Эта проблема также может быть смоделирована как обобщенная дизъюнктивная программа (ВВП). Это более подробный, но более описательный.
from pyomo.environ import *
from pyomo.gdp import *
m = ConcreteModel()
m.total_weight_cost = Var(domain=NonNegativeReals)
m.weight = Var(domain=NonNegativeReals)
m.weight_buckets = RangeSet(2)
m.weight_bucket_lb = Param(m.weight_buckets, initialize={1: 0, 2: 200})
m.weight_bucket_ub = Param(m.weight_buckets, initialize={1: 200, 2: 300})
m.weight_bucket_cost = Param(m.weight_buckets, initialize={1: z, 2: y})
m.weight_bucket_disjunction = Disjunction(expr=[
[m.total_weight_cost == m.weight_bucket_cost[bucket] * m.weight,
m.weight_bucket_lb[bucket] <= m.weight,
m.weight <= m.weight_bucket_ub[bucket]
for bucket in m.weight_buckets]
])
TransformationFactory('gdp.bigm').apply_to(m)
SolverFactory('gurobi').solve(m, tee=True)
m.display()