运行cplex / pyomo求解器找到了一个解决方案,尽管我在记笔记之前关闭了该解决方案,但报告说它保存在某个位置,无法在网上找到它的存储位置。
正在运行的窗口,有人吗?
我不知道pyomo如何精确地调用CPLEX来将解决方案存储在磁盘上。 CPLEX的默认行为是将解决方案存储在当前工作目录中。解决方案文件的后缀为.sol
或.mst
。
默认情况下,pyomo在您调用pyomo的目录中生成一个json文件results.json。
让我接受pyomo中的bus example:
在文件pyomobus.py中
from pyomo.environ import *
model = ConcreteModel()
model.nbBus = Var([40,30], domain=PositiveIntegers)
model.OBJ = Objective(expr = 600*model.nbBus[40] + 480*model.nbBus[30])
model.nbKids = Constraint(expr = 40*model.nbBus[40] + 30*model.nbBus[30] >= 300)
然后输入该目录,然后输入
pyomo solve pyomobus.py --solver=cplex
您将在将要读取的目录中得到一个文件results.json
"Problem": {},
"Status": "optimal",
"Variable": {
"nbBus[30]": {
"Value": 2.0
},
"nbBus[40]": {
"Value": 6.0
}