Pyomo:为求解器界面生成.nl文件时出错

时间:2018-09-18 14:40:04

标签: pyomo

我正在使用一个具体的模型来设置几个优化问题。 但是,在某些情况下,通过SolverFactory (opt = SolverFactory('gurobi_ampl',solver_io='nl'))用Gurobi_AMPL求解pyomo模型时会发生错误。

在这种情况下,python返回以下错误代码以及MemoryError:

File "C:\win32app\Winpython\python-2.7.9\lib\site-packages\pyomo\opt\base\solvers.py, line 599, in solve
    self._presolve(*args,**kwds)
File "C:\win32app\Winpython\python-2.7.9\lib\site-packages\pyomo\solvers\plugins\solvers\ASL.py", line 189, in _presolve
    SystemCallSolver._presolve(self, *args, **kwds)
File "C:\win32app\Winpython\python-2.7.9\lib\site-packages\pyomo\opt\solver\shellcmd.py", line 196, in _pyresolve
    OptSolver._presolve(self, *args, **kwds)
File "C:\win32app\Winpython\python-2.7.9\lib\site-packages\pyomo\opt\base\solvers.py", line 699, in _presolve
    **kwds)
File "C:\win32app\Winpython\python-2.7.9\lib\site-packages\pyomo\opt\base\solvers.py", line 770, in _convert_problem
    **kwds)
File "C:\win32app\Winpython\python-2.7.9\lib\site-packages\pyomo\opt\base\convert.py", line 110, in convert_problem
    problem_files, symbol_map = converter.apply(*tmp, **tmpkw)
File "C:\win32app\Winpython\python-2.7.9\lib\site-packages\pyomo\solvers\plugins\converter\model.py", line 192, in apply
    io_options=io_options)
File "C:\win32app\Winpython\python-2.7.9\lib\site-packages\pyomo\core\base\block.py", line 1681, in write
    io_options)
File "C:\win32app\Winpython\python-2.7.9\lib\site-packages\pyomo\repn\plugins\ampl\ampl_.py", line 392, in __call__
    include_all_variable_bounds=include_all_variable_bounds)
File "C:\win32app\Winpython\python-2.7.9\lib\site-packages\pyomo\repn\plugins\ampl\ampl_.py", line 1177, in _print_model_NL
    for column_id,var_ID in enumerate(full_var_list)])
File "C:\win32app\Winpython\python-2.7.9\lib\site-packages\pyomo\core\kernel\symbol_map.py", line 68, in addSymbols
    self.bySymbol.update((symb_, weakref_ref(obj_)) for obj_,symb_ in tuples)
MemoryError

该错误可能实际上并不是MemoryError,因为我在内存使用中没有出现过多的峰值。 但是,在我看来,.nl文件的生成会导致错误。

尽管如此,使用model.write('model.nl')单独生成.nl文件时,会生成.nl文件而不会出错。

这是一个熟悉的问题吗? 设置错误的参数值可以导致这种错误吗?

0 个答案:

没有答案