Getting started

Knitro can take its input from many different calling programs and programming languages, with various levels of abstraction. There are essentially three ways to interact with Knitro (in addition, a specific interface for Microsoft Excel is available):

  • via a modeling language like AMPL, AIMMS, GAMS, or MPL;
  • via a numerical computing environment like R or MATLAB;
  • via a programming language such as C, C++, Java, C#, Python or Fortran.

The first two methods are usually simpler, and the first has the advantage of providing derivatives “for free” since modeling languages compute derivatives behind the scene (see Section Derivatives). Calling from a programming language adds some complexity but offers a very fine control over the solver’s behaviour.

This section provides a hands-on example for each method, using AMPL, MATLAB, R, and C++, the latter with both the callable library and with the object-oriented interface.

Note

Knitro’s behaviour can be controlled by user parameters. Depending on the interface used, user parameters will be defined by their text name such as alg (this would be the case in AMPL) or by programming language identifiers such as KN_PARAM_ALG (that would be the case in C/C++).