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()
==========================================================
# = Solver Results =
# ==========================================================
# ----------------------------------------------------------
# Problem Information
# ----------------------------------------------------------
Problem:
- Name:
Lower bound: 0.666666666667
Upper bound: 0.666666666667
Number of objectives: 1
Number of constraints: 2
Number of variables: 3
Number of binary variables: 0
Number of integer variables: 0
Number of continuous variables: 3
Number of nonzeros: 3
Sense: minimize
# ----------------------------------------------------------
# Solver Information
# ----------------------------------------------------------
Solver:
- Status: ok
Return code: 0
Message: Model was solved to optimality (subject to tolerances), and an optimal solution is available.
User time: 0.0
System time: 0.0
Termination condition: optimal
Termination message: Model was solved to optimality (subject to tolerances), and an optimal solution is available.
Error rc: 0
Time: 0.233999967575
# ----------------------------------------------------------
# Solution Information
# ----------------------------------------------------------
Solution:
- number of solutions: 0
number of solutions displayed: 0
WARNING: DEPRECATION WARNING: Cannot call Model.create_instance() on a
constructed model; returning a clone of the current model instance.
# ==========================================================
# = Solver Results =
# ==========================================================
# ----------------------------------------------------------
# Problem Information
# ----------------------------------------------------------
Problem:
- Name:
Lower bound: 0.666666666667
Upper bound: 0.666666666667
Number of objectives: 1
Number of constraints: 2
Number of variables: 3
Number of binary variables: 0
Number of integer variables: 0
Number of continuous variables: 3
Number of nonzeros: 3
Sense: minimize
# ----------------------------------------------------------
# Solver Information
# ----------------------------------------------------------
Solver:
- Status: ok
Return code: 0
Message: Model was solved to optimality (subject to tolerances), and an optimal solution is available.
User time: 0.0
System time: 0.0
Termination condition: optimal
Termination message: Model was solved to optimality (subject to tolerances), and an optimal solution is available.
Error rc: 0
Time: 0.233999967575
# ----------------------------------------------------------
# Solution Information
# ----------------------------------------------------------
Solution:
- number of solutions: 0
number of solutions displayed: 0
instance = model.create_instance()
results = opt.solve(instance)
to be
results = opt.solve(model)
(You would have needed those two lines if you had been using an
AbstractModel object)
--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.