2
$\begingroup$

I have variables $x \in \{0,1,\dots,5\}$ and $y \in \{0,1\},ドル where

$$y = \begin{cases} 0 & \text{if } x = 5\\ 1 & \text{if } x \neq 5\end{cases}$$

My problem is to maximize $y$. How can I use linear constraints for this?

I tried certain cases like Cast to boolean, for integer linear programming but that won't work if the problem is to maximize $y$.

asked Mar 30, 2017 at 7:56
$\endgroup$
3
  • 1
    $\begingroup$ What about $y \leq 5-x$? $\endgroup$ Commented Mar 30, 2017 at 8:30
  • $\begingroup$ @Eugene This ensures that $y = 0$ if $x = 5,ドル but doesn't ensure that $y = 1$ otherwise. $\endgroup$ Commented Mar 30, 2017 at 10:40
  • $\begingroup$ @Yuval Filmus Indeed, it does not alone. But with objective maximize $y$ mentioned by OP and $y$ - binary, it should. $\endgroup$ Commented Mar 30, 2017 at 14:28

2 Answers 2

3
$\begingroup$

Add the following two constraints: $$ y \leq 5-x \\ y \geq 1-x/5 $$ If $x = 5,ドル then these constraints state that $y \leq 0$ and $y \geq 0,ドル hence $y = 0$. If $x \leq 4,ドル then 5ドル-x \geq 1,ドル and so the first constraint doesn't impose any constraint on $y$. On the other hand, 1ドル-x/5 > 0,ドル forcing $y = 1$; and this assignment satisfies the constraint since $x \geq 0$ implies 1ドル-x/5 \leq 1$.

answered Mar 30, 2017 at 10:41
$\endgroup$
0
$\begingroup$

Let $f : \{0,1,\dots,5\} \to \{0,1\}$ be defined by

$$f (x) := \begin{cases} 0 & \text{if } x = 5\\ 1 & \text{if } x \neq 5\end{cases}$$

Let $ y = f (x)$. We would like to maximize $y$. Note that the preimage of 1ドル$ is

$$f^{-1} (1) = \{0,1,2,3,4\}$$

Wherever $y$ appears, just make $y = 1$ and then append the constraints 0ドル \leq x$ and $x \leq 4,ドル where $x \in \mathbb N$. Instead of an optimization problem, we have a decision problem that can be solved via integer programming, e.g.,

$$\begin{array}{ll} \text{minimize} & 0\\ \text{subject to} & \color{grey}{\text{(linear constraints on } x \text{)}}\\ & 0 \leq x \leq 4\\ & x \in \mathbb N\end{array}$$

answered Mar 31, 2017 at 16:51
$\endgroup$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.