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 關注
- 210 瀏覽
添加回答
舉報