# Tag Info

16

Pyomo is an algebraic modeling language and allows users to easily represent optimization problems at a high-level (by defining variables, constraints, objective, etc.). Pyomo then provides interfaces to a variety of optimization solvers including Gurobi and CPLEX. This allows an optimization model to be formulated once and then a user can experiment with ...

13

OR-Tools is a set of solver: A very popular Routing Library built on top of a traditional constraint programming solver An award winning CP-SAT solver that combines Constraint Programming techniques, SAT solver search and Boolean centric approach, MIP solver techniques like cuts and linear relaxation, and Large Neighborhood search A Simplex solver: GLOP A ...

12

I can't address the specifics of Python, Pyomo, Gurobi or GAMS, but I can address the general question of using a modeling language (such as GAMS) versus building the model directly in a general programming language (such as Python) via a solver API. Models written in a modeling language (say GAMS) tend to be easier to read and easier to relate to a problem ...

10

According to this link on Pyomo forum from 2016 about LP files, and this one from 2018 about MPS file, this functionality doesn't exist yet. To quote from the first link: LP files are “flat” representations of a model, and there really hasn’t been a strong motivation to import that into a structured system like Pyomo. It’s not impossible to write an LP ...

10

There is a new open source solver that looks quite promising, HiGHS: https://www.maths.ed.ac.uk/hall/HiGHS/ But as pointed out by others, for mixed-integer programming problems, at the moment, open-source solvers can't compete on performance and reliability with commercial solvers.

10

One problem you might encounter is that the many solvers are either not available for M1 like CPLEX[1] or at best experimental like Gurobi[2] so i doubt there will be any guarantees for correctness. Apple support for Gurobi might be mixed in general due to issue like "Only use single-threaded BLAS on Mac to avoid overshooting the thread limit" [3] ...

9

I think it is a good idea to have a look at this question on StackOverflow. In addition to that, in the Pyomo manual, it is stated that: "Pyomo supports a wide variety of solvers. Pyomo has specialized interfaces to some solvers (for example, BARON, CBC, CPLEX, and Gurobi). It also has generic interfaces that support calling any solver that can read AMPL “....

8

If the IPOPT termination condition is Optimal Solution Found then the returned solution is locally optimal. IPOPT is, by design, not a global solver and therefore does not have any built-in infrastructure for checking if a solution is global vs. local. However, if you know certain features of your problem, like if it is convex, then you as the user might be ...

8

In a production environment, I have found code APIs to be superior to modelling languages in the long run. Nowadays, we also have Pyomo so we don't even need to compromise between the two. The subtlety is that if you use a solver's Python API your code is tied to that solver. Conversely, if you use a modelling environment (e.g. GAMS), you can seamlessly ...

7

There is a difference between an initial condition and initial values. Initial conditions in the context of differential equations fix the values of dynamic variables at the initial point. When you provide initial values for your variables you are essentially providing a guess of where you think the optimal point is. The optimizer is still free to move the ...

7

complex Pyomo MINLP to NEOS using Couenne. So, I had to Google a bit to understand this part as I am not familiar with the package nor the NEOS service. It would be beneficial as to where in the run-time progress you get the error message and what it exactly states. From the NEOS webpage I found the following limitations Retrieving results If you ...

6

Different solvers have their own interfaces (for example Cplex studio by IBM). You can use the specific syntax for those IDE or interfaces to input your model and then use the solver to solve it. Although the logic behind them all is the same but those languages or syntaxes are usually differing from one solver to the other. If you need to solve your problem ...

6

APOPT is another NLP (and MINLP) solver that works with Pyomo by reading .nl files and producing .sol files. The solver is apopt.py and called with Python to send the .nl file to a compute server and then return the .sol file back to Python and returned to Pyomo. Here is the source code on GitHub with instructions on use. Please note that we are still ...

6

There is a systematic way of finding the infeasibility of your problem. You would like to find the Irreducibly Inconsistent System (IIS) of your model. This technology is available in CPLEX and Gurobi for MIP and in BARON for MINLP. Since you have implemented your model in Pyomo (in case you do not have a BARON license), you can submit the problem to the ...

6

Hold the phone... You can keep this linear. Just sum the selection variables and multiply by the min average requirement. No division required. import pyomo.environ as pyo v = {'hammer': 1, 'wrench': 3, 'screwdriver': 1, 'towel': 2} w = {'hammer': 5, 'wrench': 7, 'screwdriver': 4, 'towel': 3} limit = 14 M = pyo.ConcreteModel() M.ITEMS = pyo.Set(...

6

The Mittlemann benchmarks are an excellent benchmark as ever in particular these two: Benchmark of Barrier LP solvers Large Network-LP Benchmark (commercial vs free) Note that Pyomo doesn't have bindings for most of these locally. If you are just looking for high-level modeling language and are not tied to Python you could use the JuMP modeling language ...

6

A variable that can assume values of zero or between some lower and upper bound is called a semi-continuous variable. Most high-end solvers have direct support for this type of variable. If not supported, you can model this with an additional binary variable: \begin{align} & \color{darkblue}L\cdot \color{darkred}\delta \le \color{darkred}x \le \color{...

5

You just need to sum over another index variable than $t$. Here is the correct code: from __future__ import division from pyomo.environ import * from pyomo import environ as pym model = ConcreteModel() Imax = 1 Jmax = 1 Tmax = 3 model.Iset = RangeSet(1, Imax) model.Jset = RangeSet(1, Jmax) model.Tset = RangeSet(0, Tmax) model.Tset2 = RangeSet(1, Tmax) ...

5

v represent each of your variables. I assume that your model is called 'model': from pyomo.environ import * import pandas as pd # add the following to your python script DF = pd.DataFrame() for v in model.component_objects(Var,active=True): for index in v: DF.at[index, v.name] = value(v[index]) This part of the code directly ...

5

You can try adding a constraint forcing one of the affected variable to be nonzero. If the model becomes infeasible, you can try to find the conflicting constraints. If the model stays feasible, this means that your objective function represents other priorities than you expected.

5

This post is of my interest. I also required a global solver for my problem. I found out that Pyomo has python interface for an opensource global solver called SCIP for nonlinear optimization problems. You might want to check that out. The process of getting SCIP installed and ready to work on Pyomo is slightly non-trivial and might take some (for which I ...

5

It sounds like the APOPT executable is not in your system's PATH. From your description, I suspect that the solver's name should be --solver=apopt.py instead of --solver=apopt.

5

As mentioned in the comments, CPLEX cannot handle MINLP problems which are not Mixed-Integer Second-order cones (MISOCP) and Mixed-integer quadratic or quadratically constrained programs (MIQP and MIQCP). Given that you have a general nonlinear constraint, you cannot write it in a matrix was, meaning that you cannot express the exponential constraint \$g(x)=\...

5

You can do this with PuLP. A column wise formulation for the cutting stock problem is given in the examples. So you don't have much to do... However, it would be interesting to see how PuLp compares with Pyomo.

5

SCIP used to be a bit challenging to set up with PYOMO as we needed to build the ASL interface. It's been a few years so I don't know if that's changed, but you can find a relevant discussion here. What might be easier would be to use Couenne, which is a deterministic global optimisation solver for MINLP and works out of the box with PYOMO. If you are a ...

5

You can use SCIP with PYOMO easily. My way is: At first, use an executable SCIP version, it is available for the 7.0 version. After then giving the path of the executable to PYOMO, such as: solver = SolverFactory('scip', executable="./scip") It works. But I use BONMIN in same way.

5

You are just importing the pyomo.environ module while the tutorials probably use the from syntax. These variables are inside pyomo.environ so you have 3 alternatives: Import them explicitly from pyomo.environ import Var, NonNegativeReals Import them using a wildcard from pyomo.environ import * (this is considered an antipattern) Import the module (with an ...

4

I found it hard, using Pyomo, to get that kind of information since Pyomo's results object has a different structure depending on the solver that has been used. To get around that, I consider that the ugly solution is still the most reliable one up to now, until someone shows me a better way. Convert the results object that was returned by the solve() ...

4

The syntax that you are using in your Pyomo code is correct and you should be able to access the GAMS solvers once Pyomo is able to find GAMS. As the error mentions, the GAMS command is not found in the system PATH. I would double check if the GAMS path is correctly added to the system PATH. A way of doing so is opening a command prompt (since you are using ...

4

Pyomo has an ASL interface, hence any solver that is equipped with one will work out of the box. Commercial options that have free variable limited demos would be KNITRO, BARON, or Octeract Engine, and open source options include Couenne, or MINOTAUR. For some of the commercial solvers you might need to request a special version from the vendor that comes ...

Only top voted, non community-wiki answers of a minimum length are eligible