Cplex gives two diffirent results?
<p>I use Python API in Cplex to solve a Linear programing problem. When using Cplex, I had the result below:</p>

<p><a href="http://i.stack.imgur.com/1BqQ2.png" rel="nofollow"><img src="http://i.stack.imgur.com/1BqQ2.png" alt="The result is solved directly by Python API"></a></p>

<p>But then I saved my LP prolem as a <strong>lp file</strong> and use Cplex to solve again, the result was a little bit difirence from the first one:</p>

<p><a href="http://i.stack.imgur.com/A7qTB.png" rel="nofollow"><img src="http://i.stack.imgur.com/A7qTB.png" alt="enter image description here"></a>
Anyone gives an explaination?</p>

<p>Below is my function:</p>

<pre><code>def SubProblem(myobj,myrow,mysense,myrhs,mylb):
c = cplex.Cplex()
c.objective.set_sense(c.objective.sense.minimize)
c.variables.add(obj = myobj,lb = mylb)
c.linear_constraints.add(lin_expr = myrow, senses = mysense,rhs = myrhs)
c.solve()
lpfile = "Save_models\clem.lp"
c.write(lpfile)
print("\nFile '%s' was saved"%(lpfile))
</code></pre>

<p>Just to add to rkersh's comment. CPLEX when run in deterministic mode should give identical answers every time. However, if you write the model out as an LP file you will lose some precision in some of the numbers and this will perturb the problem even if only slightly, and that will often lead to different answers. The SAV format is the closest you can get to a faithful copy of the model that was inside CPLEX at the time it was saved. But even then I am not certain that the behaviour of CPLEX through the interactive solver will be identical to that through the API. If you run them on the same hardware, I would hope that they would be the same, but on a different machine you might still get different behaviour (different cpu, memory etc)</p>

python mathematical-optimization cplex