CONOPT
Loading...
Searching...
No Matches
Automatic differentiation examples

Topics

 C++ examples using automatic differentiation
 Examples written in C++ using the ADOL-C package for automatic differentiation.
 
 Python examples using automatic differentiation
 Examples written in Python using the ADOL-C package for automatic differentiation.
 

Detailed Description

Examples written in C++ and Python that make use of the automatic differentiation package ADOL-C.

Examples have been prepared in C++ and Python that demonstrate the use of the automatic differentiation package ADOL-C. While the examples use ADOL-C, it is possible to use other automatic differentiation packages with CONOPT. However, only the details on how to build CONOPT with ADOL-C will be provided here.

Building and installing ADOL-C

Before building the automatic differentiation examples, the first step is to download, build and install ADOL-C. The source code is available from the repository hosted on Github, which is found at https://github.com/coin-or/ADOL-C. We recommend checking out the tagged version releases/2.7.2, since this has been used when testing the provided examples. After checking out releases/2.7.2, ADOL-C can be built as follows:

  1. The Python packages swig, numpy and setuptools are required for building the Python interface for ADOL-C.
    • Note that the SWIG-generated interface is part of releases/2.7.2, but will not continue with later releases. The examples will be updated with the latest release of ADOL-C.
  2. It is recommended that you create a Python virtual environment or Conda environment. If so, then you must activate this environment before completing the next steps of the build process.
  3. Finally, for running the Python examples, it is necessary to apply the patch adol-c-swig.patch that is available in the examples/AD/Python_1thread directory. This is achieved by executing the following command in the base directory of ADOL-C:
    git apply <path-to-conopt>/examples/AD/Python_1thread/adol-c-swig.patch
  4. Execute autoreconf -fi.
  5. Execute the command ./configure. If you are building the Python interface, it is necessary to include the option --enable-sparse. Also, if you wish to have an alternative install directory, this can be set by using passing the option --prefix=<install-dir> to the ./configure command.
  6. Execute make, then make install.
    • After the make command, you will be provided with some information about how to link against the installed ADOL-C directories.

If building ADOL-C on Windows, there is some more information available at https://github.com/coin-or/ADOL-C/blob/releases/2.7.2/INSTALL