Hello all: I want to implement the following constraint in my linear programing model: If A=B then C=1 Else C=0 I have been looking around and there are similar problems but nobody has been helpful to address the 'non equal to' condition. Thank you in advance. asked 27 Sep '14, 17:45 Chicago 
As I understand the question, you want \(c\) to be binary, and \(c=1\) if and only if \(A=B\). I will make a couple of assumptions:
Here's the formulation: \[ \begin{align} A &\le B + My  \epsilon z \\ B &\le A + Mz  \epsilon y \\ c+y+z&=1 \\ c,y,z &\in \{0,1\} \end{align} \] Now, if \(c=1\), then \(y=z=0\). In this case, the constraints reduce to \( A \le B\) and \(B \le A\), so \(A=B\). Otherwise, \(c=0\). Then \(y+z=1\). There are two cases. In the first case, \(y=1,z=0\). Then the constraints reduce to \(A \le B + M\), which is always satisfied, and \(B \le A\epsilon\), which implies \(B < A\). In the second case, \(y=0,z=1\). The analysis in this case is similar and implies \(A < B\). So if \(c=0\), then \(A \neq B\). You can also reduce the number of variables by replacing all occurrences of \(z\) by \(1cy\). But, the MIP solver will probably do this anyway. answered 27 Sep '14, 19:46 Austin Buchanan Thank you so much! This was indeed helpful! Kudos!
(27 Sep '14, 21:55)
Chicago

I would suggest the usage of an indicator constraint. I had a similar problem which is when @Florian suggested the usage of an indicator constraint. More information could be found in the cplex docs. You can find the syntax for the appropriate language over there. link text Thanks to Florian answered 16 Oct '14, 05:17 crypto 