Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Python Bindings to ADOL-C
Python C++ TeX Other
branch: master

README.rst

PYADOLC, a wrapper for ADOL-C

Short Description:
This PYADOLC, a Python module to differentiate complex algorithms written in Python. It wraps the functionality of the library ADOL-C (C++).
Author:
Sebastian F. Walter
Licence (new BSD):

Copyright (c) 2008, Sebastian F. Walter All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the HU Berlin nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY Sebastian F. Walter ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Sebastian F. Walter BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

EXAMPLE USAGE:

import numpy
from adolc import *
N = M = 10
A = numpy.zeros((M,N))
A[:] = [[ 1./N +(n==m) for n in range(N)] for m in range(M)]
def f(x):
    return numpy.dot(A,x)

# tape a function evaluation
ax = numpy.array([adouble(0) for n in range(N)])
trace_on(1)
independent(ax)
ay = f(ax)
dependent(ay)
trace_off()

x = numpy.array([n+1 for n in range(N)])

# compute jacobian of f at x
J = jacobian(1,x)

# compute gradient of f at x
if M==1:
    g = gradient(1,x)

THIS VERSION OF PYADOLC IS KNOWN TO WORK WITH:

  • Ubuntu Linux, Python 2.7.3, NumPy 1.8.0
  • OSX 10.9 (Mavericks), Python 2.7.6, NumPy 1.8.0
REQUIREMENTS:

INSTALLATION:

  • Use ./bootstrap.sh to download Boost, ADOL-C and ColPack and compile them.
  • Run python setup.py

TEST YOUR INSTALLATION:

  • run python -c "import adolc; adolc.test()". All tests should pass.
  • If anything goes wrong, please file a bug report.

MANUAL INSTALLATION:

Use the description below if the INSTALLATION procedure using ./bootstrap.sh does not work, or you want to use another ADOL-C version.

  • CHECK REQUIREMENTS: Make sure you have ADOL-C , ColPack the boost libraries and numpy installed. All with header files.

  • BUILD BOOST

    • run ./bootstrap in the boost_1_56_0 dir. This generates the files b2 and project-config.jam

    • modify project-config.jam. On my Linux system it looks like:

      # Boost.Build Configuration
      # Automatically generated by bootstrap.sh
      
      import option ;
      import feature ;
      
      # Compiler configuration. This definition will be used unless
      # you already have defined some toolsets in your user-config.jam
      # file.
      if ! gcc in [ feature.values <toolset> ]
      {
          using gcc ;
      }
      
      project : default-build <toolset>gcc ;
      
      # Python configuration
      using python : 2.7 : /usr ;
      
      path-constant ICU_PATH : /usr ;
      
      
      # List of --with-<library> and --without-<library>
      # options. If left empty, all libraries will be built.
      # Options specified on the command line completely
      # override this variable.
      libraries = --with-python ;
      
      # These settings are equivivalent to corresponding command-line
      # options.
      option.set prefix : /tmp/pyadolc/PACKAGES/boost_1_56_0/build ;
      option.set exec-prefix : /tmp/pyadolc/PACKAGES/boost_1_56_0/build ;
      option.set libdir : /tmp/pyadolc/PACKAGES/boost_1_56_0/build/lib ;
      option.set includedir : /tmp/pyadolc/PACKAGES/boost_1_56_0/build/include ;
      
      # Stop on first error
      option.set keep-going : false ;
      
  • BUILD COLPACK
    • if you have 32bit system: run ./configure --prefix=/path/to/adol-c/ThirdParty/ColPack/
    • if you have 64bit system: run ./configure --prefix=~/workspace/adol-c/ThirdParty/ColPack/ --libdir='${prefix}/lib64'
    • run make && make install
    • this should generate /path/to/adol-c/ThirdParty/ColPack/lib64/libColPack.so.
  • BUILD ADOL-C:
    • run ./configure --enable-sparse --with-colpack=/path/to/adol-c/ThirdParty/ColPack/
    • run make
    • You don't have to run make install.
    • You should then have a folder /path/to/adol-c/ADOL-C with adolc/adolc.h in it.
  • CLONE PYADOLC: git clone https://github.com/b45ch1/pyadolc.git You should then have a folder /path/to/pyadolc containing the file setup.py

  • BUILD PYADOLC:

    Go to the folder /path/to/adol-c/python and run scons. This should compile and link everything you need. If you want to install pyadolc in a different path than /path/to/adol-c/python, you have to set the following ENV variables export ADOLC_DIR=/path/to/adolc and export COLPACK_DIR=/path/to/colpack before running scons.

Something went wrong with that request. Please try again.