1

I have a linear programming question

I have integer values t[i] such that |t[i]| < M.

Each T[i] is a positive or negative integer bound by a known maximum

I'd like to set a value c[i] such that c[i] is zero if t[i] <> 0

How do I do this?

The more general is probably setting a boolean, 0 or 1 for equals or not equals.

Nickle
  • 111
  • 3

2 Answers2

1

The implication $$t_i=0 \Rightarrow c_i=0$$ can be restated as: $$c_i=1 \Rightarrow t_i<0 \text{ or } t_i>0$$ In a MIP model you can do: $$\begin{align} & t_i \le -0.001+M(1-c_i)+M\delta_i\\ & t_i \ge +0.001-M(1-c_i)-M(1-\delta_i)\\ &\delta_i \in \{0,1\} \end{align}$$ I am not using here that your $t_i$ are integer. Not much changes when using that additional restriction. One thing we can do, is replacing 0.001 by 1.

Here my $M$ is the usual big-$M$. It can be set to your $M+1$.

  • Thanks. I'll get out some paper and work through it. I had got to the restatement but not made the jump to the next bit. – Nickle Nov 13 '17 at 21:35
  • Doing some more work on it I've changed my model. By doing that I can change it so the indicator variable {0,1} is just checking if something is positive. That way the test is far easier since there is no OR condition.

    Thanks for your help!

    – Nickle Nov 23 '17 at 08:41
0
max: c;
t = 0;
t <= -0.1 + 10 - 10 c + 10 d;
t >= +0.1 - 10 + 10 c + 10 d - 10;
int c;
bin d;

As an LP Solve solution I think works. M = 10, and the epsilon = 0.1.

Nickle
  • 111
  • 3