3.8 Other Programming Languages

Most solvers also include libraries that can be called from any programming language. The most popular languages are C++, Java, C#, or C. The model formulation is then implemented as a program and the mathematical model structure disappears in the code. The advantage is, of course, the complete flexibility in implementing. If you are a C whiz, you would prefer to use C also to program models. Furthermore, a model may be a small part of a larger software project, then it might be beneficial to use a common language. Many reasons speak for such an approach. Once the code structure of calling the solver is implemented, it is easy to “reuse” it for other projects. On the other hand, most modeling system come along with libraries, so why not include them into the larger project of the chosen programming language? LPL, for instance, exports the whole functionality into a dynamic library callable by most programming languages.

In any case, many reasons guide the choice of a tool for modeling: specifications, habit, skills. In the following, a small linear model is exposed to illustrate the implementation details using Gurobi’s library in the programming language C.

   3.8.1 A small MIP model (mip1-c)