PyomoFest Notre Dame!
/PyomoFest Notre Dame was hosted by Alex Dowling and Jeff Kantor during the first week of June 2018. Pyomo developers had a chance to give some tutorials and also gain exposure to the interesting work being done at Notre Dame.
PyomoFest Notre Dame was hosted by Alex Dowling and Jeff Kantor during the first week of June 2018. Pyomo developers had a chance to give some tutorials and also gain exposure to the interesting work being done at Notre Dame.
We are on the move! Documentation has been converted to sphinx and is now on readthedocs. See http://pyomo.readthedocs.io/en/latest/
There will be another Pyomo-fest on October 3 and 4 in Trondheim, Norway. To register, send an email to me, DLWoodruff, at UCDavis in the edu domain. The fests are an opportunity for Pyomo users to present their work and to talk with Pyomo developers about ideas for new developments. We typically begin with a short tutorial on using Pyomo and present updates on the project.
This post is really only of interest to folks doing research in the area of stochastic programming. A Pyomo model and PySP data for the well-known SSLP benchmark problem are available online as well as a short document with some performance benchmarks at
https://github.com/DLWoodruff/sslp-pysp
There is a public image on docker hub that has Pyomo and glpk. To use it, install docker, run docker, and then use a command like:
docker pull dlwoodruff/pyomoglpk
to get get the image. Once you have the image, you probably want to run it with a local file system mounted using a command like:
docker run -i -t -v /home/woodruff:/home/woodruff pyomoglpk /bin/bash
Depending on your environment, you may need to use sudo before the docker commands or you may need to do some work on a windows machine to make a mount available. Docker is well documented, so you can get more details on how to do these things. The main advantage of docker is that you could distribute your Pyomo model to someone who has docker, but does not want to, or cannot, install Python, Pyomo, and glpk. I realize that's a pretty small number of folks.
This post covers some of the major changes that have occurred in Pyomo over the last few release cycles and how to go about updating code that was written with versions of Pyomo older than 4.x.
Old Coopr Code:
from coopr.pyomo import * from coopr.opt import SolverFactory |
Pyomo 4.x Code:
from pyomo.environ import * from pyomo.opt import SolverFactory |
Old Coopr Code:
results = opt.solve(instance) instance.load(results) |
Pyomo 4.x Code:
results = opt.solve(instance, load_solutions=False) instance.solutions.load_from(results) |
Old Coopr Code:
instance.x[1].fix(5.0) instance.preprocess() results = opt.solve(instance) |
Pyomo 4.x Code:
instance.x[1].fix(5.0) results = opt.solve(instance) |
Thanks to Francisco Muñoz who organized a great workshop in Santiago at Universidad Adalfo Ibañez.
Need to try out a new feature or fix that will be in the next Pyomo release? Then you will want to install Pyomo from trunk. In most cases, this can be accomplished using the pyomo_install script available at https://software.sandia.gov/trac/pyomo/downloader. This post will review how to use this script, but also introduce another method for installing from trunk that uses the pip command.
To install from trunk using the pyomo_install script, one must execute a shell command such as the following:
$ python pyomo_install --trunk --venv pyomo_python
The --venv option in this command tells the install script to create a new python installation in a directory named pyomo_python. If the installation was successful, the pyomo_python directory will contain a sub-directory named bin. Inside bin there will be a new python executable along with other Pyomo commands. The python executable inside this directory needs to be used when launching scripts that import Pyomo packages. You might find it preferable to just make this your default python by adding this bin directory to the beginning of your PATH environment variable. Be aware that installing trunk requires that the svn command (subversion) be available in your command shell.
On some systems, including Windows, you might run into issues with the above installation method. A nice alternative to using the pyomo_install script is to use the Python-based package manager pip. With more recent versions of Python, pip comes installed by default. If you have an older version Python (some versions of 2.7 and earlier), you must first obtain pip by downloading and executing the get-pip.py script found at https://pip.pypa.io/en/stable/installing. In addition to pip, the git command also needs to be available from your command shell.
Once the pip and git commands are available, installation of Pyomo trunk proceeds as follows:
Install the master branch of PyUtilib from GitHub using pip:
$ pip install git+https://github.com/PyUtilib/pyutilib
If in the future you ever need to remove Pyomo and Pyutilib, simply execute the command:
$ pip uninstall Pyomo Pyutilib
To update to a new Pyomo release, execute the command:
$ pip install -U Pyomo
If you are on Windows, the Pyomo installation process will create a sub-directory named 'Scripts' inside of the directory where Python is installed on your system. Although your system Python will already be able to execute Pyomo scripts, the Scripts sub-directory will contain the other various Pyomo tools that you might find useful (such as the pyomo command). Adding this directory to your PATH will make these tools available the next time you open a command shell. The screenshot below shows how I edited my PATH environment variable on Windows 8 for a Python2.7 installation located in C:\Python27.
(Update: This post was edited after the git "pyomo" development branch of Pyutilib was permanently merged with the git master branch of Pyutilib)
(Update: This post was edited after Pyomo was moved onto GitHub)
If you are new to Pyomo or teaching a course that uses Pyomo, you might find a series of videos helpful that are posted at: http://dlwoodruff.ucdavis.edu/PyomoVideos/VList1.html
The Documentation page has been updated to include a link to the Pyomo Gallery. This repository contains Pyomo model and scripting examples. We welcome contributions from users (see here)!
Users and potential users are invited to attend a workshop concerning Pyomo. We can change the schedule a little to accommodate participants but the plan is as follows:
Wednesday, 16. March: Tutorials for new users and review of new features for advanced users
Thursday, 17. March: User presentations and advanced topics
Friday, 18. March: Collaboration and advanced topics
The workshop will be held at RWTH Aachen:
Aixtron A
Ground floor, Room number Se1
Kackerstraße 15, Aachen, Germany
If you plan to participate, please send an email to DLWoodruff@UCDavis.edu
Organizers:
Alexander Mitsos; Aachen University; alexander.mitsos@avt.rwth-aachen.de
Bill Hart; Sandia National Laboratories; wehart@sandia.gov
Carl Laird; Purdue University; lairdc@purdue.edu
John Siirola; Sandia National Laboratories; jdsiiro@sandia.gov
Jean-Paul Watson: Sandia National Laboratories; jwatson@sandia.gov
David Woodruff; UC Davis; dlwoodruff@ucdavis.edu
To use the solver glpk with Pyomo, it must be installed so the command glpsol --help can be given on the command line from any directory. That is pretty easy to do on a Unix machine, but a little trickier on Windows. In this video we show you how it looks if you have glpk on the machine, but not fully installed. The video does not show you how to fully install it. That is not really a Pyomo issue and there is more than one way, but you can google that. Here's a video link:
http://dlwoodruff.ucdavis.edu/badGLPK.mp4
We are pleased to announce the release of Pyomo 4.1 (4.1.10519). Pyomo is a collection of Python software packages that supports a diverse set of optimization capabilities for formulating and analyzing optimization models.
The following are highlights of this release:
- Modeling
* API changes for model transformations
* Revised API for SOSConstraint, Suffix and Block components
* Optimization results are now loaded into models
* Removed explicit specification of model preprocessing
- Solvers
* Resolved many issues with writing and solving MPECs
* Changes to MPEC meta-solver names
* The solution output for runph has been changed to
- Other
* Pyomo subcommands can now use configuration files (e.g. pyomo solve config.json)
* New JSON/YAML format for parameter data
* Added a script to install pyomo.extras
See http://pyomo.org for installation options and documentation for getting started with Pyomo.
Enjoy!
The Pyomo home page provides resources for Pyomo users:
Pyomo development is hosted by Sandia National Laboratories and COIN-OR:
See the Pyomo Forum for online discussions of Pyomo:
I created video with instructions for installing Pyomo on Windows. The video is too long, but might help if you are having trouble. The exact behavior of things depends on your browser and its configuration. Note that when I click on get-pip.py the programs comes into a browser tab rather than being downloaded to the Downloads directory so I simply save the file to the downloads directory. Maybe your browser will behave differently. Ultimately, the goal is to download get-pip.py and run it and then download get-pyomo.py and run it. The way I prefer to run them is from the command prompt. Here is the URL for the video: http://dlwoodruff.ucdavis.edu/PyomoWindows.mp4
This is only for trunk users of Pyomo on Ubuntu (and maybe Debian). If you don't know why you want trunk, then you probably don't want it and you can totally ignore this post.
Here is what I did to install pyomo trunk using python3.4 on Ubuntu 14.04; March 2015
Caveats:
0. If you want python2.7 don't use these steps.
1. There is no reason to think these would be anything like the steps on a mac
2. I am tired of working on this, so I have not done the experiments to find out which steps could be omitted or simplified
3. Obviously, if you have already installed numpy, etc. into 3.4 or you don't want numpy etc. you can skip those steps
4. There might be typos (I did not paste these in)
sudo rm -r /usr/bin/python
sudo ln -s /usr/bin/python3.4 /usr/bin/python
sudo apt-get install python3-numpy
sudo apt-get install python3-scipy
sudo apt-get install python3-matplotlib
sudo apt-get install python3-pip
==== (you can get xlrd later if you need it)
=== Edit pyomo_install to comment out two lines and add one line:
### install_pip(upgrade=options.zipfile is None, user=False, quiet=not options.verbose)
### pip = find_pip(pyomo_install_tempdir)
pip = "pip"
python pyomo_install –trunk --venv=pyomo
sudo rm -r /usr/bin/python
sudo ln -s /usr/bin/python2.7 /usr/bin/python
=== make sure your .bashrc file puts pyomo/bin very early in the path
=== open a new terminal
We are pleased to announce the release of Pyomo 4.0 (4.0.9682). Pyomo is a collection of Python software packages that supports a diverse set of optimization capabilities for formulating and analyzing optimization models.
This release patch release for Pyomo 4.0.9638. The following are highlights of this release:
- Modeling
* Added a ComplementarityList component
- Solvers
* PySP test baseline updates
- Other
* Bug fix for pickling results objects
* Performance fix for ordered sets
* Resolving a bug that disabled pyodbc support.
* Added preliminary support for pypyodbc.
* Fix to enable sets to be initialized with a tuple
* Re-enabled the 'import' and 'export' Pyomo data commands, which
are still deprecated.
* Various performance enhancements to avoid iterating over list of
dictionary keys.
See http://pyomo.org for installation options and documentation for getting started with Pyomo.
Enjoy!
- Pyomo Developer Team
- pyomo-developers@googlecode.com
- http://pyomo.org
-----------
About Pyomo
-----------
The Pyomo home page provides resources for Pyomo users:
* http://pyomo.org
Pyomo development is hosted by Sandia National Laboratories and COIN-OR:
* https://software.sandia.gov/pyomo
* https://projects.coin-or.org/Pyomo
See the Pyomo Forum for online discussions of Pyomo:
* http://groups.google.com/group/pyomo-forum/
Pyomo has been designed to provide high level scripting capabilities for users to quickly and easily write meta-algorithms using off the shelf solvers. Users writing these scripts often need to make decisions based on the status or the termination condition obtained from a solver. To this aim, Pyomo provides a standardized set of objects that can be used to query solver information regardless of the solver being used. The following code snippet provides a typical scenario where SolverStatus and TerminationCondition objects can be useful.
from pyomo.opt import SolverStatus, TerminationCondition … results = opt.solve(instance) # Solving a model instance instance.load(results) # Loading solution into results object if (results.solver.status == SolverStatus.ok) and (results.solver.termination_condition == TerminationCondition.optimal): # Do something when the solution in optimal and feasible elif (results.solver.termination_condition == TerminationCondition.infeasible): # Do something when model in infeasible else: # Something else is wrong print “Solver Status: ”, result.solver.status
The following table provides a complete list of all available solver statuses and termination conditions.
Solver Statuses | |
ok | Normal termination |
warning | Termination with unusual condition |
error | Terminated internally with error |
aborted | Terminated due to external conditions (e.g. interrupts) |
unknown | Unknown (an uninitialized value) |
maxTimeLimit | Exceeded maximum time limit allowed |
maxIterations | Exceeded maximum number of iterations allowed |
minFunctionValue | Found solution smaller than specified function value |
minStepLength | Step length is smaller than specified limit |
globallyOptimal | Found a globally optimal solution |
locallyOptimal | Found a locally optimal solution |
optimal | Found an optimal solution |
maxEvaluations | Exceeded maximum number of problem evaluations (e.g., branch and bound nodes) |
other | Other, uncategorized normal termination |
unbounded | Demonstrated that problem is unbounded |
infeasible | Demonstrated that problem is infeasible |
invalidProblem | The problem setup or characteristics are not valid for the solver |
solverFailure | Solver failed to terminate correctly |
internalSolverError | Internal solver error |
error | Other error |
userInterrupt | Interrupt signal generated by user |
resourceInterrupt | Interrupt signal in resources used by the solver |
licensingProblem | Problem accessing solver license |
I installed the most recent version of Anaconda 2.7 and then the trunk version of Pyomo. This results in an internal error in Pyro that is trapped by Pyomo and reported as an absence of Pyro. I don't know what the fix is because I just used my system Python to install trunk on the machine where I want to use Pyro. If you are not going to use Pyro, then you can just ignore this blog post :)
We are pleased to announce the release of Pyomo 4.0 (4.0.9629). Pyomo is a collection of Python software packages that supports a diverse set of optimization capabilities for formulating and analyzing optimization models.
This release rebrands Coopr as Pyomo, which reflects the fact that users have consistently confused the Coopr software and the Pyomo modeling language. Pyomo 4.0 includes the following significant changes:
The following are highlights of this release:
See http://pyomo.org for installation options and documentation for getting started with Pyomo.
Enjoy!
The Pyomo home page provides resources for Pyomo users:
Pyomo development is hosted by Sandia National Laboratories and COIN-OR:
See the Pyomo Forum for online discussions of Pyomo:
The Coopr software will soon be renamed as Pyomo! Coopr has been an umbrella software project that includes Pyomo and other software components. However, most users first and foremost use Coopr's Pyomo modeling package. Thus, many users describe their model as a "Pyomo model" even when it relies on advanced modeling extensions in Coopr. In fact, even Coopr developers often discuss "Pyomo" developments.
Given this confusion, we have decided to clearly brand this software as Pyomo. Later this fall, Pyomo 4.0 will be released. The source repository will be changed to reflect the name change. A new Pyomo home page will be hosted at http://pyomo.org, and the Pyomo Trac site will be reworked to more clearly be a site for Pyomo developers.
There will also be some new features in Pyomo 4.0. More details coming soon!
Community
Pyomo Forum
Report a Bug
Other
Citing Pyomo