Mixed-Integer
Programming in Python
A simple example with Pyomo and HiGHS
Why integer?
• Some decisions
only make sense
when
considering
integer values
• Ex: the number
of trips a delivery
truck does
A simple example
Its linear relaxation
And the discrete domain
Pyomo + HiGHS
import [Link] as pyo
from [Link] import Highs
model = [Link]()
model.x = [Link]([1, 2], within=[Link])
model.c1 = [Link](expr=2 * model.x[1] + 3 * model.x[2] <= 12)
model.c2 = [Link](expr=2 * model.x[1] + model.x[2] <= 6)
[Link] = [Link](expr=5 * model.x[1] + 4 * model.x[2],
sense=[Link])
solver = Highs()
solver.highs_options = {"time_limit": 10}
res = [Link](model)
Give it a try!
pip install pyomo>=6.6.0
pip install highspy
Keep an eye out 👁️ more optimization content
Like 👍, share, comment 💬 (it’s free)