Use max operation in a constraint in Linear Programming 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}) &gt;= 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?
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$.