1

I have the following linear program.

$$\begin{array}{ll} \text{maximize} & x_1 + 2 x_2 + 3 x_3\\ \text{subject to} & x_1 + x_2 - x_3 = 1\\ & -2 x_1 + x_2 + 2 x_3 \geq -5\\ & x_1 - x_2 \leq 4\\ & x_2 + x_3 \leq 5\\ & x_1, x_2, x_3 > 0\\ & \color{gray}{\text{No two values are the same}}\end{array}$$

The problem I am facing is that I need to formulate the requirement that "no two values are the same" in a linear equation so that I can apply the Simplex method. I need to convert

$$ (x_1 \neq x_2) \wedge (x_2 \neq x_3) \wedge (x_1 \neq x_3) $$

into one or more linear constraints, but I don't know how. Please help. Thanks.

Update-1: I noticed a similar question at: How can not-equals be expressed as an inequality for a linear programming model

NoChance
  • 6,427
  • Have you tried solving the linear program without the "no two values are the same" constraint? – Rodrigo de Azevedo Feb 03 '18 at 08:06
  • @RodrigodeAzevedo, yes I did. In fact this is an example from a LP Calculator and the feasible solution is: 4.6667, 0.6667, 4.3333. No 2 values are equal here, but I wanted to know how express the constraint. – NoChance Feb 03 '18 at 09:52
  • 1
    You may want to take a look at chapter 5 of Decision Procedures. Some slides are available here. – Rodrigo de Azevedo Feb 03 '18 at 11:09
  • @RodrigodeAzevedo, I had not known about the topic of "Decision Procedures" before. Very interesting concept. Thanks for sharing. – NoChance Feb 03 '18 at 12:43
  • Can you give an example of a practical problem where you work with continuous decision variables and have a not equal condition, and thus allowing values arbitrarily close to each other? – Johan Löfberg Feb 03 '18 at 12:51
  • @JohanLöfberg, One example would be trying to solve a Sudeko problem. In this game, no two variables in the same row or column can be of the same value. Mind you in this case, it would be an integer programming problem. – NoChance Feb 03 '18 at 18:37
  • 1
    exactly,you're doing mixed-integer programming as the decision variables definitely aren't continuous. I'm asking about a relevant LP problem – Johan Löfberg Feb 03 '18 at 18:40
  • I guess one could come out with such a problem, say Max Z=X+Y where X and Y are both positive and between n and n+0.1 (where n is any real value). – NoChance Feb 03 '18 at 19:04
  • You can of course come up with any random problem where you add not equal, but I am asking for a real-world problem where you must have x and y different but arbitrarily close would be ok. – Johan Löfberg Feb 03 '18 at 19:15
  • @JohanLöfberg I don't have a real-world example. It does not look like an easy task for me to come-up with one! – NoChance Feb 03 '18 at 21:16
  • 1
    Precisely. On real-word problems with continuous variables, not equal really does not make sense, but you would have some quantization involved, such as $|x-y|\geq L$, and that model is easily MILP-representable, as discussed in the question you linked to. – Johan Löfberg Feb 04 '18 at 06:22

2 Answers2

4

not equal is nonconvex and cannot be expressed using linear programming but requires a combinatorial approach, i.e. effectively in your case mixed-integer linear programming

What's worse though is that not equal in continuous variables really isn't well-posed, just as your strict positivity requirement is ill-posed. As a trivial example, consider minimize $|x-y|$ subject to $x\neq y$. Obviously no minimizer as you can make the optimal value arbitrarily small, but $0$ is not feasible.

Johan Löfberg
  • 9,497
  • 1
  • 15
  • 15
2

Assuming it's not integer programming, everything is continuous so the "probability" that the optimal solution has two values the same is $0$. Even if it does, you could add or subtract any $\epsilon>0$ from one value to make them unequal.

Otherwise you would need to split it into six linear programs with conditions $x_1<x_2<x_3$ and permutations, because $x_1\neq x_2$ isn't convex.

Akababa
  • 3,109
  • lmao I didn't even notice that – Akababa Feb 03 '18 at 08:37
  • Assuming the polytope has nonzero volume, every neighborhood of the vertex intersects the polytope with positive measure. On the other hand the planes $x_1=x_2$ etc have 0 measure, so just take a point in the neighborhood. – Akababa Feb 03 '18 at 09:13
  • I would assume that the, in general, the probability of all variables to be of the same value is not zero. However, breaking the problem in all possible combinations is theoretically valid. If we add the assumption that $x$ values are all integers, could we find a way to solve it? – NoChance Feb 03 '18 at 09:42
  • Well the planes $x_1=x_2$, etc. actually divide the $\mathbb{Z^3}$ into 6 regions, so in general you can't solve it with one linear program unless your polytope lies in one of them (i.e. you can deduce the ordering of $x_1,x_2,x_3$ from the other inequalities). – Akababa Feb 03 '18 at 09:47
  • Well you can always split it into 6 linear programs. The "perturbation" argument is only an intuitive explanation of why you can find solutions arbitrarily close to the optimum. – Akababa Feb 03 '18 at 10:10
  • your suggestion about $\epsilon>0$ is valid for the non-integer case. See my question updates. Thank you. – NoChance Feb 03 '18 at 10:25