Skip to content

Instantly share code, notes, and snippets.

@mfansler
Created December 9, 2020 18:13
Show Gist options
  • Select an option

  • Save mfansler/97783e5cb74245924c8fe840cea2f5ff to your computer and use it in GitHub Desktop.

Select an option

Save mfansler/97783e5cb74245924c8fe840cea2f5ff to your computer and use it in GitHub Desktop.
Conda environment for Pyomo with IPOPT
name: so-ipopt
channels:
- conda-forge
- defaults
dependencies:
- pyomo
- ipopt
@mfansler
Copy link
Author

mfansler commented Dec 9, 2020

Created for this SO question.

Test Case

(base) $ conda env create -f so-ipopt.yaml
(base) $ conda activate so-ipopt
(so-ipopt) $ python

Once in Python interpreter, run

from pyomo.environ import *

# model
m = ConcreteModel()
m.x = Var()
m.c = Constraint(expr=m.x >= 2)
m.o = Objective(expr=m.x)

# solver
s = SolverFactory('ipopt')
#s.options['fixed_variable_treatment'] = 'make_parameter'  # this line didn't work for me
s.solve(m, tee=True, keepfiles=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment