Changeset 1130 for library/tests

Show
Ignore:
Timestamp:
07/09/10 12:39:41 (14 years ago)
Author:
smidl
Message:

Basic outline of universal LQG controller

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/tests/testsuite/LQG_test.cpp

    r1064 r1130  
    11#define BDMLIB 
    22#include "../mat_checks.h" 
    3 #include "design/ctrlbase.h" 
     3#include "design/lq_ctrl.h" 
    44 
    55using namespace bdm; 
     
    9191    cout << L.to_string() << endl; 
    9292} 
     93 
     94TEST (quadratic_test){ 
     95  quadraticfn qf; 
     96  qf.Q = chmat(2); 
     97  qf.Q._Ch() = mat("1 -1 0; 0 0 0; 0 0 0"); 
     98  CHECK_CLOSE_EX(qf.eval(vec("1 2")), vec_1(1.0), 0.0000000000000001); 
     99   
     100  LQG_universal lq; 
     101  lq.Losses = Array<quadraticfn>(1); 
     102  lq.Losses(0) = quadraticfn(); 
     103  lq.Losses(0).Q._Ch() = mat("1 -1 0; 0 0 0; 0 0 0"); 
     104  lq.Losses(0).rv = RV("{u up }"); 
     105   
     106  lq.Models = Array<linfn>(1); 
     107  lq.Models(0) = linfn(mat("1"),vec("1")); 
     108  lq.Models(0).rv = RV("{x }"); 
     109   
     110  lq.rv = RV("u",1); 
     111   
     112  lq.redesign(); 
     113  CHECK_CLOSE_EX(lq.ctrlaction(vec("1,0")), vec("1.24, -5.6"), 0.0000001); 
     114}