from pyomo.contrib.simplemodel import SimpleModel
m = SimpleModel()
x = m.var('x')
m += x == 1
m.solve('glpk')
results in this error traceback:
File "/usr/local/lib/python3.6/dist-packages/pyomocontrib_simplemodel/core.py", line 177, in solve
return solver.solve(self.model, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/pyomo/opt/base/solvers.py", line 569, in solve
self._presolve(*args, **kwds)
File "/usr/local/lib/python3.6/dist-packages/pyomo/opt/solver/shellcmd.py", line 200, in _presolve
OptSolver._presolve(self, *args, **kwds)
File "/usr/local/lib/python3.6/dist-packages/pyomo/opt/base/solvers.py", line 669, in _presolve
**kwds)
File "/usr/local/lib/python3.6/dist-packages/pyomo/opt/base/solvers.py", line 740, in _convert_problem
**kwds)
File "/usr/local/lib/python3.6/dist-packages/pyomo/opt/base/convert.py", line 105, in convert_problem
problem_files, symbol_map = converter.apply(*tmp, **tmpkw)
File "/usr/local/lib/python3.6/dist-packages/pyomo/solvers/plugins/converter/model.py", line 88, in apply
io_options=io_options)
File "/usr/local/lib/python3.6/dist-packages/pyomo/core/base/block.py", line 1716, in write
io_options)
File "/usr/local/lib/python3.6/dist-packages/pyomo/repn/plugins/cpxlp.py", line 175, in __call__
include_all_variable_bounds=include_all_variable_bounds)
File "/usr/local/lib/python3.6/dist-packages/pyomo/repn/plugins/cpxlp.py", line 553, in _print_model_LP
"ERROR: No objectives defined for input model. "
ValueError: ERROR: No objectives defined for input model. Cannot write legal LP file.
Dummy objective functions
from pyomo.contrib.simplemodel import SimpleModel
m = SimpleModel()
m += 1.0
x = m.var('x')
m += x == 1
m.solve('glpk')
results in this error traceback:
prob += 1.0 # dummy objective
File "/usr/local/lib/python3.6/dist-packages/pyomocontrib_simplemodel/core.py", line 147, in __iadd__
elif expr.is_relational():
AttributeError: 'float' object has no attribute 'is_relational'
Dummy objectives are now supported, but not omitted objectives. Maybe the solve() function can add a dummy objective, if there are zero objective functions defined.
Both of these seem to produce an error in v1.0.2
Not defining the objective function:
results in this error traceback:
Dummy objective functions
results in this error traceback: