2

I have liner programme with set of $x_{3n}$ variables where $x_{ij}$ are {0,1}. I am solving this linear programme using LP-Solve.

Using these variables, I want to form following constraint :

$max(x_1 , x_2.., x_n) + max(x_{n+1} , x_{n+2}.. , x_{2n}) + max(x_{2n+1} , x_{2n+2}..., x_{3n}) >= q$

Constraint is : Sum of max variable in set of variables should be greater than q.

How can I write constraint using $max$ operation in LP Solve?

Abhay
  • 123
  • 1
  • 4

1 Answers1

3

Introduce variables $m_1,m_2,m_3$ to represent the three maxes.

Add the linear inequality $m_1 + m_2 + m_3 \ge q$.

Then, add the following extra inequalities for $m_1$:

  • $0 \le m_1 \le 1$
  • $m_1 \le x_1 + x_2 + \dots + x_n$
  • $x_1 \le m_1$, $x_2 \le m_1$, $\dots$, $x_n \le m_1$

and similarly for $m_2$ and $m_3$.

D.W.
  • 159,275
  • 20
  • 227
  • 470
  • @ D.W. thanks ..it's working :). Previously I followed the second answer given in the link you shared but it was taking too much time to solve the problem. – Abhay Feb 28 '16 at 06:56
  • ,I did, but to show and display it publicly I have to earn 15 reputations :(. I will definitely do once I earn 15 reputations. – Abhay Mar 01 '16 at 04:13
  • @D.W. I understand the necessity for the final bullet point and was able to come up with it independently, but could you explain the reason for the other two? It seems the other two would happen implicitly due to constraints on x_i. – Christian Mar 22 '18 at 20:25
  • @Christian, the first is necessary, otherwise we might find a solution where $m_1$ is bigger than 1 (which won't be the max of $x_1,\dots,x_n$). The second is necessary, otherwise we might have $x_1=\cdots=x_n=0$ but $m_1=1$ (which wouldn't be the max). – D.W. Mar 22 '18 at 21:08
  • @D.W. Thanks for clarifying. I was thinking through the lens of a minimization problem where those things would be impossible and hadn't considered the more general case. – Christian Mar 23 '18 at 21:53