AbstractModel VS ConcreteModel of pyomo? how does “opt.options[”tol“]” make the difference in finding optimal solution?

不羁岁月 提交于 2019-12-11 15:26:23

问题


I have an AbstractModel and a ConcreteModel solving the same problem, but they are performing differently. It is mainly about initial value of a variable and tolerance of ipopt.

  1. When I initialize my variable model.x as 10 and opt.options["tol"] = 1E-64: ConcreteModel can find optimal solution, while abstract model "Solved To Acceptable Level". (But the solutions they find are actually the same)

  2. When I initialize my variable model.x as 100 and opt.options["tol"] = 1E-64: ConcreteModel can find the optimal solution, while abstract model sometimes "Solved To Acceptable Level" and sometimes "Cannot load a SolverResults object with bad status: error".

  3. If I just use the ipopt's default value of the tolerance, both ConcreteModel and AbstractModel can find the same optimal solution no matter how I initialize the variable model.x.

So I wonder how opt.options["tol"] makes a difference? Why is ConcreteModel always able to find an optimal solution in this case while AbstractModel not?

Variable

model.x = Var(model.Crops, model.Inputs, initialize = 100, within=NonNegativeReals)

solve script of AbstractModel

instance = model.create_instance(data="AbstractCDFarm.dat")
opt = SolverFactory("ipopt")
opt.options["tol"] = 1E-64
results = opt.solve(instance, tee=True) 
instance.display()

solve script of ConcreteModel

opt = SolverFactory('ipopt')
opt.solve(model, tee=True) 
opt.options["tol"] = 1E-64
results = opt.solve
model.display()

回答1:


You're calling solve twice for the ConcreteModel and it looks like the output you're seeing is for the default Ipopt tolerance not for the tolerance of 1E-64. Why are you setting such a low tolerance? 1E-64 is smaller than machine precision so it's an impossibly small tolerance to converge to.



来源:https://stackoverflow.com/questions/56700933/abstractmodel-vs-concretemodel-of-pyomo-how-does-opt-optionstol-make-the

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!