CONOPT
Loading...
Searching...
No Matches
Tutorial

CONOPT is a general-purpose nonlinear programming system. It is available in several different forms: as a Dynamic Link Library (DLL) or Shared Library and as an optional or build-in solution algorithm in some modeling systems such as AIMMS, AMPL, GAMS, LINGO and MPL.

This tutorial will work through a small example show how to implement a model using the CONOPT DLL. We recommend in general that CONOPT be called from a modeling system such as those mentioned above. It is easier and more reliable to formulate and update models in these environments. However, it will be advantageous to use the DLL or shared library version of CONOPT in certain cases. For example when the nonlinear relationships already exist in the form of Fortran or C routines and the relationships are difficult to translate into the format used by a modeling system. Note, however, that CONOPT requires accurate derivatives. If they are not readily available then you should consider rewriting the model using a modeling system. We must strongly discourage computing derivatives by finite differences.

We will describe the implementation of a simple production optimization model. The description will be limited to the topics most needed. For more information, please review the documentation under Introduction and the Public API.

A model is defined to CONOPT through a control vector and set of user-written callback routines. The control vector holds the number of constraints and variables and other model statistics. It is filled with a set of defining routines in the CONOPT DLL. The first callback routine declares the constraints as equalities or inequalities, defines which variables appear in which constraints and whether the relationship is linear or nonlinear, and it defines bounds on the variables, initial values, etc. Coefficients in linear relationships are also defined. The second callback routines define the nonlinear relationships of the model by returning numerical values. Additional callback routines are used to communicate messages, the status of the solution, and the solution itself back to the modeler. Other callback routines can be added for special purposes. We will refer to a few of these. Details are available in the Reference Manual.

The tutorial will show how the control vector is allocated and filled, and it will show the content of the callback routines for a particular production optimization model. Problem description shows the mathematical formulation of the model, Constraint Reorganizations and Jacobian Structure describe certain reformulations that are necessary to bring the model into the format required by CONOPT. Callback Routines will then discuss the callback routines for the model, and Running CONOPT will discuss the corresponding output produced by CONOPT. Second Derivative discusses the use of second derivatives for our example model and it discusses how certain model reformulations can help simplify the computations of first and second derivatives. Other Examples gives a short overview over some other models that are distributed with CONOPT.

The tutorial that this is based on is available is both Fortran (tutorial.f90) and C (tutorial.c). Throughout we will describe the features for both Fortran and C. There are a couple of things to note.

  • All function calls will be described with respect to the Fortran interface. The equivalent function calls for the C interface will be given in parentheses.
  • Array indexing in Fortran starts from 1. We will use this convention throughout. If using C, please take this into account.
  • In the C interface, all arguments to CONOPT calls are passed by reference. As such, when using C you should define local (or global) variables with the matrix and vector sizes, initialise these variables and pass their address to CONOPT. In the case of Fortran, all variables a passed by reference.

This tutorial is divided into the following sections: