When coding an application involving a MIP, what are the best practices I should follow? In particular, I mean:

  1. Domain-specific language (GAMS, AMPL) or General purpose (Python, C#)?
  2. Structure of the code: should it just be one long list of adding variables, constraints and callbacks or how should it be organized?
  3. Are there like “example projects”, where I can see how it is done?
  • $\begingroup$ Are you referring to academic contexts or application in practice? $\endgroup$
    – CMichael
    Jun 5 '19 at 14:43
  • 4
    $\begingroup$ It's not clear to me exactly what you are asking. Do you mean formulating the MIP? coding the MIP in a modeling language? a solver API? coding the application that uses the MIP? It would be great if you can make your question a bit more specific. Thanks! $\endgroup$
    – LarrySnyder610
    Jun 5 '19 at 14:51
  • 1
    $\begingroup$ @LarrySnyder610 Good comment. That's much better than downvoting and voting to close, which in my opinion has been much too common a practice so far on this forum. $\endgroup$ Jun 5 '19 at 15:14
  • 2
    $\begingroup$ @LarrySnyder610 That’s fair, I’ll sit down and write a more concrete version of my question in the coming days. In essence I am asking: given a MIP, are there best practices to convert that into good code. I think there are some underlying rules that make a lot of sense in my experience, but I would like to hear from others what they have in mind. $\endgroup$
    – Richard
    Jun 5 '19 at 16:39
  • 1
    $\begingroup$ @Richard Sounds great. This will make a great question, in the end. If you want to close this question in the meantime, you can; otherwise, you can leave it up and folks can see the status from these comments. $\endgroup$
    – LarrySnyder610
    Jun 5 '19 at 16:50

Revised answer after OP's edit

If you are interested in a high-level framework on how to start the coding process from reading your initial inputs, how to best handle writing the optimization model, how to handle different solvers, and so on, then I suggest to check out this GitHub repository.

I put that together mainly for teaching purposes. It has an object-oriented design in Python with a simple optimization example to follow for different solvers (Cplex, Gurobi for commercial and PuLP as the open-source package) and I think it's a good starting point, especially for question #2.


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