1. Home
  2. Docs
  3. Tutorials
  4. Pyomo tutorial
  5. Pyomo on Windows

Pyomo on Windows

Step 1: Make sure Python and Pyomo are installed

If Python is not installed, go to https://www.python.org/downloads and download the Python installer and install Python 3.8+.

If Pyomo is not installed, do:

python -m pip install pyomo

or

py -m pip install pyomo

If you encounter issues, you can check the Pyomo installation guide for more details.

Step 2: Run the Octeract Engine installer

Pretty self-explanatory, download and run the installer to install the engine. The installer will add the engine to the Windows Path so that Pyomo will be able to find the binary.

Step 3: Create and solve your model

import os
from pyomo.environ import *

os.environ["octeract_options"] = "num_cores=4"

model = m = ConcreteModel()

x1 = m.x1 = Var(within=Reals, bounds=(0,1), initialize=1)
x2 = m.x2 = Var(within=Reals, bounds=(0,1), initialize=1)
x3 = m.x3 = Var(within=Reals, bounds=(0,1), initialize=None)
x4 = m.x4 = Var(within=Reals, bounds=(0,1), initialize=1)
x5 = m.x5 = Var(within=Reals, bounds=(0,1), initialize=None)

m.obj = Objective(sense=minimize, expr=42*x1 - 0.5*(100*x1*x1 + 100*x2*x2 + 100*x3*x3 + 100*x4*x4 + 100*x5*x5) + 44*x2 + 45*x3 + 47*x4 + 47.5*x5)
m.e2 = Constraint(expr=20*x1 + 12*x2 + 11*x3 + 7*x4 + 4*x5 <= 40)

results = SolverFactory("octeract-engine").solve(m, tee=True, keepfiles=False, load_solutions=False)

print(results)

If you’d prefer to get creative, refer to the list of modeling components for Pyomo.