Tom's solution for the Gadgets & More Inc. problem:

In [1]:
from pyomo.environ import *
from pyomo.opt import *
opt = solvers.SolverFactory("ipopt")
model = ConcreteModel()
In [2]:
model.x = Var(within=NonNegativeReals)
model.y = Var(within=NonNegativeReals)

model.c = Constraint(expr = 4*model.y + 6*model.x <= 24)

model.z = Objective(expr = 2*model.x**2 + model.y**2, sense=maximize)
In [3]:
results = opt.solve(model)
model.x.get_values()[None]
Out[3]:
4.000000046353438
In [4]:
model.y.get_values()[None]
Out[4]:
0.0
In [5]:
model.z.expr()
Out[5]:
32.00000074165502