root/library/doc/html/ctrlbase_8h-source.html @ 538

Revision 538, 18.4 kB (checked in by smidl, 15 years ago)

Documentation regenerated

Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3<title>mixpp: ctrlbase.h Source File</title>
4<link href="tabs.css" rel="stylesheet" type="text/css">
5<link href="doxygen.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.5.8 -->
8<script type="text/javascript">
9<!--
10function changeDisplayState (e){
11  var num=this.id.replace(/[^[0-9]/g,'');
12  var button=this.firstChild;
13  var sectionDiv=document.getElementById('dynsection'+num);
14  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
15    sectionDiv.style.display='block';
16    button.src='open.gif';
17  }else{
18    sectionDiv.style.display='none';
19    button.src='closed.gif';
20  }
21}
22function initDynSections(){
23  var divs=document.getElementsByTagName('div');
24  var sectionCounter=1;
25  for(var i=0;i<divs.length-1;i++){
26    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
27      var header=divs[i];
28      var section=divs[i+1];
29      var button=header.firstChild;
30      if (button!='IMG'){
31        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
32        button=document.createElement('img');
33        divs[i].insertBefore(button,divs[i].firstChild);
34      }
35      header.style.cursor='pointer';
36      header.onclick=changeDisplayState;
37      header.id='dynheader'+sectionCounter;
38      button.src='closed.gif';
39      section.id='dynsection'+sectionCounter;
40      section.style.display='none';
41      section.style.marginLeft='14px';
42      sectionCounter++;
43    }
44  }
45}
46window.onload = initDynSections;
47-->
48</script>
49<div class="navigation" id="top">
50  <div class="tabs">
51    <ul>
52      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
53      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
54      <li><a href="annotated.html"><span>Classes</span></a></li>
55      <li class="current"><a href="files.html"><span>Files</span></a></li>
56    </ul>
57  </div>
58  <div class="tabs">
59    <ul>
60      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
61      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
62    </ul>
63  </div>
64<h1>ctrlbase.h</h1><a href="ctrlbase_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
65<a name="l00013"></a>00013 <span class="preprocessor">#include "../base/bdmbase.h"</span>
66<a name="l00014"></a>00014
67<a name="l00015"></a>00015 <span class="keyword">namespace </span>bdm{
68<a name="l00016"></a>00016
69<a name="l00018"></a><a class="code" href="classbdm_1_1Designer.html">00018</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1Designer.html" title="Base class of designers of control strategy.">Designer</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> {
70<a name="l00019"></a>00019         <span class="keyword">public</span>:
71<a name="l00021"></a><a class="code" href="classbdm_1_1Designer.html#c2855e3a554af0221401626a2904ef22">00021</a>                 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1Designer.html#c2855e3a554af0221401626a2904ef22" title="Redesign control strategy.">redesign</a>(){it_error(<span class="stringliteral">"Not implemented"</span>); };
72<a name="l00023"></a><a class="code" href="classbdm_1_1Designer.html#334668204e01d468fe107780d10d2bd8">00023</a>                 <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1Designer.html#334668204e01d468fe107780d10d2bd8" title="apply control strategy to obtain control input">apply</a>(<span class="keyword">const</span> vec &amp;cond){it_error(<span class="stringliteral">"Not implemented"</span>); <span class="keywordflow">return</span> vec(0);}
73<a name="l00024"></a>00024 };
74<a name="l00025"></a>00025
75<a name="l00028"></a><a class="code" href="classbdm_1_1LQG.html">00028</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1LQG.html">LQG</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1Designer.html" title="Base class of designers of control strategy.">Designer</a> {
76<a name="l00029"></a>00029         <span class="keyword">protected</span>:
77<a name="l00031"></a><a class="code" href="classbdm_1_1LQG.html#ce3c087c11fa4d50f63d2027be572394">00031</a>                 <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1LQG.html#ce3c087c11fa4d50f63d2027be572394" title="dimension of state">dimx</a>;
78<a name="l00033"></a><a class="code" href="classbdm_1_1LQG.html#ff701d81aa4f32e0a07a5910f06c8969">00033</a>                 <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1LQG.html#ff701d81aa4f32e0a07a5910f06c8969" title="dimension of inputs">dimu</a>;
79<a name="l00035"></a><a class="code" href="classbdm_1_1LQG.html#753e909ac3694cde54b4fc718e24fa09">00035</a>                 <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1LQG.html#753e909ac3694cde54b4fc718e24fa09" title="dimension of output">dimy</a>;
80<a name="l00036"></a>00036
81<a name="l00038"></a><a class="code" href="classbdm_1_1LQG.html#ffc0d99976377c584afd5717440a7e61">00038</a>                 mat <a class="code" href="classbdm_1_1LQG.html#ffc0d99976377c584afd5717440a7e61" title="matrix A of the linear system">A</a>;
82<a name="l00040"></a><a class="code" href="classbdm_1_1LQG.html#3093b0597585914ed7ed8c7bc3f2073f">00040</a>                 mat <a class="code" href="classbdm_1_1LQG.html#3093b0597585914ed7ed8c7bc3f2073f" title="matrix B of the linear system">B</a>;
83<a name="l00042"></a><a class="code" href="classbdm_1_1LQG.html#fc2b09d6ff3fd8a7dd6ed8ecf2fb3376">00042</a>                 mat <a class="code" href="classbdm_1_1LQG.html#fc2b09d6ff3fd8a7dd6ed8ecf2fb3376" title="matrix C of the linear system">C</a>;
84<a name="l00044"></a><a class="code" href="classbdm_1_1LQG.html#ad002e3dc31c59db7f286b00a8e2fc65">00044</a>                 vec <a class="code" href="classbdm_1_1LQG.html#ad002e3dc31c59db7f286b00a8e2fc65" title="required value of the output y at time t (assumed constant)">y_req</a>;
85<a name="l00045"></a>00045                 
86<a name="l00047"></a><a class="code" href="classbdm_1_1LQG.html#e770d283502cf4da978d1d8523309869">00047</a>                 <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1LQG.html#e770d283502cf4da978d1d8523309869" title="Control horizon, set to maxint for infinite horizons.">horizon</a>;
87<a name="l00049"></a><a class="code" href="classbdm_1_1LQG.html#484963959d51059d73d9c6174782cc2f">00049</a>                 mat <a class="code" href="classbdm_1_1LQG.html#484963959d51059d73d9c6174782cc2f" title="penalization matrix Qy">Qy</a>;
88<a name="l00051"></a><a class="code" href="classbdm_1_1LQG.html#13f14aea28c7f7b074779ece7df5e748">00051</a>                 mat <a class="code" href="classbdm_1_1LQG.html#13f14aea28c7f7b074779ece7df5e748" title="penalization matrix Qu">Qu</a>;
89<a name="l00053"></a><a class="code" href="classbdm_1_1LQG.html#6c9fa6d9bb0be47ac5ed9183eb38562e">00053</a>                 <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1LQG.html#6c9fa6d9bb0be47ac5ed9183eb38562e" title="time of the design step - from horizon-&amp;gt;0">td</a>;
90<a name="l00055"></a><a class="code" href="classbdm_1_1LQG.html#d78bb29a213eef033a9657ec2f592e80">00055</a>                 mat <a class="code" href="classbdm_1_1LQG.html#d78bb29a213eef033a9657ec2f592e80" title="controller parameters">L</a>;
91<a name="l00056"></a>00056                 
92<a name="l00059"></a>00059                 mat pr;
93<a name="l00061"></a><a class="code" href="classbdm_1_1LQG.html#98203a62e12acc13ced7ef22e4ac4255">00061</a>                 mat <a class="code" href="classbdm_1_1LQG.html#98203a62e12acc13ced7ef22e4ac4255" title="penalization">qux</a>;
94<a name="l00063"></a><a class="code" href="classbdm_1_1LQG.html#0fc6ec35bd9e5f99192b5ff7b0257aef">00063</a>                 mat <a class="code" href="classbdm_1_1LQG.html#0fc6ec35bd9e5f99192b5ff7b0257aef" title="penalization">qyx</a>;
95<a name="l00065"></a><a class="code" href="classbdm_1_1LQG.html#5fc6fe8a5205a1698fb319b58315671b">00065</a>                 mat <a class="code" href="classbdm_1_1LQG.html#5fc6fe8a5205a1698fb319b58315671b" title="internal quadratic form">s</a>;
96<a name="l00067"></a><a class="code" href="classbdm_1_1LQG.html#b29c3dfff52b54e44a793d62afbb5a63">00067</a>                 mat <a class="code" href="classbdm_1_1LQG.html#b29c3dfff52b54e44a793d62afbb5a63" title="penalization">qy</a>;
97<a name="l00069"></a><a class="code" href="classbdm_1_1LQG.html#0f20c8ff99875e3009f2e427247c4c78">00069</a>                 mat <a class="code" href="classbdm_1_1LQG.html#0f20c8ff99875e3009f2e427247c4c78" title="pre_qr part">hqy</a>;
98<a name="l00071"></a><a class="code" href="classbdm_1_1LQG.html#e6c9db2abc7a3290f8e2bb851683d7a0">00071</a>                 mat <a class="code" href="classbdm_1_1LQG.html#e6c9db2abc7a3290f8e2bb851683d7a0" title="pre qr matrix">pre_qr</a>;
99<a name="l00073"></a><a class="code" href="classbdm_1_1LQG.html#13eb495eb5e3c3477e2ebaa4640a642e">00073</a>                 mat <a class="code" href="classbdm_1_1LQG.html#13eb495eb5e3c3477e2ebaa4640a642e" title="post qr matrix">post_qr</a>;
100<a name="l00075"></a>00075                 
101<a name="l00076"></a>00076         <span class="keyword">public</span>:
102<a name="l00078"></a>00078                 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1LQG.html#50b5aee93427077a97d6640cc90e50e3" title="set system parameters from given matrices">set_system_parameters</a>(<span class="keyword">const</span> mat &amp;<a class="code" href="classbdm_1_1LQG.html#ffc0d99976377c584afd5717440a7e61" title="matrix A of the linear system">A</a>, <span class="keyword">const</span> mat &amp;<a class="code" href="classbdm_1_1LQG.html#3093b0597585914ed7ed8c7bc3f2073f" title="matrix B of the linear system">B</a>, <span class="keyword">const</span> mat &amp;<a class="code" href="classbdm_1_1LQG.html#fc2b09d6ff3fd8a7dd6ed8ecf2fb3376" title="matrix C of the linear system">C</a>);
103<a name="l00080"></a>00080                 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1LQG.html#13c39ce525ac7969777113abcad20729" title="set penalization matrices and control horizon">set_control_parameters</a>(<span class="keyword">const</span> mat &amp;Qy0, <span class="keyword">const</span> mat &amp;Qu0, <span class="keyword">const</span> vec y_req0, <span class="keywordtype">int</span> horizon0);
104<a name="l00082"></a>00082 <span class="comment">//              void set_system_parameters(const Kalman &amp;K);</span>
105<a name="l00084"></a>00084 <span class="comment"></span>                <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1LQG.html#3c85d71e15b469f608a8bee1f901264b" title="set system parameters from Kalman filter">prepare_qr</a>();
106<a name="l00086"></a><a class="code" href="classbdm_1_1LQG.html#5016aebbb654a0e3d653b8485e0ea86c">00086</a>                 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1LQG.html#5016aebbb654a0e3d653b8485e0ea86c" title="function for future use which is called at each time td; Should call prepare_qr()!...">update_state</a>(){};
107<a name="l00088"></a><a class="code" href="classbdm_1_1LQG.html#ddc5444b092fdb36239f83ab1ae85805">00088</a>                 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1LQG.html#ddc5444b092fdb36239f83ab1ae85805" title="redesign one step of the">ricatti_step</a>(){
108<a name="l00089"></a>00089                         <a class="code" href="classbdm_1_1LQG.html#e6c9db2abc7a3290f8e2bb851683d7a0" title="pre qr matrix">pre_qr</a>.set_submatrix(0,0,<a class="code" href="classbdm_1_1LQG.html#5fc6fe8a5205a1698fb319b58315671b" title="internal quadratic form">s</a>*pr);
109<a name="l00090"></a>00090                         <a class="code" href="classbdm_1_1LQG.html#e6c9db2abc7a3290f8e2bb851683d7a0" title="pre qr matrix">pre_qr</a>.set_submatrix(<a class="code" href="classbdm_1_1LQG.html#ce3c087c11fa4d50f63d2027be572394" title="dimension of state">dimx</a>+<a class="code" href="classbdm_1_1LQG.html#ff701d81aa4f32e0a07a5910f06c8969" title="dimension of inputs">dimu</a>+<a class="code" href="classbdm_1_1LQG.html#753e909ac3694cde54b4fc718e24fa09" title="dimension of output">dimy</a>, <a class="code" href="classbdm_1_1LQG.html#ff701d81aa4f32e0a07a5910f06c8969" title="dimension of inputs">dimu</a>+<a class="code" href="classbdm_1_1LQG.html#ce3c087c11fa4d50f63d2027be572394" title="dimension of state">dimx</a>, -<a class="code" href="classbdm_1_1LQG.html#484963959d51059d73d9c6174782cc2f" title="penalization matrix Qy">Qy</a>*<a class="code" href="classbdm_1_1LQG.html#ad002e3dc31c59db7f286b00a8e2fc65" title="required value of the output y at time t (assumed constant)">y_req</a>);
110<a name="l00091"></a>00091                         <span class="keywordflow">if</span> (!qr(<a class="code" href="classbdm_1_1LQG.html#e6c9db2abc7a3290f8e2bb851683d7a0" title="pre qr matrix">pre_qr</a>,<a class="code" href="classbdm_1_1LQG.html#13eb495eb5e3c3477e2ebaa4640a642e" title="post qr matrix">post_qr</a>)) it_warning(<span class="stringliteral">"QR in LQG unstable"</span>);
111<a name="l00092"></a>00092                         triu(<a class="code" href="classbdm_1_1LQG.html#13eb495eb5e3c3477e2ebaa4640a642e" title="post qr matrix">post_qr</a>);
112<a name="l00093"></a>00093         <span class="comment">// hn(m+1:2*m+n+r,m+1:2*m+n+r);</span>
113<a name="l00094"></a>00094                         <a class="code" href="classbdm_1_1LQG.html#5fc6fe8a5205a1698fb319b58315671b" title="internal quadratic form">s</a>=<a class="code" href="classbdm_1_1LQG.html#13eb495eb5e3c3477e2ebaa4640a642e" title="post qr matrix">post_qr</a>.get(<a class="code" href="classbdm_1_1LQG.html#ff701d81aa4f32e0a07a5910f06c8969" title="dimension of inputs">dimu</a>, 2*<a class="code" href="classbdm_1_1LQG.html#ff701d81aa4f32e0a07a5910f06c8969" title="dimension of inputs">dimu</a>+<a class="code" href="classbdm_1_1LQG.html#ce3c087c11fa4d50f63d2027be572394" title="dimension of state">dimx</a>+<a class="code" href="classbdm_1_1LQG.html#753e909ac3694cde54b4fc718e24fa09" title="dimension of output">dimy</a>-1, <a class="code" href="classbdm_1_1LQG.html#ff701d81aa4f32e0a07a5910f06c8969" title="dimension of inputs">dimu</a>, 2*<a class="code" href="classbdm_1_1LQG.html#ff701d81aa4f32e0a07a5910f06c8969" title="dimension of inputs">dimu</a>+<a class="code" href="classbdm_1_1LQG.html#ce3c087c11fa4d50f63d2027be572394" title="dimension of state">dimx</a>+<a class="code" href="classbdm_1_1LQG.html#753e909ac3694cde54b4fc718e24fa09" title="dimension of output">dimy</a>-1);
114<a name="l00095"></a>00095                 };
115<a name="l00096"></a><a class="code" href="classbdm_1_1LQG.html#e8df589bbdbdd40515f837c9c9560ed8">00096</a>                 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1LQG.html#e8df589bbdbdd40515f837c9c9560ed8" title="Redesign control strategy.">redesign</a>(){
116<a name="l00097"></a>00097                         <span class="keywordflow">for</span>(<a class="code" href="classbdm_1_1LQG.html#6c9fa6d9bb0be47ac5ed9183eb38562e" title="time of the design step - from horizon-&amp;gt;0">td</a>=<a class="code" href="classbdm_1_1LQG.html#e770d283502cf4da978d1d8523309869" title="Control horizon, set to maxint for infinite horizons.">horizon</a>; <a class="code" href="classbdm_1_1LQG.html#6c9fa6d9bb0be47ac5ed9183eb38562e" title="time of the design step - from horizon-&amp;gt;0">td</a>&gt;0; <a class="code" href="classbdm_1_1LQG.html#6c9fa6d9bb0be47ac5ed9183eb38562e" title="time of the design step - from horizon-&amp;gt;0">td</a>--){
117<a name="l00098"></a>00098                                 <a class="code" href="classbdm_1_1LQG.html#5016aebbb654a0e3d653b8485e0ea86c" title="function for future use which is called at each time td; Should call prepare_qr()!...">update_state</a>();
118<a name="l00099"></a>00099                                 <a class="code" href="classbdm_1_1LQG.html#ddc5444b092fdb36239f83ab1ae85805" title="redesign one step of the">ricatti_step</a>();
119<a name="l00100"></a>00100                         }
120<a name="l00101"></a>00101 <span class="comment">/*                      ws=hn(1:m,m+1:2*m+n+r);</span>
121<a name="l00102"></a>00102 <span class="comment">                        wsd=hn(1:m,1:m);</span>
122<a name="l00103"></a>00103 <span class="comment">                        Lklq=-inv(wsd)*ws;*/</span>
123<a name="l00104"></a>00104                         <a class="code" href="classbdm_1_1LQG.html#d78bb29a213eef033a9657ec2f592e80" title="controller parameters">L</a> = -inv(<a class="code" href="classbdm_1_1LQG.html#13eb495eb5e3c3477e2ebaa4640a642e" title="post qr matrix">post_qr</a>.get(0,<a class="code" href="classbdm_1_1LQG.html#ff701d81aa4f32e0a07a5910f06c8969" title="dimension of inputs">dimu</a>-1, 0,<a class="code" href="classbdm_1_1LQG.html#ff701d81aa4f32e0a07a5910f06c8969" title="dimension of inputs">dimu</a>-1)) * <a class="code" href="classbdm_1_1LQG.html#13eb495eb5e3c3477e2ebaa4640a642e" title="post qr matrix">post_qr</a>.get(0,<a class="code" href="classbdm_1_1LQG.html#ff701d81aa4f32e0a07a5910f06c8969" title="dimension of inputs">dimu</a>-1, <a class="code" href="classbdm_1_1LQG.html#ff701d81aa4f32e0a07a5910f06c8969" title="dimension of inputs">dimu</a>, 2*<a class="code" href="classbdm_1_1LQG.html#ff701d81aa4f32e0a07a5910f06c8969" title="dimension of inputs">dimu</a>+<a class="code" href="classbdm_1_1LQG.html#ce3c087c11fa4d50f63d2027be572394" title="dimension of state">dimx</a>+<a class="code" href="classbdm_1_1LQG.html#753e909ac3694cde54b4fc718e24fa09" title="dimension of output">dimy</a>-1);
124<a name="l00105"></a>00105                 }
125<a name="l00106"></a>00106                 vec apply(<span class="keyword">const</span> vec &amp;state, <span class="keyword">const</span> vec &amp;ukm){vec pom=concat(state, ones(<a class="code" href="classbdm_1_1LQG.html#753e909ac3694cde54b4fc718e24fa09" title="dimension of output">dimy</a>), ukm); <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1LQG.html#d78bb29a213eef033a9657ec2f592e80" title="controller parameters">L</a>*pom;}
126<a name="l00107"></a>00107         } ;
127<a name="l00108"></a>00108
128<a name="l00109"></a>00109 } <span class="comment">// namespace</span>
129</pre></div></div>
130<hr size="1"><address style="text-align: right;"><small>Generated on Sun Aug 16 17:58:18 2009 for mixpp by&nbsp;
131<a href="http://www.doxygen.org/index.html">
132<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
133</body>
134</html>
Note: See TracBrowser for help on using the browser.