GCOP  1.0
cost.h
Go to the documentation of this file.
00001 #ifndef GCOP_COST_H
00002 #define GCOP_COST_H
00003 
00004 #include <Eigen/Dense>
00005 #include <iostream>
00006 #include "system.h"
00007 
00008 namespace gcop {
00009 
00010   using namespace Eigen;
00011   using namespace std;
00012   
00024   template <typename T, 
00025     int _nx = Dynamic, 
00026     int _nu = Dynamic,
00027     int _np = Dynamic,
00028     typename Tc = T> class Cost {
00029   public:
00030   
00031   typedef Matrix<double, _nx, 1> Vectornd;
00032   typedef Matrix<double, _nu, 1> Vectorcd;
00033   typedef Matrix<double, _np, 1> Vectormd;
00034 
00035   typedef Matrix<double, _nx, _nx> Matrixnd;
00036   typedef Matrix<double, _nx, _nu> Matrixncd;
00037   typedef Matrix<double, _nu, _nx> Matrixcnd;
00038   typedef Matrix<double, _nu, _nu> Matrixcd;
00039   
00040   //  typedef Matrix<double, Dynamic, 1> Vectormd;
00041   typedef Matrix<double, _np, _np> Matrixmd;
00042   typedef Matrix<double, _nx, _np> Matrixnmd;
00043   typedef Matrix<double, _np, _nx> Matrixmnd;
00044   
00050   Cost(System<T, _nx, _nu, _np> &sys, double tf);
00051 
00057   //Cost(System<T, _nx, _nu, _np> &sys, Sensor<double tf);
00058   
00071   virtual double L(double t, const T &x, const Vectorcd &u, double h,
00072                    const Vectormd *p = 0,
00073                    Vectornd *Lx = 0, Matrixnd* Lxx = 0,
00074                    Vectorcd *Lu = 0, Matrixcd* Luu = 0,
00075                    Matrixncd *Lxu = 0,
00076                    Vectormd *Lp = 0, Matrixmd *Lpp = 0,
00077                    Matrixmnd *Lpx = 0);  
00078 
00084   virtual bool SetContext(const Tc &c) { return true; };
00085   
00086   System<T, _nx, _nu, _np> &sys;  
00087   double tf;                      
00088   
00089 };
00090 
00091 
00092   template <typename T, int _nx, int _nu, int _np, typename Tc> 
00093     Cost<T, _nx, _nu, _np, Tc>::Cost(System<T, _nx, _nu, _np> &sys, 
00094                                      double tf) : sys(sys), tf(tf) {
00095   }
00096   
00097   template <typename T, int _nx, int _nu, int _np, typename Tc> 
00098     double Cost<T, _nx, _nu, _np, Tc>::L(double t, const T& x, const Vectorcd& u, double h,
00099                                          const Vectormd *p,
00100                                          Matrix<double, _nx, 1> *Lx, Matrix<double, _nx, _nx>* Lxx,
00101                                          Matrix<double, _nu, 1> *Lu, Matrix<double, _nu, _nu>* Luu,
00102                                          Matrix<double, _nx, _nu> *Lxu,
00103                                          Vectormd *Lp, Matrixmd *Lpp,
00104                                          Matrixmnd *Lpx) {
00105     cout << "[W] Cost:L: unimplemented!" << endl;
00106     return 0;
00107   }
00108 }
00109 
00110 #endif