Luigi Poderico


Software and Operational Research


Optimization Template interface


This page describe a proposal for a c++ template based abstraction interface for mathematical optimization software.

The major problem for an optimization software writer is to switch from a solver to another. This because every solver has got its own interface. The most famous project facing this problem is OSI, that uses abstract classes and virtual functions to build and to implement the general interface and the several implementations.

My proposal is to use template and the basic concepts of template meta programming. This allows solver abstraction with no run-time costs. I've reused many concepts and ideas from STL and boost.

Using the most common subdivision, oti library provides environment and problem classes. Each class is a template on an integer representing the solver to implement. Currently three solvers are provided as example: cplex, osl and mosek. Just the mosek implementation is used and tested in real applications.

From a practical point of view, the user:

  1. selects which solver to use;

  2. using the type generator asks to OTI to generate the right types for an environment and a problem;

  3. uses them with the common interface.

Documentation and source code

A very short document describing the OTI library is available here.

The complete source code is available here.


Please send any comments at