1

I have this problem: I'm building an integer linear program, which I'm going to give to an ILP solver. I have a binary variable Y which can be either 1 or 0 and an integer variable MONTH which takes integer values 1-12.

I have to give restrictions such that Y = 1 if MONTH = 1, and Y = 0 otherwise.

I don't know how to do this. I can think of a way to make Y = 1 when MONTH = 1, like Y + MONTH > 2, but I can't think of a restriction to make Y = 0 otherwise.

D.W.
  • 159,275
  • 20
  • 227
  • 470
Heathcliff
  • 121
  • 1
  • 1
    See also http://cs.stackexchange.com/q/12102/755. You should mention in your question that you want something that can be used with linear programming -- presumably integer linear programming, right? – D.W. Sep 21 '15 at 04:55
  • That's right, it's ILP. Thanks, that linked helped. – Heathcliff Sep 23 '15 at 14:06

1 Answers1

1

In this case (where the possible sets of values are finite) a graphical approach can work nicely for determining a suitable set of constraints. Draw the points in the set $\{1,\dots,12\}\times\{0,1\}$ in the plane, using $+$ for allowed and $-$ for disallowed combinations:

$\begin{array} & & + & - & - & - & - & - & - & - & - & - & - & - \\ & - & + & + & + & + & + & + & + & + & + & + & +\end{array}$

Can you find a set of lines separating the $+$s from the $-$s? Note that $Y+MONTH\ge 2$ already take care of the $-$ in the bottom left corner.

Klaus Draeger
  • 2,178
  • 12
  • 17