Algorithmic Optimal Control - CO2 Uptake of the Ocean

ADIMat

ADiMat - Sourcetransformationtool for Matlab

Homepage at the RWTH Aachen

To use the current version you have to install the Windows or Linux tool (see homepage).

Theres an old version installed on the sun system at the Department of Computer Science under

  • /home/ts/pub/AD/adimat-0.4-r9 (Solaris Sun-Sparc-Architektur, z.B. auf Rechner sauron)

Documentation.

The following tutorial refers to that old version:

Preparation, set shell variables: 

  • set shell-Variable ADIMAT_HOME to directory adimat-0.4 :
    • (in homedirectory) enter the following line into the file .bashrc :
      • export ADIMAT_HOME=/home/ts/pub/AD/adimat-0.4-r9
      • somewhere in .bashrc there's a line  
        • export PATH= ...
      • enter the following line behind that line:
        • export PATH=$PATH:$ADIMAT_HOME/bin 
  • open new terminal or enter source .bashrc into the current terminal (to activate the changes)
  • Done!
 

Differentiate: There are two possibilities:

  • Apply ADiMat directly onto a function y=f(x) in file f.m:
    • In shell:
      • adimat -i x -d y f.m
  • Write a Matlab-Skriptfile that calls the function you want to differentiate (e.g. driver.m, not just a function!), for example: x=[0,1]; y=f(x);
    • Enter directives with names of  independent variables, dependent variables and the function yo want to differentiate into this file:
      • %ADiMat AD_IVARS = x
      • %ADiMat AD_DVARS = y
      • %ADiMat AD_TOP = f
    • Call in shell:
      • adimat driver.m

In both cases a function [g_y,y] = g_f(g_x,x) will be generated in file g_f.m .

Call/Embedding of the differentiated code:

  • Copy the file ADiMat_startup.m from $ADIMAT_HOME/share/adimat/opt_derivclass into the directory from which Matlab is called.
  • Call Skript ADiMat_startup (see above.) in Matlab, or write the following line into startup.m  (to automatically call it when starting Matlab):
    • ADiMat_startup
  • Generate and initialize Seed Matrix g_x :
    • g_x=createZeroGradients(n,x);
    • n is the number of directional or partial derivatives to be calculated, you thus need n= length(x) for a full Jacobian matrix
    • Set individual components of g_x:
      • n=1: i-th partial derivative: g_x{1}(i)=1;
      • n=1: directional derivative in direction of d: g_x{1}=d;
      • n=length(x): full Jacobian matrix: for i=1:n, g_x{i}(i)=1; end
  • After calling g_f the derivative can be found in in g_y