This is about pyomo and specifically the glpk solver, is there anyway to set the max iteration for glpk in pyomo? - pyomo

For example I found a solution in matlab which is “options.glpk.itlim" - is there something similar to this ?

Related

Changing IPOPT options with pyomo doesn't work

I am using IPOPT solver for solving KKTs conditions (a bunch of equality constraints and complementarity conditions).
For assigning the solver for the complementarity problem, I use the command line below:
solver = po.SolverFactory('mpec_nlp')
And then according to IPOPT documentation I am changing the number of maximum iteration
solver.options['max_iter']=1000
But solver doesn't listen to me and still stops at its default maximum of 3000 iterations
Do you have any suggestions on how to make it work?
Consider creating ipopt.opt file using notepad. Write max_iter 500 into the file. Place the file into your working directory (where your code is running)

Accessing Pyomo user time with Neos

I teach an optimization course in which I use the Pyomo modeling language to solve problems. I also encourage students to compare solvers using Neos. However, I have not found a way to measure the computational time required to solve the problems.
To explain my point I have created this notebook in Colab (https://github.com/salvapineda/notebooks/blob/main/UserTimePyomoNeos.ipynb)
First, I solve a model using cbc without using NEOS. As you can see, the "Solver Information" includes the time required to solve the problem.
Then, I solve the same model using cbc through NEOS. However, the "Solver Information" does not include any time information.
Is there any way to access the computational time when I am solving Pyomo models in Neos?
Do you mean the breakdown of the computation time? The model in Colab on NEOS returns 0.00389 seconds.
Message: CBC 2.10.3 optimal, objective 3.49; 0 nodes, 2 iterations, 0.00389 seconds

Initializing IPOPT when using pyomo parmest

I am learning to use pyomo parmest. I am trying to recreate the following parameter estimation example. The code that I created is in the following jupyter notebook. IPOPT stops with the message of maximum iterations exceeded when using collocation but solves with finite difference discretization. Since it is suggested that collocation is typically more robust, I would like to know what I might be doing wrong in using the collocation discretization.
I had originally used number of collocation points in discretization ncp = 4. When I changed ncp = 2, IPOPT ran without issues. The updated ipython notebook is in this location.

How I can convert ampl file to cplex?

I wrote a model in Ampl and I wanted to solve it by glpk. But I noticed that I need some cplex's operation such that ==>, and glpk does not have it. I am wondering is there an easy way to convert Ampl file to cplex? or it is a difficult process and I have to rewrite every thing in Cplex format!
(I did not buy ampl so I can not use cplex in ampl)
If you do not have the AMPL software, then you cannot run AMPL files and convert them automatically to any form.
The GLPK package does have its own modeling language, GNU Mathprog, which implements a linear subset of AMPL. Thus sometimes it is not so hard to translate an AMPL model to a GNU Mathprog model. Then GLPK can process the GNU Mathprog model and produce an MPS or LP file that can be read by a solver.
GNU Mathprog does not have the ==> ("implies") operator found in AMPL, however, so any AMPL constraints using that operator will have to be translated into linear constraints. There are well-known ways to make such a translation. If you need help with doing it, then that should be posted as a separate question. (You will have the best chance of getting an answer if you show the complete AMPL constraint that you are trying to translate.)

specifying tolerance for GLPK solver in PuLP Python

I am running PuLP Programming Library in Python 2.7.8, Windows 32 bit. I'm using GLPK as my solver for a mixed integer linear programming problem. The solver converges to approx. 1% of the optimal quickly, however time to compute the exact optimal solution is high. Is there a way to specify percent tolerance for GLPK solver using PuLP? I searched https://pythonhosted.org/PuLP/solvers.html but it doesn't give any answer for GLPK solver.
If you run "glpsol" on the command line with "--help" you see the "--mipgap tol", where tol is the tolerance.
So, in PuLP, have you tried this:
model.solve(GLPK(options=['--mipgap', '0.01']))
(from this discussion a while ago) (and notice how you can use this same method to pass in more arguments that you please).
Furthermore, I went into the source code ("solvers.py") and took a look at how GLPK expects its "options" arguments, and indeed it expects the arguments as above (look at line 345 or so in the file reproduced below):
proc = ["glpsol", "--cpxlp", tmpLp, "-o", tmpSol]
if not self.mip: proc.append('--nomip')
proc.extend(self.options)
So you see that "proc" (the command which is run using Python's "subprocess" later) is "extended" with what you specify via "options" (incidentally stored in the variable self.options). So, it looks like the approach above (using '--mipgap' etc. in a list) is (still) correct.
Finally, I have not tried that myself, but I hope this helps.