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>If I understand correctly, you are solving the second time using the LP file you exported in the first run. You can loose precision when writing to LP format. Try with <a href="https://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.3/ilog.odms.cplex.help/CPLEX/FileFormats/topics/SAV.html" rel="nofollow">SAV</a> format instead.</p>

python mathematical-optimization cplex