Skip to content

Instantly share code, notes, and snippets.

@hbshrestha
Created September 21, 2021 15:04
Show Gist options
  • Save hbshrestha/2812c082634f677742ff48e4cdfe685f to your computer and use it in GitHub Desktop.
Save hbshrestha/2812c082634f677742ff48e4cdfe685f to your computer and use it in GitHub Desktop.
from pyomo.environ import *
model = ConcreteModel()
#Define variables x and y
model.x = Var (domain = NonNegativeReals)
model.y = Var (domain = NonNegativeReals)
#Define objectives
model.obj = Objective (expr = 90 * model.x + 75 * model.y, sense = maximize)
#Define Constraints
model.cons1 = Constraint (expr = 3 * model.x + 2 * model.y <= 66)
model.cons2 = Constraint (expr = 9 * model.x + 4 * model.y <= 180)
model.cons3 = Constraint (expr = 2 * model.x + 10 * model.y <= 200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment