I am relatively new to the world of OR as my first foray into this field has me solving a MINLP. Unfortunately, my model is unable to solve because it is too complex, and so my supervisor has suggested that they could help me to code it up in MATLAB instead of PYOMO (I use PYOMO), and I am assuming that the reason for suggesting that is because they believe that coding it in MATLAB will speed up the convergence of the solver.

To my understanding, regardless of the platform used to code up the model (MATLAB, JuMP, PYOMO, GAMS, etc), it is the solver that is unable to handle the problem. Am I wrong to think that simply recoding the problem in a different modelling platform will not help to solve the problem, or is there some merit into changing the platform?


4 Answers 4


I did not want to answer here, but Alex challenged me :) I agree on all the benefits of using a modeling language (as Alex indicates) and totally on the importance of finding a "good" model (as Alex also indicates), but neither answers your question which, in my understanding, pertains to

regardless of the platform used to code up the model [...], it is the solver that is unable to handle the problem.

I would say: in most cases this is correct.

I have seen cases where the modeling language was (for memory/performance reasons) unable to generate large models while other modeling languages did not struggle. This is rare in my experience.

Otherwise, yes, regardless of the system, in simple terms, you write out an LP or MPS file, and feed it to a solver. When the two modeling languages you test use different default solvers, then the difference in performance comes from the different solvers, exactly as you say.

My very very very personal remark: I would never switch away from Python to ...


I agree with the answers by @Alex Fleischer and @Marco Lübbecke as essays in their own right, divorced from the question which was asked. However, neither of them directly address the question as asked, which is specifically about MINLP - Mixed-Integer Nonlinear Program, and not about LP or MILP.

MINLP solvers (not counting convex conic MINLP solvers) generally employ derivatives (gradient and maybe Hessian of Lagrangian, Jacobian and maybe Hessians of constraints). Solvers may have various derivative options (forward or central finite difference), "exact" (analytical or automatic differentiation). Different modeling systems may provide different derivatives to the solver - some only utilize whatever is provided by the user, and may default to finite difference if none are provided; whereas others, such as AMPL, automatically compute and provide automatic derivatives to the solver, and yet others, such as YALMIP, automatically provide first derivatives (gradient and Jacobian), but no 2nd derivatives, and no option to provide 2nd derivatives. The derivative options (leaving aside the possibility of coding errors) can have a large impact on (MI)NLP performance (for example, finite difference Quasi-Newton vs. Quasi-Newton vs. Newton for continuous relaxations). Note that some MINLP solvers, such as BARON, automatically compute derivatives internally, in which case modeling system derivative options are irrelevant to solver performance.

Also, modeling systems may differ in the type and amount, if any, of pre-solve performed by the modeling system prior to providing a problem to the solver. The pre-solve performed by the modeling system can have a large impact on MINLP solver performance, and may not be the same as the pre-solve which would have been performed by the solver.

Also, note that there may be different default starting (initial) values provided for the variables, depending on the modeling system (and its pre-solve). Generally, a user is allowed to provide starting values; but if not, the modeling system default can have a big impact (do you know how often the all zero vector is provided as default starting value, and there is either a model singularity there or non-local optimum stationary point?).

Default values of other solver algorithm and parameter choices may also differ by modeling system, and have a large impact on performance.


Short answer: yes it can make a huge difference. The degree to which it will make a difference depends on the combination of modelling software & solver.

There are 3 main things a modelling environment can do, other than represent & pass your math to a solver:

  1. Presolve
  2. Compute derivatives
  3. Reformulate

This will mostly affect users of non-linear technology because, historically, local NLP solvers don't do any of the above as they rely on callbacks. AFAIK there is no local NLP solver which does symbolic manipulation, so modelling software attempts to be clever and improve on what the NLP solvers can do.

Deterministic global optimisation solvers such as BARON, ANTIGONE, and Octeract Engine, are different in that we do symbolic manipulation internally, so we do all of the above regardless of how the user interacts with the solver.

One important exception here is if you are using CLP/CBC, as their presolve is not nearly as extensive as CPLEX/GUROBI's. In this case, a commercial modelling software such as AIMMS can improve performance due to its presolve.

Some examples that you might find interesting include:

  • AMPL has incredibly fast automatic differentiation code. People get papers accepted by claiming they managed to get within a factor of 5 of AMPL's speed.
  • AMPL will perform Singleton reduction, but not Doubleton reduction.
  • AIMMS will perform Doubleton reduction as well.
  • GAMS will reformulate your problem to have the objective function as a constraint.
  • PYOMO uses AMPL's automatic differentiation code, but does not presolve nor reformulate.

With respect to what you actually want to know, I strongly advise against using MATLAB if you can use PYOMO instead:

  • MATLAB is not open source, so anything you develop will need a MATLAB license for anyone to use. This includes you once/if you leave academia. One of my employees developed an entire MATLAB framework in his PhD, and words cannot describe how annoyed he is that he can not use it now that he's left academia.
  • MATLAB is much harder to interface with than Python is.
  • MATLAB's multiprocessing toolbox is very expensive, whereas Python's is free.
  • MATLAB will be slower than Python in most cases that can be relevant here, including symbolic manipulation. The speed difference between SymPy & MuPad is not even funny.
  • AFAIK MATLAB also doesn't use the ASL automatic differentiation code that PYOMO does, which means your problem will be much slower if you are using a local NLP/MINLP solver.
  • PYOMO is a modelling environment specifically designed for optimisation, whereas MATLAB is not. If, as you describe, you main problem is in getting your model right, then your chances of success are much higher if you use PYOMO because it's much closer to the logic you are trying to capture.

I am guessing that your supervisor is suggesting MATLAB because that's what they know so they can help you with the actual code. This means that you got lucky, as most supervisors will not do that for you, but in the grand scheme of things PYOMO does offer many advantages so you have an interesting decision to make.


I find this question quite interesting and wrote my most popular linkedin article about this:

Optimization (aka prescriptive analytics) : Should we write the model in a modeling language or a general programming language ?

I used to believe we should all write optimization models in efficient programming languages like C++ but that was 20 years ago. High level modeling languages like MATLAB or OPL offer many advantages:

In your case, the ability to share your model to get some help from a colleague or an expert. Not to mention, the flexibility you will get if you want to try new ideas.

The way you model a problem has a strong impact on performances so it's key to be able to try new ideas.

I tried to rewrite my bus and zoo example with many APIs to make this easy to see.

So to me you re wrong when you say: " Am I wrong to think that simply recoding the problem in a different modelling platform will not help to solve the problem, or is there some merit into changing the platform? "

This will help, as it helped many. You will need less human brain power to get to the same result.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.