2 回答
TA贡献1848条经验 获得超6个赞
设法解决了!对于任何可能觉得这有用的人,我传递了一个带有“symbolic_solver_labels”的字典作为该方法的 io_options 参数,如下所示:
instance.write(filename = str(es_) + ".mps", io_options = {"symbolic_solver_labels":True})
现在我的变量在 .mps 文件中已正确标记!
TA贡献1911条经验 获得超7个赞
我使用Pyomo==5.6.9,在这个版本中,“io_options”应该使用不同的方式来设置。
model.write(filename = "FILEPATH.mps", symbolic_solver_labels=True)
我检查了 Pyomo(pyomo/repn/plugins/mps.py:ProblemWriter_mps.__call__) 的源代码,在我看来,传递给该函数的“io_options”是 **kargs 但不是字典。
def __call__(self,
model,
output_filename,
solver_capability,
io_options):
# Make sure not to modify the user's dictionary,
# they may be reusing it outside of this call
io_options = dict(io_options)
...
# Use full Pyomo component names in the MPS file rather
# than shortened symbols (slower, but useful for debugging).
symbolic_solver_labels = \
io_options.pop("symbolic_solver_labels", False)
...
if len(io_options):
raise ValueError(
"ProblemWriter_mps passed unrecognized io_options:\n\t" +
"\n\t".join("%s = %s" % (k,v) for k,v in iteritems(io_options)))
- 2 回答
- 0 关注
- 140 浏览
添加回答
举报