Are there any rules of thumb for figuring out when you need to use a solver like Gurobi or CPLEX, and when you can just solve you problems directly with a Python, R, or Matlab package?

Is it just a question of the size of the problem, or are there other considerations?

  • $\begingroup$ Could you give examples for the Python, R or Matlab packages that you would consider alternatives to solvers? $\endgroup$ – Robert Schwarz Sep 20 '19 at 7:40
  • $\begingroup$ As @EhsanK pointed out in his answer below, it seems you are asking specifically about open-source vs. commercial solvers. If that's the case, would you mind editing your question to make that explicit? $\endgroup$ – LarrySnyder610 Sep 20 '19 at 12:39

I assume the solver you're referring to in Python/R/Matlab, are the open-source solvers such as CBC or GLPK (you can find out more in this question: Where can I find open source LP solvers?). If that's the case then you should consider:

  • The size of the problem
  • Solution time: which can be very different between open-source and commercial solvers
  • How much flexibility you need or what type of problems you are solving? For example, do you need to solve a quadratic problem? How about fine-tuning capabilities, callback functionality, using solution pools, usage of the software on the cloud, and a lot more which are much better in commercial solvers (if they even exist in open-source solvers)
  • How much money you can spend!
  • If you need any support or maintenance. This can be a concern when:
    • You are solving problems for companies that require someone to answer any question that arises with the performance or even modeling itself
    • The problem is important and almost no risk can be taken! (e.g. when there is a concern about the performance or accuracy of an open-source solver). In a commercial solver (since you are paying), you can assume the solvers don't have any bug and if they do, you can reach out to their support system and resolve it (hopefully quickly). But that cannot necessarily be the case using an open-source solver.
| improve this answer | |

The main reasons are performance and quality of numerics. Non-professional stuff tend to lack the polish professionals spend time doing to ensure that numerical issues don't compromise the solving procedure.

Performance-wise, a good rule of thumb is problem density: if a problem is large but really sparse, open source solvers can perform really well. If a problem is dense however, we need a professional-grade implementation. The main reason is the development time invested when it comes to the scalability of the data structures and algorithms in a solver, as well as uncommon/edge use cases.

As an anecdotal real-world example, our engine calculates some of the fastest derivatives in the world, but one day we discovered that our differentiation algorithm stopped scaling well after 70,000 or so non-zero hessian elements (so it was really slow beyond that). The reason was fundamentally linked to how we were getting such speed for less dense problems, so it took my team three weeks to come up with a high performance alternative, which now triggers automatically after a certain density. Interestingly, our alternative algorithm is really slow for sparse problems, which is why we never considered it before. Taking the time to do these kinds of tricks is really common in commercial products, because our selling point is that the solver will work well even on edge cases, but not as much in most free software where the focus is (for good reason) on the average use case.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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