conda install -c conda-forge pyomo
conda install -c conda-forge pyomo.extras
from __future__ import division
from pyomo.environ import *
model = ConcreteModel()
model.x = Var([1,2], domain=NonNegativeReals)
model.OBJ = Objective(expr = 2*model.x[1] + 3*model.x[2])
model.Constraint1 = Constraint(expr = 3*model.x[1] + 4*model.x[2] >= 1)
opt = SolverFactory("gurobi")
instance = model.create_instance()
results = opt.solve(instance)
results.write()
I get this error:
WARNING: DEPRECATION WARNING: Cannot call Model.create_instance() on a
constructed model; returning a clone of the current model instance.
Traceback (most recent call last):
File "/Users/hm568/git/stochOpt/src/pyomo/testopt.py", line 15, in <module>
results = opt.solve(instance)
File "/anaconda/lib/python2.7/site-packages/pyomo/opt/base/solvers.py", line 508, in solve
WARNING: "[base]/site-packages/pyomo/solvers/plugins/solvers/GUROBI.py", 233, _default_executable
Could not locate the 'gurobi' executable, which is required for solver gurobi
self.available(exception_flag=True)
File "/anaconda/lib/python2.7/site-packages/pyomo/solvers/plugins/solvers/GUROBI.py", line 139, in available
val = ILMLicensedSystemCallSolver.available(self, exception_flag)
File "/anaconda/lib/python2.7/site-packages/pyomo/opt/solver/ilmcmd.py", line 35, in available
if not pyomo.opt.solver.shellcmd.SystemCallSolver.available(self, exception_flag):
File "/anaconda/lib/python2.7/site-packages/pyomo/opt/solver/shellcmd.py", line 121, in available
raise ApplicationError(msg % self.name)
pyutilib.common._exceptions.ApplicationError: No executable found for solver 'gurobi'
Do you have an idea how I can fix this?
Thanks,
Hugh