Robot Simulator of the Robotics Group for Self-Organization of Control: lyapunov.h Source File

# lyapunov.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
    00003  *    Georg Martius  <georg dot martius at web dot de>                     *
    00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
    00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
    00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
    00007  *                                                                         *
    00008  *   This program is free software; you can redistribute it and/or modify  *
    00009  *   it under the terms of the GNU General Public License as published by  *
    00010  *   the Free Software Foundation; either version 2 of the License, or     *
    00011  *   (at your option) any later version.                                   *
    00012  *                                                                         *
    00013  *   This program is distributed in the hope that it will be useful,       *
    00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
    00016  *   GNU General Public License for more details.                          *
    00017  *                                                                         *
    00018  *   You should have received a copy of the GNU General Public License     *
    00019  *   along with this program; if not, write to the                         *
    00020  *   Free Software Foundation, Inc.,                                       *
    00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
    00022  *                                                                         *
    00023  ***************************************************************************/
    00024 #ifndef __LYAPUNOV_H
    00025 #define __LYAPUNOV_H
    00026
    00027 #include "matrix.h"
    00028 #include "stl_map.h"
    00029
    00030 /**
    00031  *  Class for calculating lyapunov exponents
    00032  *   online, over several time horizons, from given Jacobi matrices
    00033 */
    00034 class Lyapunov {
    00035 public:
    00036   /// holds a matrix that is the result of a sliding window multiplication
    00037   struct SlidingMatrix {
    00038     /** @param dim dimension of the system (matrix is (dim x dim))
    00039         @param horizon for sliding window
    00040      */
    00041     SlidingMatrix(int dim, int horizon);
    00042     void step(int t, const matrix::Matrix* buffer,
    00043               const matrix::Matrix* invbuffer, int buffersize);
    00044     /** nominal size of sliding window
    00045         (if <=0 then infinite and absolute value stands for the size so far) */
    00046     int horizon;
    00047     matrix::Matrix M;   ///<  accumulated Matrix
    00048     matrix::Matrix Exp; ///< Lyapunov exponents
    00049   };
    00050
    00051   typedef HashMap< int, SlidingMatrix* > Horizons;
    00052
    00053 public:
    00054   Lyapunov();
    00055   ~Lyapunov();
    00056
    00057   /** initializes with a set of horizons.
    00058       @param horizons for each horizon # in steps. 0 means infinite
    00059       @param dim # of dimensions (expect a (dim x dim) matrix in step)
    00060    */
    00061   void init(const std::list<int>& horizons, int dim);
    00062
    00063   /** provides the current Jacobi matrix.
    00064       Internally the sliding windows and the exponents are generated
    00065    */
    00066   void step(const matrix::Matrix& jacobi);
    00067
    00068   /** returns the lyapunov matrix at the given horizon
    00069    */
    00070   const matrix::Matrix& getLyapunovMatrix(int horizon);
    00071
    00072   /** returns the lyapunov exponents at the given horizon
    00073    */
    00074   const matrix::Matrix& getLyapunovExp(int horizon);
    00075
    00076 protected:
    00077   matrix::Matrix* buffer;
    00078   matrix::Matrix* invbuffer; // buffer for inverses
    00079   int buffersize;
    00080   long int t;
    00081
    00082   Horizons horizons;
    00083 };
    00084
    00085
    00086 #endif
    00087