Cplex给出两个不同的结果? [英] Cplex gives two different results?

查看:108
本文介绍了Cplex给出两个不同的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Cplex中使用Python API解决了线性编程问题.使用Cplex时,结果如下:

I use Python API in Cplex to solve a Linear programing problem. When using Cplex, I had the result below:

但是随后我将LP问题保存为 lp文件,并再次使用Cplex进行了求解,结果与第一个有所不同:

But then I saved my LP prolem as a lp file and use Cplex to solve again, the result was a little bit difference from the first one:

有人给一个解释吗?

下面是我的功能:

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))

推荐答案

如果我理解正确,那么您将使用第一次运行中导出的LP文件来解决第二次问题.写入LP格式时,您可能会降低精度.尝试使用 SAV格式.

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 SAV format instead.

这篇关于Cplex给出两个不同的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆