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

In [1]:
from pyomo.environ import *
from pyomo.opt import *
opt=solvers.SolverFactory("glpk")
model=ConcreteModel()
In [2]:
model.x1=Var(within=NonNegativeIntegers)
model.x2=Var(within=NonNegativeIntegers)
model.y1=Var(within=NonNegativeIntegers)
model.y2=Var(within=NonNegativeIntegers)
model.b1=Var(within=Boolean)
model.b2=Var(within=Boolean)

model.c1 = Constraint(expr = 6*model.x1 + 6*model.x2 + 
                             4*model.y1 + 4*model.y2 <= 24)
model.c2 = Constraint(expr = model.x1 <= 2)
model.c3 = Constraint(expr = model.y1 <= 3)
model.c4 = Constraint(expr = model.b1*2 <= model.x1)
model.c5 = Constraint(expr = model.b2*3 <= model.y1)
model.c6 = Constraint(expr = model.x2 <= model.b1*2)
model.c7 = Constraint(expr = model.y2 <= model.b2*3)

model.z = Objective(expr = 4*model.x1 + 12*model.x2 + 
                           3*model.y1 + 9*model.y2, 
                    sense=maximize)     
In [3]:
results = opt.solve(model)
model.x1.get_values()[None] + model.x2.get_values()[None]
Out[3]:
0.0
In [4]:
model.y1.get_values()[None] + model.y2.get_values()[None]
Out[4]:
6.0
In [5]:
model.z.expr()
Out[5]:
36.0