source: projects/ckbs/stable/0.20100228/doc/_printable.xml @ 92

Last change on this file since 92 was 92, checked in by bradbell, 12 years ago

[ckbs/trunk] Change download instructions

ckbs.omh: move from here to ckbs.omh.
ckbs.omh: move to here from omh/ckbs.omh and change download instructions.

The changes in doc/* were automatically transferred from ckbs.omh.
_ckbs_xml.js:
ckbs.htm:
ckbs.xml:
index.htm:
_external.htm:
_printable.htm:
index.xml:
_external.xml:
_ckbs_htm.js:
_printable.xml:
copy_doc.sh:
build_doc.sh:

File size: 386.5 KB
Line 
1<?xml version='1.0'?>
2<?xml-stylesheet type='text/xsl' href='pmathml.xsl'?>
3<html xmlns='http://www.w3.org/1999/xhtml'>
4
5<head><title>ckbs-0.20100228.0: A Constrained Kalman-Bucy Smoother</title></head>
6<body>
7
8<hr/>
9<center><b><big><big>ckbs-0.20100228.0: A Constrained Kalman-Bucy Smoother</big></big></b></center>
10<br/>
11<b><big><a name="a" id="a">a: MathML</a></big></b>
12<br/>
13This documentation is in XHTML + MathML.
14If you have trouble viewing it in your browser see
15Viewing MathML on the web page
16<code><span style='white-space: nowrap'><br/>
17&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></code>
18        <a href="http://www.seanet.com/~bradbell/packages.htm" target="_top"><span style='white-space: nowrap'>http://www.seanet.com/~bradbell/packages.htm</span></a>
19
20
21<br/>
22<br/>
23<b><big><a name="b" id="b">b: System Requirements</a></big></b>
24<br/>
25This constrained Kalman-Bucy smoother runs under both the
26<a href="http://www.mathworks.com/" target="_top"><span style='white-space: nowrap'>Matlab&#174;</span></a>
27 (http://www.mathworks.com/)
28and
29<a href="http://www.gnu.org/software/octave/" target="_top"><span style='white-space: nowrap'>Octave</span></a>
30 (http://www.gnu.org/software/octave/)
31While it will work under MS windows,
32these download instructions are for the Unix operating system.
33
34<br/>
35<br/>
36<b><big><a name="c" id="c">c: Download</a></big></b>
37
38
39<br/>
40<br/>
41<b><a name="c.a" id="c.a">c.a: Release Tarballs</a></b>
42<br/>
43You can download a tarball release of ckbs from the directory
44<code><span style='white-space: nowrap'><br/>
45&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></code>
46<a href="http://www.coin-or.org/download/source/CoinBazaar" target="_top"><span style='white-space: nowrap'>http://www.coin-or.org/download/source/CoinBazaar</span></a>
47
48<code><span style='white-space: nowrap'><br/>
49</span></code>Theses releases are named
50
51<code><font color="blue"><span style='white-space: nowrap'><br/>
52&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;ckbs-0.</span></font><i><font color="black"><span style='white-space: nowrap'>yyyymmdd</span></font></i><font color="blue"><span style='white-space: nowrap'>.</span></font><i><font color="black"><span style='white-space: nowrap'>r</span></font></i><font color="blue"><span style='white-space: nowrap'>.</span></font><i><font color="black"><span style='white-space: nowrap'>ext</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
53</span></font></code>
54where
55<code><i><font color="black"><span style='white-space: nowrap'>yyyy</span></font></i></code>
56 is the year,
57
58<code><i><font color="black"><span style='white-space: nowrap'>mm</span></font></i></code>
59 is the month,
60
61<code><i><font color="black"><span style='white-space: nowrap'>dd</span></font></i></code>
62 is the day,
63
64<code><i><font color="black"><span style='white-space: nowrap'>r</span></font></i></code>
65 is the release number,
66and
67<code><i><font color="black"><span style='white-space: nowrap'>ext</span></font></i></code>
68 is <code><font color="blue">tgz</font></code> or <code><font color="blue">zip</font></code>.
69<code><span style='white-space: nowrap'><br/>
70<br/>
71</span></code>If
72<code><i><font color="black"><span style='white-space: nowrap'>ext</span></font></i></code>
73 is <code><font color="blue">tgz</font></code> the command
74
75<code><font color="blue"><span style='white-space: nowrap'><br/>
76&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;tar&#xA0;-xvzf&#xA0;ckbs-0.</span></font><i><font color="black"><span style='white-space: nowrap'>yyyymmdd</span></font></i><font color="blue"><span style='white-space: nowrap'>.</span></font><i><font color="black"><span style='white-space: nowrap'>r</span></font></i><font color="blue"><span style='white-space: nowrap'>.tgz<br/>
77</span></font></code>
78will create the
79<code><font color="blue"><span style='white-space: nowrap'>ckbs-0.</span></font><i><font color="black"><span style='white-space: nowrap'>yyyymmdd</span></font></i><font color="blue"><span style='white-space: nowrap'>.</span></font><i><font color="black"><span style='white-space: nowrap'>r</span></font></i></code>
80 directory.
81<code><span style='white-space: nowrap'><br/>
82<br/>
83</span></code>If
84<code><i><font color="black"><span style='white-space: nowrap'>ext</span></font></i></code>
85 is <code><font color="blue">zip</font></code> the command
86
87<code><font color="blue"><span style='white-space: nowrap'><br/>
88&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;unzip&#xA0;ckbs-0.</span></font><i><font color="black"><span style='white-space: nowrap'>yyyymmdd</span></font></i><font color="blue"><span style='white-space: nowrap'>.</span></font><i><font color="black"><span style='white-space: nowrap'>r</span></font></i><font color="blue"><span style='white-space: nowrap'>.zip<br/>
89</span></font></code>
90will create the
91<code><font color="blue"><span style='white-space: nowrap'>ckbs-0.</span></font><i><font color="black"><span style='white-space: nowrap'>yyyymmdd</span></font></i><font color="blue"><span style='white-space: nowrap'>.</span></font><i><font color="black"><span style='white-space: nowrap'>r</span></font></i></code>
92 directory.
93
94<br/>
95<br/>
96<b><a name="c.b" id="c.b">c.b: Using Subversion</a></b>
97<br/>
98For each release listed in the
99<a href="http://www.coin-or.org/download/source/CoinBazaar" target="_top"><span style='white-space: nowrap'>download&#xA0;directory</span></a>
100 (http://www.coin-or.org/download/source/CoinBazaar)
101you can use subversion to download the release with the commands
102
103<code><font color="blue"><span style='white-space: nowrap'><br/>
104&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;web=&quot;https://projects.coin-or.org/svn/CoinBazaar/projects/ckbs&quot;<br/>
105&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;svn&#xA0;checkout&#xA0;$web/releases/0.</span></font><i><font color="black"><span style='white-space: nowrap'>yyyymmdd</span></font></i><font color="blue"><span style='white-space: nowrap'>.</span></font><i><font color="black"><span style='white-space: nowrap'>r</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;ckbs-0.</span></font><i><font color="black"><span style='white-space: nowrap'>yyyymmdd</span></font></i><font color="blue"><span style='white-space: nowrap'>.</span></font><i><font color="black"><span style='white-space: nowrap'>r</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
106</span></font></code>
107This will create the
108<code><font color="blue"><span style='white-space: nowrap'>ckbs-0.</span></font><i><font color="black"><span style='white-space: nowrap'>yyyymmdd</span></font></i><font color="blue"><span style='white-space: nowrap'>.</span></font><i><font color="black"><span style='white-space: nowrap'>r</span></font></i></code>
109 directory.
110
111<br/>
112<br/>
113<b><a name="c.c" id="c.c">c.c: Latest Version</a></b>
114<br/>
115You can download the most recent version of ckbs (called the trunk)
116using the commands
117
118<code><font color="blue"><span style='white-space: nowrap'><br/>
119&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;web=&quot;https://projects.coin-or.org/svn/CoinBazaar/projects/ckbs&quot;<br/>
120&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;svn&#xA0;checkout&#xA0;$web/trunk&#xA0;ckbs-0.20100228.0<br/>
121</span></font></code>
122This will create the <code><font color="blue">ckbs-0.20100228.0</font></code> directory.
123
124<br/>
125<br/>
126<b><big><a name="d" id="d">d: Test Install</a></big></b>
127<br/>
128Using Matlab&#174; or Octave, to change into the directory
129
130<code><font color="blue"><span style='white-space: nowrap'><br/>
131&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;ckbs-0.</span></font><i><font color="black"><span style='white-space: nowrap'>yyyymmdd</span></font></i><font color="blue"><span style='white-space: nowrap'>.</span></font><i><font color="black"><span style='white-space: nowrap'>r</span></font></i><font color="blue"><span style='white-space: nowrap'>/test<br/>
132</span></font></code>
133and run the program <code><font color="blue">all_ok.m</font></code>.
134It will print the test results for all the components of <code><font color="blue">ckbs</font></code>.
135
136<br/>
137<br/>
138<b><big><a name="e" id="e">e: Documentation</a></big></b>
139<br/>
140If you download a release, a copy of the documentation for the release
141can be found be viewed in your browser by opening the file
142
143<code><font color="blue"><span style='white-space: nowrap'><br/>
144&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;ckbs-0.</span></font><i><font color="black"><span style='white-space: nowrap'>yyyymmdd</span></font></i><font color="blue"><span style='white-space: nowrap'>.</span></font><i><font color="black"><span style='white-space: nowrap'>r</span></font></i><font color="blue"><span style='white-space: nowrap'>/doc/ckbs.xml<br/>
145<br/>
146</span></font></code>
147If you download the latest version (the trunk),
148a copy of the documentation for this version can
149be built by executing the commands
150<code><font color='blue'><pre style='display:inline'> 
151        cd ckbs-0.20100228.0
152        ./build_doc.sh
153</pre></font></code>
154
155You can then view the documentation in your browser by opening the file
156
157<code><font color="blue"><span style='white-space: nowrap'><br/>
158&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;ckbs-0.20100228.0/doc/ckbs.xml<br/>
159</span></font></code>
160<br/>
161<b><big><a name="f" id="f">f: Contents</a></big></b>
162<br/>
163<table>
164<tr><td><a href="#1" target="_top">_contents:&#xA0;1</a></td><td>Table&#xA0;of&#xA0;Contents</td></tr><tr><td><a href="#2" target="_top">license:&#xA0;2</a></td><td>Your&#xA0;License&#xA0;to&#xA0;use&#xA0;the&#xA0;ckbs&#xA0;Software</td></tr><tr><td><a href="#3" target="_top">ckbs_nonlinear:&#xA0;3</a></td><td>The&#xA0;Nonlinear&#xA0;Constrained&#xA0;Kalman-Bucy&#xA0;Smoother</td></tr><tr><td><a href="#4" target="_top">ckbs_affine:&#xA0;4</a></td><td>Constrained&#xA0;Affine&#xA0;Kalman&#xA0;Bucy&#xA0;Smoother</td></tr><tr><td><a href="#5" target="_top">utility:&#xA0;5</a></td><td>ckbs&#xA0;Utility&#xA0;Functions</td></tr><tr><td><a href="#6" target="_top">all_ok.m:&#xA0;6</a></td><td>Run&#xA0;All&#xA0;Correctness&#xA0;Tests</td></tr><tr><td><a href="#7" target="_top">whatsnew:&#xA0;7</a></td><td>Changes&#xA0;and&#xA0;Additions&#xA0;to&#xA0;ckbs</td></tr><tr><td><a href="#8" target="_top">_reference:&#xA0;8</a></td><td>Alphabetic&#xA0;Listing&#xA0;of&#xA0;Cross&#xA0;Reference&#xA0;Tags</td></tr><tr><td><a href="#9" target="_top">_index:&#xA0;9</a></td><td>Keyword&#xA0;Index</td></tr><tr><td><a href="#10" target="_top">_external:&#xA0;10</a></td><td>External&#xA0;Internet&#xA0;References</td></tr></table>
165<hr/>Input File: ckbs.omh
166
167<hr/>
168<center><b><big><big>
1691: Table of Contents</big></big></b></center>
170
171<pre>
172ckbs-0.20100228.0: A Constrained Kalman-Bucy Smoother: <a href="#">: ckbs</a>
173    Table of Contents: <a href="#1">1: _contents</a>
174    Your License to use the ckbs Software: <a href="#2">2: license</a>
175    The Nonlinear Constrained Kalman-Bucy Smoother: <a href="#3">3: ckbs_nonlinear</a>
176        Simple ckbs_nonlinear Example and Test: <a href="#3.1">3.1: nonlinear_ok_simple.m</a>
177            Example Constraint Function: nonlinear_ok_simple_f: <a href="#3.1.1">3.1.1: nonlinear_ok_simple_f.m</a>
178            Example Transition Function: nonlinear_ok_simple_g: <a href="#3.1.2">3.1.2: nonlinear_ok_simple_g.m</a>
179            Example Measurement Function: nonlinear_ok_simple_h: <a href="#3.1.3">3.1.3: nonlinear_ok_simple_h.m</a>
180        ckbs_nonlinear Box Constrained Tracking Example and Test: <a href="#3.2">3.2: nonlinear_ok_box.m</a>
181            Example Constraint Function: nonlinear_ok_box_f: <a href="#3.2.1">3.2.1: nonlinear_ok_box_f.m</a>
182            Example Transition Function: nonlinear_ok_box_g: <a href="#3.2.2">3.2.2: nonlinear_ok_box_g.m</a>
183            Example Measurement Function: nonlinear_ok_box_h: <a href="#3.2.3">3.2.3: nonlinear_ok_box_h.m</a>
184            Example no Constraint Function: nonlinear_ok_box_nof: <a href="#3.2.4">3.2.4: nonlinear_ok_box_nof.m</a>
185        ckbs_nonlinear Sine Wave Constrained Tracking Example and Test: <a href="#3.3">3.3: nonlinear_ok_sin.m</a>
186            Example Constraint Function: nonlinear_ok_sin_f: <a href="#3.3.1">3.3.1: nonlinear_ok_sin_f.m</a>
187    Constrained Affine Kalman Bucy Smoother: <a href="#4">4: ckbs_affine</a>
188        ckbs_affine Box Constrained Smoothing Spline Example and Test: <a href="#4.1">4.1: affine_ok_box.m</a>
189    ckbs Utility Functions: <a href="#5">5: utility</a>
190        Packed Block Diagonal Matrix Times a Vector: <a href="#5.1">5.1: ckbs_blkdiag_mul</a>
191            blkdiag_mul Example and Test: <a href="#5.1.1">5.1.1: blkdiag_mul_ok.m</a>
192        Transpose of Packed Block Diagonal Matrix Times a Vector: <a href="#5.2">5.2: ckbs_blkdiag_mul_t</a>
193            blkdiag_mul_t Example and Test: <a href="#5.2.1">5.2.1: blkdiag_mul_t_ok.m</a>
194        Affine Residual Sum of Squares Objective: <a href="#5.3">5.3: ckbs_sumsq_obj</a>
195            ckbs_sumsq_obj Example and Test: <a href="#5.3.1">5.3.1: sumsq_obj_ok.m</a>
196        Affine Residual Sum of Squares Gradient: <a href="#5.4">5.4: ckbs_sumsq_grad</a>
197            ckbs_sumsq_grad Example and Test: <a href="#5.4.1">5.4.1: sumsq_grad_ok.m</a>
198        Affine Residual Sum of Squares Hessian: <a href="#5.5">5.5: ckbs_sumsq_hes</a>
199            ckbs_sumsq_hes Example and Test: <a href="#5.5.1">5.5.1: sumsq_hes_ok.m</a>
200        Symmetric Block Tridiagonal Algorithm: <a href="#5.6">5.6: ckbs_tridiag_solve</a>
201            ckbs_tridiag_solve Example and Test: <a href="#5.6.1">5.6.1: tridiag_solve_ok.m</a>
202        Affine Constrained Kalman Bucy Smoother Newton Step: <a href="#5.7">5.7: ckbs_newton_step</a>
203            ckbs_newton_step Example and Test: <a href="#5.7.1">5.7.1: newton_step_ok.m</a>
204        Compute Residual in Kuhn-Tucker Conditions: <a href="#5.8">5.8: ckbs_kuhn_tucker</a>
205            ckbs_kuhn_tucker Example and Test: <a href="#5.8.1">5.8.1: kuhn_tucker_ok.m</a>
206    Run All Correctness Tests: <a href="#6">6: all_ok.m</a>
207        Ensure Path is Set for Testing: <a href="#6.1">6.1: test_path.m</a>
208    Changes and Additions to ckbs: <a href="#7">7: whatsnew</a>
209    Alphabetic Listing of Cross Reference Tags: <a href="#8">8: _reference</a>
210    Keyword Index: <a href="#9">9: _index</a>
211    External Internet References: <a href="#10">10: _external</a>
212</pre>
213<hr/>
214<center><b><big><big><a name="2" id="2">2: Your License to use the ckbs Software</a>
215</big></big></b></center>
216<code><span style='white-space: nowrap'><br/>
217&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;GNU&#xA0;GENERAL&#xA0;PUBLIC&#xA0;LICENSE<br/>
218&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;Version&#xA0;2,&#xA0;June&#xA0;1991<br/>
219<br/>
220&#xA0;Copyright&#xA0;(C)&#xA0;1989,&#xA0;1991&#xA0;Free&#xA0;Software&#xA0;Foundation,&#xA0;Inc.,<br/>
221&#xA0;51&#xA0;Franklin&#xA0;Street,&#xA0;Fifth&#xA0;Floor,&#xA0;Boston,&#xA0;MA&#xA0;02110-1301&#xA0;USA<br/>
222&#xA0;Everyone&#xA0;is&#xA0;permitted&#xA0;to&#xA0;copy&#xA0;and&#xA0;distribute&#xA0;verbatim&#xA0;copies<br/>
223&#xA0;of&#xA0;this&#xA0;license&#xA0;document,&#xA0;but&#xA0;changing&#xA0;it&#xA0;is&#xA0;not&#xA0;allowed.<br/>
224<br/>
225&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;Preamble<br/>
226<br/>
227&#xA0;&#xA0;The&#xA0;licenses&#xA0;for&#xA0;most&#xA0;software&#xA0;are&#xA0;designed&#xA0;to&#xA0;take&#xA0;away&#xA0;your<br/>
228freedom&#xA0;to&#xA0;share&#xA0;and&#xA0;change&#xA0;it.&#xA0;&#xA0;By&#xA0;contrast,&#xA0;the&#xA0;GNU&#xA0;General&#xA0;Public<br/>
229License&#xA0;is&#xA0;intended&#xA0;to&#xA0;guarantee&#xA0;your&#xA0;freedom&#xA0;to&#xA0;share&#xA0;and&#xA0;change&#xA0;free<br/>
230software--to&#xA0;make&#xA0;sure&#xA0;the&#xA0;software&#xA0;is&#xA0;free&#xA0;for&#xA0;all&#xA0;its&#xA0;users.&#xA0;&#xA0;This<br/>
231General&#xA0;Public&#xA0;License&#xA0;applies&#xA0;to&#xA0;most&#xA0;of&#xA0;the&#xA0;Free&#xA0;Software<br/>
232Foundation's&#xA0;software&#xA0;and&#xA0;to&#xA0;any&#xA0;other&#xA0;program&#xA0;whose&#xA0;authors&#xA0;commit&#xA0;to<br/>
233using&#xA0;it.&#xA0;&#xA0;(Some&#xA0;other&#xA0;Free&#xA0;Software&#xA0;Foundation&#xA0;software&#xA0;is&#xA0;covered&#xA0;by<br/>
234the&#xA0;GNU&#xA0;Lesser&#xA0;General&#xA0;Public&#xA0;License&#xA0;instead.)&#xA0;&#xA0;You&#xA0;can&#xA0;apply&#xA0;it&#xA0;to<br/>
235your&#xA0;programs,&#xA0;too.<br/>
236<br/>
237&#xA0;&#xA0;When&#xA0;we&#xA0;speak&#xA0;of&#xA0;free&#xA0;software,&#xA0;we&#xA0;are&#xA0;referring&#xA0;to&#xA0;freedom,&#xA0;not<br/>
238price.&#xA0;&#xA0;Our&#xA0;General&#xA0;Public&#xA0;Licenses&#xA0;are&#xA0;designed&#xA0;to&#xA0;make&#xA0;sure&#xA0;that&#xA0;you<br/>
239have&#xA0;the&#xA0;freedom&#xA0;to&#xA0;distribute&#xA0;copies&#xA0;of&#xA0;free&#xA0;software&#xA0;(and&#xA0;charge&#xA0;for<br/>
240this&#xA0;service&#xA0;if&#xA0;you&#xA0;wish),&#xA0;that&#xA0;you&#xA0;receive&#xA0;source&#xA0;code&#xA0;or&#xA0;can&#xA0;get&#xA0;it<br/>
241if&#xA0;you&#xA0;want&#xA0;it,&#xA0;that&#xA0;you&#xA0;can&#xA0;change&#xA0;the&#xA0;software&#xA0;or&#xA0;use&#xA0;pieces&#xA0;of&#xA0;it<br/>
242in&#xA0;new&#xA0;free&#xA0;programs;&#xA0;and&#xA0;that&#xA0;you&#xA0;know&#xA0;you&#xA0;can&#xA0;do&#xA0;these&#xA0;things.<br/>
243<br/>
244&#xA0;&#xA0;To&#xA0;protect&#xA0;your&#xA0;rights,&#xA0;we&#xA0;need&#xA0;to&#xA0;make&#xA0;restrictions&#xA0;that&#xA0;forbid<br/>
245anyone&#xA0;to&#xA0;deny&#xA0;you&#xA0;these&#xA0;rights&#xA0;or&#xA0;to&#xA0;ask&#xA0;you&#xA0;to&#xA0;surrender&#xA0;the&#xA0;rights.<br/>
246These&#xA0;restrictions&#xA0;translate&#xA0;to&#xA0;certain&#xA0;responsibilities&#xA0;for&#xA0;you&#xA0;if&#xA0;you<br/>
247distribute&#xA0;copies&#xA0;of&#xA0;the&#xA0;software,&#xA0;or&#xA0;if&#xA0;you&#xA0;modify&#xA0;it.<br/>
248<br/>
249&#xA0;&#xA0;For&#xA0;example,&#xA0;if&#xA0;you&#xA0;distribute&#xA0;copies&#xA0;of&#xA0;such&#xA0;a&#xA0;program,&#xA0;whether<br/>
250gratis&#xA0;or&#xA0;for&#xA0;a&#xA0;fee,&#xA0;you&#xA0;must&#xA0;give&#xA0;the&#xA0;recipients&#xA0;all&#xA0;the&#xA0;rights&#xA0;that<br/>
251you&#xA0;have.&#xA0;&#xA0;You&#xA0;must&#xA0;make&#xA0;sure&#xA0;that&#xA0;they,&#xA0;too,&#xA0;receive&#xA0;or&#xA0;can&#xA0;get&#xA0;the<br/>
252source&#xA0;code.&#xA0;&#xA0;And&#xA0;you&#xA0;must&#xA0;show&#xA0;them&#xA0;these&#xA0;terms&#xA0;so&#xA0;they&#xA0;know&#xA0;their<br/>
253rights.<br/>
254<br/>
255&#xA0;&#xA0;We&#xA0;protect&#xA0;your&#xA0;rights&#xA0;with&#xA0;two&#xA0;steps:&#xA0;(1)&#xA0;copyright&#xA0;the&#xA0;software,&#xA0;and<br/>
256(2)&#xA0;offer&#xA0;you&#xA0;this&#xA0;license&#xA0;which&#xA0;gives&#xA0;you&#xA0;legal&#xA0;permission&#xA0;to&#xA0;copy,<br/>
257distribute&#xA0;and/or&#xA0;modify&#xA0;the&#xA0;software.<br/>
258<br/>
259&#xA0;&#xA0;Also,&#xA0;for&#xA0;each&#xA0;author's&#xA0;protection&#xA0;and&#xA0;ours,&#xA0;we&#xA0;want&#xA0;to&#xA0;make&#xA0;certain<br/>
260that&#xA0;everyone&#xA0;understands&#xA0;that&#xA0;there&#xA0;is&#xA0;no&#xA0;warranty&#xA0;for&#xA0;this&#xA0;free<br/>
261software.&#xA0;&#xA0;If&#xA0;the&#xA0;software&#xA0;is&#xA0;modified&#xA0;by&#xA0;someone&#xA0;else&#xA0;and&#xA0;passed&#xA0;on,&#xA0;we<br/>
262want&#xA0;its&#xA0;recipients&#xA0;to&#xA0;know&#xA0;that&#xA0;what&#xA0;they&#xA0;have&#xA0;is&#xA0;not&#xA0;the&#xA0;original,&#xA0;so<br/>
263that&#xA0;any&#xA0;problems&#xA0;introduced&#xA0;by&#xA0;others&#xA0;will&#xA0;not&#xA0;reflect&#xA0;on&#xA0;the&#xA0;original<br/>
264authors'&#xA0;reputations.<br/>
265<br/>
266&#xA0;&#xA0;Finally,&#xA0;any&#xA0;free&#xA0;program&#xA0;is&#xA0;threatened&#xA0;constantly&#xA0;by&#xA0;software<br/>
267patents.&#xA0;&#xA0;We&#xA0;wish&#xA0;to&#xA0;avoid&#xA0;the&#xA0;danger&#xA0;that&#xA0;redistributors&#xA0;of&#xA0;a&#xA0;free<br/>
268program&#xA0;will&#xA0;individually&#xA0;obtain&#xA0;patent&#xA0;licenses,&#xA0;in&#xA0;effect&#xA0;making&#xA0;the<br/>
269program&#xA0;proprietary.&#xA0;&#xA0;To&#xA0;prevent&#xA0;this,&#xA0;we&#xA0;have&#xA0;made&#xA0;it&#xA0;clear&#xA0;that&#xA0;any<br/>
270patent&#xA0;must&#xA0;be&#xA0;licensed&#xA0;for&#xA0;everyone's&#xA0;free&#xA0;use&#xA0;or&#xA0;not&#xA0;licensed&#xA0;at&#xA0;all.<br/>
271<br/>
272&#xA0;&#xA0;The&#xA0;precise&#xA0;terms&#xA0;and&#xA0;conditions&#xA0;for&#xA0;copying,&#xA0;distribution&#xA0;and<br/>
273modification&#xA0;follow.<br/>
274<br/>
275&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;GNU&#xA0;GENERAL&#xA0;PUBLIC&#xA0;LICENSE<br/>
276&#xA0;&#xA0;&#xA0;TERMS&#xA0;AND&#xA0;CONDITIONS&#xA0;FOR&#xA0;COPYING,&#xA0;DISTRIBUTION&#xA0;AND&#xA0;MODIFICATION<br/>
277<br/>
278&#xA0;&#xA0;0.&#xA0;This&#xA0;License&#xA0;applies&#xA0;to&#xA0;any&#xA0;program&#xA0;or&#xA0;other&#xA0;work&#xA0;which&#xA0;contains<br/>
279a&#xA0;notice&#xA0;placed&#xA0;by&#xA0;the&#xA0;copyright&#xA0;holder&#xA0;saying&#xA0;it&#xA0;may&#xA0;be&#xA0;distributed<br/>
280under&#xA0;the&#xA0;terms&#xA0;of&#xA0;this&#xA0;General&#xA0;Public&#xA0;License.&#xA0;&#xA0;The&#xA0;&quot;Program&quot;,&#xA0;below,<br/>
281refers&#xA0;to&#xA0;any&#xA0;such&#xA0;program&#xA0;or&#xA0;work,&#xA0;and&#xA0;a&#xA0;&quot;work&#xA0;based&#xA0;on&#xA0;the&#xA0;Program&quot;<br/>
282means&#xA0;either&#xA0;the&#xA0;Program&#xA0;or&#xA0;any&#xA0;derivative&#xA0;work&#xA0;under&#xA0;copyright&#xA0;law:<br/>
283that&#xA0;is&#xA0;to&#xA0;say,&#xA0;a&#xA0;work&#xA0;containing&#xA0;the&#xA0;Program&#xA0;or&#xA0;a&#xA0;portion&#xA0;of&#xA0;it,<br/>
284either&#xA0;verbatim&#xA0;or&#xA0;with&#xA0;modifications&#xA0;and/or&#xA0;translated&#xA0;into&#xA0;another<br/>
285language.&#xA0;&#xA0;(Hereinafter,&#xA0;translation&#xA0;is&#xA0;included&#xA0;without&#xA0;limitation&#xA0;in<br/>
286the&#xA0;term&#xA0;&quot;modification&quot;.)&#xA0;&#xA0;Each&#xA0;licensee&#xA0;is&#xA0;addressed&#xA0;as&#xA0;&quot;you&quot;.<br/>
287<br/>
288Activities&#xA0;other&#xA0;than&#xA0;copying,&#xA0;distribution&#xA0;and&#xA0;modification&#xA0;are&#xA0;not<br/>
289covered&#xA0;by&#xA0;this&#xA0;License;&#xA0;they&#xA0;are&#xA0;outside&#xA0;its&#xA0;scope.&#xA0;&#xA0;The&#xA0;act&#xA0;of<br/>
290running&#xA0;the&#xA0;Program&#xA0;is&#xA0;not&#xA0;restricted,&#xA0;and&#xA0;the&#xA0;output&#xA0;from&#xA0;the&#xA0;Program<br/>
291is&#xA0;covered&#xA0;only&#xA0;if&#xA0;its&#xA0;contents&#xA0;constitute&#xA0;a&#xA0;work&#xA0;based&#xA0;on&#xA0;the<br/>
292Program&#xA0;(independent&#xA0;of&#xA0;having&#xA0;been&#xA0;made&#xA0;by&#xA0;running&#xA0;the&#xA0;Program).<br/>
293Whether&#xA0;that&#xA0;is&#xA0;true&#xA0;depends&#xA0;on&#xA0;what&#xA0;the&#xA0;Program&#xA0;does.<br/>
294<br/>
295&#xA0;&#xA0;1.&#xA0;You&#xA0;may&#xA0;copy&#xA0;and&#xA0;distribute&#xA0;verbatim&#xA0;copies&#xA0;of&#xA0;the&#xA0;Program's<br/>
296source&#xA0;code&#xA0;as&#xA0;you&#xA0;receive&#xA0;it,&#xA0;in&#xA0;any&#xA0;medium,&#xA0;provided&#xA0;that&#xA0;you<br/>
297conspicuously&#xA0;and&#xA0;appropriately&#xA0;publish&#xA0;on&#xA0;each&#xA0;copy&#xA0;an&#xA0;appropriate<br/>
298copyright&#xA0;notice&#xA0;and&#xA0;disclaimer&#xA0;of&#xA0;warranty;&#xA0;keep&#xA0;intact&#xA0;all&#xA0;the<br/>
299notices&#xA0;that&#xA0;refer&#xA0;to&#xA0;this&#xA0;License&#xA0;and&#xA0;to&#xA0;the&#xA0;absence&#xA0;of&#xA0;any&#xA0;warranty;<br/>
300and&#xA0;give&#xA0;any&#xA0;other&#xA0;recipients&#xA0;of&#xA0;the&#xA0;Program&#xA0;a&#xA0;copy&#xA0;of&#xA0;this&#xA0;License<br/>
301along&#xA0;with&#xA0;the&#xA0;Program.<br/>
302<br/>
303You&#xA0;may&#xA0;charge&#xA0;a&#xA0;fee&#xA0;for&#xA0;the&#xA0;physical&#xA0;act&#xA0;of&#xA0;transferring&#xA0;a&#xA0;copy,&#xA0;and<br/>
304you&#xA0;may&#xA0;at&#xA0;your&#xA0;option&#xA0;offer&#xA0;warranty&#xA0;protection&#xA0;in&#xA0;exchange&#xA0;for&#xA0;a&#xA0;fee.<br/>
305<br/>
306&#xA0;&#xA0;2.&#xA0;You&#xA0;may&#xA0;modify&#xA0;your&#xA0;copy&#xA0;or&#xA0;copies&#xA0;of&#xA0;the&#xA0;Program&#xA0;or&#xA0;any&#xA0;portion<br/>
307of&#xA0;it,&#xA0;thus&#xA0;forming&#xA0;a&#xA0;work&#xA0;based&#xA0;on&#xA0;the&#xA0;Program,&#xA0;and&#xA0;copy&#xA0;and<br/>
308distribute&#xA0;such&#xA0;modifications&#xA0;or&#xA0;work&#xA0;under&#xA0;the&#xA0;terms&#xA0;of&#xA0;Section&#xA0;1<br/>
309above,&#xA0;provided&#xA0;that&#xA0;you&#xA0;also&#xA0;meet&#xA0;all&#xA0;of&#xA0;these&#xA0;conditions:<br/>
310<br/>
311&#xA0;&#xA0;&#xA0;&#xA0;a)&#xA0;You&#xA0;must&#xA0;cause&#xA0;the&#xA0;modified&#xA0;files&#xA0;to&#xA0;carry&#xA0;prominent&#xA0;notices<br/>
312&#xA0;&#xA0;&#xA0;&#xA0;stating&#xA0;that&#xA0;you&#xA0;changed&#xA0;the&#xA0;files&#xA0;and&#xA0;the&#xA0;date&#xA0;of&#xA0;any&#xA0;change.<br/>
313<br/>
314&#xA0;&#xA0;&#xA0;&#xA0;b)&#xA0;You&#xA0;must&#xA0;cause&#xA0;any&#xA0;work&#xA0;that&#xA0;you&#xA0;distribute&#xA0;or&#xA0;publish,&#xA0;that&#xA0;in<br/>
315&#xA0;&#xA0;&#xA0;&#xA0;whole&#xA0;or&#xA0;in&#xA0;part&#xA0;contains&#xA0;or&#xA0;is&#xA0;derived&#xA0;from&#xA0;the&#xA0;Program&#xA0;or&#xA0;any<br/>
316&#xA0;&#xA0;&#xA0;&#xA0;part&#xA0;thereof,&#xA0;to&#xA0;be&#xA0;licensed&#xA0;as&#xA0;a&#xA0;whole&#xA0;at&#xA0;no&#xA0;charge&#xA0;to&#xA0;all&#xA0;third<br/>
317&#xA0;&#xA0;&#xA0;&#xA0;parties&#xA0;under&#xA0;the&#xA0;terms&#xA0;of&#xA0;this&#xA0;License.<br/>
318<br/>
319&#xA0;&#xA0;&#xA0;&#xA0;c)&#xA0;If&#xA0;the&#xA0;modified&#xA0;program&#xA0;normally&#xA0;reads&#xA0;commands&#xA0;interactively<br/>
320&#xA0;&#xA0;&#xA0;&#xA0;when&#xA0;run,&#xA0;you&#xA0;must&#xA0;cause&#xA0;it,&#xA0;when&#xA0;started&#xA0;running&#xA0;for&#xA0;such<br/>
321&#xA0;&#xA0;&#xA0;&#xA0;interactive&#xA0;use&#xA0;in&#xA0;the&#xA0;most&#xA0;ordinary&#xA0;way,&#xA0;to&#xA0;print&#xA0;or&#xA0;display&#xA0;an<br/>
322&#xA0;&#xA0;&#xA0;&#xA0;announcement&#xA0;including&#xA0;an&#xA0;appropriate&#xA0;copyright&#xA0;notice&#xA0;and&#xA0;a<br/>
323&#xA0;&#xA0;&#xA0;&#xA0;notice&#xA0;that&#xA0;there&#xA0;is&#xA0;no&#xA0;warranty&#xA0;(or&#xA0;else,&#xA0;saying&#xA0;that&#xA0;you&#xA0;provide<br/>
324&#xA0;&#xA0;&#xA0;&#xA0;a&#xA0;warranty)&#xA0;and&#xA0;that&#xA0;users&#xA0;may&#xA0;redistribute&#xA0;the&#xA0;program&#xA0;under<br/>
325&#xA0;&#xA0;&#xA0;&#xA0;these&#xA0;conditions,&#xA0;and&#xA0;telling&#xA0;the&#xA0;user&#xA0;how&#xA0;to&#xA0;view&#xA0;a&#xA0;copy&#xA0;of&#xA0;this<br/>
326&#xA0;&#xA0;&#xA0;&#xA0;License.&#xA0;&#xA0;(Exception:&#xA0;if&#xA0;the&#xA0;Program&#xA0;itself&#xA0;is&#xA0;interactive&#xA0;but<br/>
327&#xA0;&#xA0;&#xA0;&#xA0;does&#xA0;not&#xA0;normally&#xA0;print&#xA0;such&#xA0;an&#xA0;announcement,&#xA0;your&#xA0;work&#xA0;based&#xA0;on<br/>
328&#xA0;&#xA0;&#xA0;&#xA0;the&#xA0;Program&#xA0;is&#xA0;not&#xA0;required&#xA0;to&#xA0;print&#xA0;an&#xA0;announcement.)<br/>
329<br/>
330These&#xA0;requirements&#xA0;apply&#xA0;to&#xA0;the&#xA0;modified&#xA0;work&#xA0;as&#xA0;a&#xA0;whole.&#xA0;&#xA0;If<br/>
331identifiable&#xA0;sections&#xA0;of&#xA0;that&#xA0;work&#xA0;are&#xA0;not&#xA0;derived&#xA0;from&#xA0;the&#xA0;Program,<br/>
332and&#xA0;can&#xA0;be&#xA0;reasonably&#xA0;considered&#xA0;independent&#xA0;and&#xA0;separate&#xA0;works&#xA0;in<br/>
333themselves,&#xA0;then&#xA0;this&#xA0;License,&#xA0;and&#xA0;its&#xA0;terms,&#xA0;do&#xA0;not&#xA0;apply&#xA0;to&#xA0;those<br/>
334sections&#xA0;when&#xA0;you&#xA0;distribute&#xA0;them&#xA0;as&#xA0;separate&#xA0;works.&#xA0;&#xA0;But&#xA0;when&#xA0;you<br/>
335distribute&#xA0;the&#xA0;same&#xA0;sections&#xA0;as&#xA0;part&#xA0;of&#xA0;a&#xA0;whole&#xA0;which&#xA0;is&#xA0;a&#xA0;work&#xA0;based<br/>
336on&#xA0;the&#xA0;Program,&#xA0;the&#xA0;distribution&#xA0;of&#xA0;the&#xA0;whole&#xA0;must&#xA0;be&#xA0;on&#xA0;the&#xA0;terms&#xA0;of<br/>
337this&#xA0;License,&#xA0;whose&#xA0;permissions&#xA0;for&#xA0;other&#xA0;licensees&#xA0;extend&#xA0;to&#xA0;the<br/>
338entire&#xA0;whole,&#xA0;and&#xA0;thus&#xA0;to&#xA0;each&#xA0;and&#xA0;every&#xA0;part&#xA0;regardless&#xA0;of&#xA0;who&#xA0;wrote&#xA0;it.<br/>
339<br/>
340Thus,&#xA0;it&#xA0;is&#xA0;not&#xA0;the&#xA0;intent&#xA0;of&#xA0;this&#xA0;section&#xA0;to&#xA0;claim&#xA0;rights&#xA0;or&#xA0;contest<br/>
341your&#xA0;rights&#xA0;to&#xA0;work&#xA0;written&#xA0;entirely&#xA0;by&#xA0;you;&#xA0;rather,&#xA0;the&#xA0;intent&#xA0;is&#xA0;to<br/>
342exercise&#xA0;the&#xA0;right&#xA0;to&#xA0;control&#xA0;the&#xA0;distribution&#xA0;of&#xA0;derivative&#xA0;or<br/>
343collective&#xA0;works&#xA0;based&#xA0;on&#xA0;the&#xA0;Program.<br/>
344<br/>
345In&#xA0;addition,&#xA0;mere&#xA0;aggregation&#xA0;of&#xA0;another&#xA0;work&#xA0;not&#xA0;based&#xA0;on&#xA0;the&#xA0;Program<br/>
346with&#xA0;the&#xA0;Program&#xA0;(or&#xA0;with&#xA0;a&#xA0;work&#xA0;based&#xA0;on&#xA0;the&#xA0;Program)&#xA0;on&#xA0;a&#xA0;volume&#xA0;of<br/>
347a&#xA0;storage&#xA0;or&#xA0;distribution&#xA0;medium&#xA0;does&#xA0;not&#xA0;bring&#xA0;the&#xA0;other&#xA0;work&#xA0;under<br/>
348the&#xA0;scope&#xA0;of&#xA0;this&#xA0;License.<br/>
349<br/>
350&#xA0;&#xA0;3.&#xA0;You&#xA0;may&#xA0;copy&#xA0;and&#xA0;distribute&#xA0;the&#xA0;Program&#xA0;(or&#xA0;a&#xA0;work&#xA0;based&#xA0;on&#xA0;it,<br/>
351under&#xA0;Section&#xA0;2)&#xA0;in&#xA0;object&#xA0;code&#xA0;or&#xA0;executable&#xA0;form&#xA0;under&#xA0;the&#xA0;terms&#xA0;of<br/>
352Sections&#xA0;1&#xA0;and&#xA0;2&#xA0;above&#xA0;provided&#xA0;that&#xA0;you&#xA0;also&#xA0;do&#xA0;one&#xA0;of&#xA0;the&#xA0;following:<br/>
353<br/>
354&#xA0;&#xA0;&#xA0;&#xA0;a)&#xA0;Accompany&#xA0;it&#xA0;with&#xA0;the&#xA0;complete&#xA0;corresponding&#xA0;machine-readable<br/>
355&#xA0;&#xA0;&#xA0;&#xA0;source&#xA0;code,&#xA0;which&#xA0;must&#xA0;be&#xA0;distributed&#xA0;under&#xA0;the&#xA0;terms&#xA0;of&#xA0;Sections<br/>
356&#xA0;&#xA0;&#xA0;&#xA0;1&#xA0;and&#xA0;2&#xA0;above&#xA0;on&#xA0;a&#xA0;medium&#xA0;customarily&#xA0;used&#xA0;for&#xA0;software&#xA0;interchange;&#xA0;or,<br/>
357<br/>
358&#xA0;&#xA0;&#xA0;&#xA0;b)&#xA0;Accompany&#xA0;it&#xA0;with&#xA0;a&#xA0;written&#xA0;offer,&#xA0;valid&#xA0;for&#xA0;at&#xA0;least&#xA0;three<br/>
359&#xA0;&#xA0;&#xA0;&#xA0;years,&#xA0;to&#xA0;give&#xA0;any&#xA0;third&#xA0;party,&#xA0;for&#xA0;a&#xA0;charge&#xA0;no&#xA0;more&#xA0;than&#xA0;your<br/>
360&#xA0;&#xA0;&#xA0;&#xA0;cost&#xA0;of&#xA0;physically&#xA0;performing&#xA0;source&#xA0;distribution,&#xA0;a&#xA0;complete<br/>
361&#xA0;&#xA0;&#xA0;&#xA0;machine-readable&#xA0;copy&#xA0;of&#xA0;the&#xA0;corresponding&#xA0;source&#xA0;code,&#xA0;to&#xA0;be<br/>
362&#xA0;&#xA0;&#xA0;&#xA0;distributed&#xA0;under&#xA0;the&#xA0;terms&#xA0;of&#xA0;Sections&#xA0;1&#xA0;and&#xA0;2&#xA0;above&#xA0;on&#xA0;a&#xA0;medium<br/>
363&#xA0;&#xA0;&#xA0;&#xA0;customarily&#xA0;used&#xA0;for&#xA0;software&#xA0;interchange;&#xA0;or,<br/>
364<br/>
365&#xA0;&#xA0;&#xA0;&#xA0;c)&#xA0;Accompany&#xA0;it&#xA0;with&#xA0;the&#xA0;information&#xA0;you&#xA0;received&#xA0;as&#xA0;to&#xA0;the&#xA0;offer<br/>
366&#xA0;&#xA0;&#xA0;&#xA0;to&#xA0;distribute&#xA0;corresponding&#xA0;source&#xA0;code.&#xA0;&#xA0;(This&#xA0;alternative&#xA0;is<br/>
367&#xA0;&#xA0;&#xA0;&#xA0;allowed&#xA0;only&#xA0;for&#xA0;noncommercial&#xA0;distribution&#xA0;and&#xA0;only&#xA0;if&#xA0;you<br/>
368&#xA0;&#xA0;&#xA0;&#xA0;received&#xA0;the&#xA0;program&#xA0;in&#xA0;object&#xA0;code&#xA0;or&#xA0;executable&#xA0;form&#xA0;with&#xA0;such<br/>
369&#xA0;&#xA0;&#xA0;&#xA0;an&#xA0;offer,&#xA0;in&#xA0;accord&#xA0;with&#xA0;Subsection&#xA0;b&#xA0;above.)<br/>
370<br/>
371The&#xA0;source&#xA0;code&#xA0;for&#xA0;a&#xA0;work&#xA0;means&#xA0;the&#xA0;preferred&#xA0;form&#xA0;of&#xA0;the&#xA0;work&#xA0;for<br/>
372making&#xA0;modifications&#xA0;to&#xA0;it.&#xA0;&#xA0;For&#xA0;an&#xA0;executable&#xA0;work,&#xA0;complete&#xA0;source<br/>
373code&#xA0;means&#xA0;all&#xA0;the&#xA0;source&#xA0;code&#xA0;for&#xA0;all&#xA0;modules&#xA0;it&#xA0;contains,&#xA0;plus&#xA0;any<br/>
374associated&#xA0;interface&#xA0;definition&#xA0;files,&#xA0;plus&#xA0;the&#xA0;scripts&#xA0;used&#xA0;to<br/>
375control&#xA0;compilation&#xA0;and&#xA0;installation&#xA0;of&#xA0;the&#xA0;executable.&#xA0;&#xA0;However,&#xA0;as&#xA0;a<br/>
376special&#xA0;exception,&#xA0;the&#xA0;source&#xA0;code&#xA0;distributed&#xA0;need&#xA0;not&#xA0;include<br/>
377anything&#xA0;that&#xA0;is&#xA0;normally&#xA0;distributed&#xA0;(in&#xA0;either&#xA0;source&#xA0;or&#xA0;binary<br/>
378form)&#xA0;with&#xA0;the&#xA0;major&#xA0;components&#xA0;(compiler,&#xA0;kernel,&#xA0;and&#xA0;so&#xA0;on)&#xA0;of&#xA0;the<br/>
379operating&#xA0;system&#xA0;on&#xA0;which&#xA0;the&#xA0;executable&#xA0;runs,&#xA0;unless&#xA0;that&#xA0;component<br/>
380itself&#xA0;accompanies&#xA0;the&#xA0;executable.<br/>
381<br/>
382If&#xA0;distribution&#xA0;of&#xA0;executable&#xA0;or&#xA0;object&#xA0;code&#xA0;is&#xA0;made&#xA0;by&#xA0;offering<br/>
383access&#xA0;to&#xA0;copy&#xA0;from&#xA0;a&#xA0;designated&#xA0;place,&#xA0;then&#xA0;offering&#xA0;equivalent<br/>
384access&#xA0;to&#xA0;copy&#xA0;the&#xA0;source&#xA0;code&#xA0;from&#xA0;the&#xA0;same&#xA0;place&#xA0;counts&#xA0;as<br/>
385distribution&#xA0;of&#xA0;the&#xA0;source&#xA0;code,&#xA0;even&#xA0;though&#xA0;third&#xA0;parties&#xA0;are&#xA0;not<br/>
386compelled&#xA0;to&#xA0;copy&#xA0;the&#xA0;source&#xA0;along&#xA0;with&#xA0;the&#xA0;object&#xA0;code.<br/>
387<br/>
388&#xA0;&#xA0;4.&#xA0;You&#xA0;may&#xA0;not&#xA0;copy,&#xA0;modify,&#xA0;sublicense,&#xA0;or&#xA0;distribute&#xA0;the&#xA0;Program<br/>
389except&#xA0;as&#xA0;expressly&#xA0;provided&#xA0;under&#xA0;this&#xA0;License.&#xA0;&#xA0;Any&#xA0;attempt<br/>
390otherwise&#xA0;to&#xA0;copy,&#xA0;modify,&#xA0;sublicense&#xA0;or&#xA0;distribute&#xA0;the&#xA0;Program&#xA0;is<br/>
391void,&#xA0;and&#xA0;will&#xA0;automatically&#xA0;terminate&#xA0;your&#xA0;rights&#xA0;under&#xA0;this&#xA0;License.<br/>
392However,&#xA0;parties&#xA0;who&#xA0;have&#xA0;received&#xA0;copies,&#xA0;or&#xA0;rights,&#xA0;from&#xA0;you&#xA0;under<br/>
393this&#xA0;License&#xA0;will&#xA0;not&#xA0;have&#xA0;their&#xA0;licenses&#xA0;terminated&#xA0;so&#xA0;long&#xA0;as&#xA0;such<br/>
394parties&#xA0;remain&#xA0;in&#xA0;full&#xA0;compliance.<br/>
395<br/>
396&#xA0;&#xA0;5.&#xA0;You&#xA0;are&#xA0;not&#xA0;required&#xA0;to&#xA0;accept&#xA0;this&#xA0;License,&#xA0;since&#xA0;you&#xA0;have&#xA0;not<br/>
397signed&#xA0;it.&#xA0;&#xA0;However,&#xA0;nothing&#xA0;else&#xA0;grants&#xA0;you&#xA0;permission&#xA0;to&#xA0;modify&#xA0;or<br/>
398distribute&#xA0;the&#xA0;Program&#xA0;or&#xA0;its&#xA0;derivative&#xA0;works.&#xA0;&#xA0;These&#xA0;actions&#xA0;are<br/>
399prohibited&#xA0;by&#xA0;law&#xA0;if&#xA0;you&#xA0;do&#xA0;not&#xA0;accept&#xA0;this&#xA0;License.&#xA0;&#xA0;Therefore,&#xA0;by<br/>
400modifying&#xA0;or&#xA0;distributing&#xA0;the&#xA0;Program&#xA0;(or&#xA0;any&#xA0;work&#xA0;based&#xA0;on&#xA0;the<br/>
401Program),&#xA0;you&#xA0;indicate&#xA0;your&#xA0;acceptance&#xA0;of&#xA0;this&#xA0;License&#xA0;to&#xA0;do&#xA0;so,&#xA0;and<br/>
402all&#xA0;its&#xA0;terms&#xA0;and&#xA0;conditions&#xA0;for&#xA0;copying,&#xA0;distributing&#xA0;or&#xA0;modifying<br/>
403the&#xA0;Program&#xA0;or&#xA0;works&#xA0;based&#xA0;on&#xA0;it.<br/>
404<br/>
405&#xA0;&#xA0;6.&#xA0;Each&#xA0;time&#xA0;you&#xA0;redistribute&#xA0;the&#xA0;Program&#xA0;(or&#xA0;any&#xA0;work&#xA0;based&#xA0;on&#xA0;the<br/>
406Program),&#xA0;the&#xA0;recipient&#xA0;automatically&#xA0;receives&#xA0;a&#xA0;license&#xA0;from&#xA0;the<br/>
407original&#xA0;licensor&#xA0;to&#xA0;copy,&#xA0;distribute&#xA0;or&#xA0;modify&#xA0;the&#xA0;Program&#xA0;subject&#xA0;to<br/>
408these&#xA0;terms&#xA0;and&#xA0;conditions.&#xA0;&#xA0;You&#xA0;may&#xA0;not&#xA0;impose&#xA0;any&#xA0;further<br/>
409restrictions&#xA0;on&#xA0;the&#xA0;recipients'&#xA0;exercise&#xA0;of&#xA0;the&#xA0;rights&#xA0;granted&#xA0;herein.<br/>
410You&#xA0;are&#xA0;not&#xA0;responsible&#xA0;for&#xA0;enforcing&#xA0;compliance&#xA0;by&#xA0;third&#xA0;parties&#xA0;to<br/>
411this&#xA0;License.<br/>
412<br/>
413&#xA0;&#xA0;7.&#xA0;If,&#xA0;as&#xA0;a&#xA0;consequence&#xA0;of&#xA0;a&#xA0;court&#xA0;judgment&#xA0;or&#xA0;allegation&#xA0;of&#xA0;patent<br/>
414infringement&#xA0;or&#xA0;for&#xA0;any&#xA0;other&#xA0;reason&#xA0;(not&#xA0;limited&#xA0;to&#xA0;patent&#xA0;issues),<br/>
415conditions&#xA0;are&#xA0;imposed&#xA0;on&#xA0;you&#xA0;(whether&#xA0;by&#xA0;court&#xA0;order,&#xA0;agreement&#xA0;or<br/>
416otherwise)&#xA0;that&#xA0;contradict&#xA0;the&#xA0;conditions&#xA0;of&#xA0;this&#xA0;License,&#xA0;they&#xA0;do&#xA0;not<br/>
417excuse&#xA0;you&#xA0;from&#xA0;the&#xA0;conditions&#xA0;of&#xA0;this&#xA0;License.&#xA0;&#xA0;If&#xA0;you&#xA0;cannot<br/>
418distribute&#xA0;so&#xA0;as&#xA0;to&#xA0;satisfy&#xA0;simultaneously&#xA0;your&#xA0;obligations&#xA0;under&#xA0;this<br/>
419License&#xA0;and&#xA0;any&#xA0;other&#xA0;pertinent&#xA0;obligations,&#xA0;then&#xA0;as&#xA0;a&#xA0;consequence&#xA0;you<br/>
420may&#xA0;not&#xA0;distribute&#xA0;the&#xA0;Program&#xA0;at&#xA0;all.&#xA0;&#xA0;For&#xA0;example,&#xA0;if&#xA0;a&#xA0;patent<br/>
421license&#xA0;would&#xA0;not&#xA0;permit&#xA0;royalty-free&#xA0;redistribution&#xA0;of&#xA0;the&#xA0;Program&#xA0;by<br/>
422all&#xA0;those&#xA0;who&#xA0;receive&#xA0;copies&#xA0;directly&#xA0;or&#xA0;indirectly&#xA0;through&#xA0;you,&#xA0;then<br/>
423the&#xA0;only&#xA0;way&#xA0;you&#xA0;could&#xA0;satisfy&#xA0;both&#xA0;it&#xA0;and&#xA0;this&#xA0;License&#xA0;would&#xA0;be&#xA0;to<br/>
424refrain&#xA0;entirely&#xA0;from&#xA0;distribution&#xA0;of&#xA0;the&#xA0;Program.<br/>
425<br/>
426If&#xA0;any&#xA0;portion&#xA0;of&#xA0;this&#xA0;section&#xA0;is&#xA0;held&#xA0;invalid&#xA0;or&#xA0;unenforceable&#xA0;under<br/>
427any&#xA0;particular&#xA0;circumstance,&#xA0;the&#xA0;balance&#xA0;of&#xA0;the&#xA0;section&#xA0;is&#xA0;intended&#xA0;to<br/>
428apply&#xA0;and&#xA0;the&#xA0;section&#xA0;as&#xA0;a&#xA0;whole&#xA0;is&#xA0;intended&#xA0;to&#xA0;apply&#xA0;in&#xA0;other<br/>
429circumstances.<br/>
430<br/>
431It&#xA0;is&#xA0;not&#xA0;the&#xA0;purpose&#xA0;of&#xA0;this&#xA0;section&#xA0;to&#xA0;induce&#xA0;you&#xA0;to&#xA0;infringe&#xA0;any<br/>
432patents&#xA0;or&#xA0;other&#xA0;property&#xA0;right&#xA0;claims&#xA0;or&#xA0;to&#xA0;contest&#xA0;validity&#xA0;of&#xA0;any<br/>
433such&#xA0;claims;&#xA0;this&#xA0;section&#xA0;has&#xA0;the&#xA0;sole&#xA0;purpose&#xA0;of&#xA0;protecting&#xA0;the<br/>
434integrity&#xA0;of&#xA0;the&#xA0;free&#xA0;software&#xA0;distribution&#xA0;system,&#xA0;which&#xA0;is<br/>
435implemented&#xA0;by&#xA0;public&#xA0;license&#xA0;practices.&#xA0;&#xA0;Many&#xA0;people&#xA0;have&#xA0;made<br/>
436generous&#xA0;contributions&#xA0;to&#xA0;the&#xA0;wide&#xA0;range&#xA0;of&#xA0;software&#xA0;distributed<br/>
437through&#xA0;that&#xA0;system&#xA0;in&#xA0;reliance&#xA0;on&#xA0;consistent&#xA0;application&#xA0;of&#xA0;that<br/>
438system;&#xA0;it&#xA0;is&#xA0;up&#xA0;to&#xA0;the&#xA0;author/donor&#xA0;to&#xA0;decide&#xA0;if&#xA0;he&#xA0;or&#xA0;she&#xA0;is&#xA0;willing<br/>
439to&#xA0;distribute&#xA0;software&#xA0;through&#xA0;any&#xA0;other&#xA0;system&#xA0;and&#xA0;a&#xA0;licensee&#xA0;cannot<br/>
440impose&#xA0;that&#xA0;choice.<br/>
441<br/>
442This&#xA0;section&#xA0;is&#xA0;intended&#xA0;to&#xA0;make&#xA0;thoroughly&#xA0;clear&#xA0;what&#xA0;is&#xA0;believed&#xA0;to<br/>
443be&#xA0;a&#xA0;consequence&#xA0;of&#xA0;the&#xA0;rest&#xA0;of&#xA0;this&#xA0;License.<br/>
444<br/>
445&#xA0;&#xA0;8.&#xA0;If&#xA0;the&#xA0;distribution&#xA0;and/or&#xA0;use&#xA0;of&#xA0;the&#xA0;Program&#xA0;is&#xA0;restricted&#xA0;in<br/>
446certain&#xA0;countries&#xA0;either&#xA0;by&#xA0;patents&#xA0;or&#xA0;by&#xA0;copyrighted&#xA0;interfaces,&#xA0;the<br/>
447original&#xA0;copyright&#xA0;holder&#xA0;who&#xA0;places&#xA0;the&#xA0;Program&#xA0;under&#xA0;this&#xA0;License<br/>
448may&#xA0;add&#xA0;an&#xA0;explicit&#xA0;geographical&#xA0;distribution&#xA0;limitation&#xA0;excluding<br/>
449those&#xA0;countries,&#xA0;so&#xA0;that&#xA0;distribution&#xA0;is&#xA0;permitted&#xA0;only&#xA0;in&#xA0;or&#xA0;among<br/>
450countries&#xA0;not&#xA0;thus&#xA0;excluded.&#xA0;&#xA0;In&#xA0;such&#xA0;case,&#xA0;this&#xA0;License&#xA0;incorporates<br/>
451the&#xA0;limitation&#xA0;as&#xA0;if&#xA0;written&#xA0;in&#xA0;the&#xA0;body&#xA0;of&#xA0;this&#xA0;License.<br/>
452<br/>
453&#xA0;&#xA0;9.&#xA0;The&#xA0;Free&#xA0;Software&#xA0;Foundation&#xA0;may&#xA0;publish&#xA0;revised&#xA0;and/or&#xA0;new&#xA0;versions<br/>
454of&#xA0;the&#xA0;General&#xA0;Public&#xA0;License&#xA0;from&#xA0;time&#xA0;to&#xA0;time.&#xA0;&#xA0;Such&#xA0;new&#xA0;versions&#xA0;will<br/>
455be&#xA0;similar&#xA0;in&#xA0;spirit&#xA0;to&#xA0;the&#xA0;present&#xA0;version,&#xA0;but&#xA0;may&#xA0;differ&#xA0;in&#xA0;detail&#xA0;to<br/>
456address&#xA0;new&#xA0;problems&#xA0;or&#xA0;concerns.<br/>
457<br/>
458Each&#xA0;version&#xA0;is&#xA0;given&#xA0;a&#xA0;distinguishing&#xA0;version&#xA0;number.&#xA0;&#xA0;If&#xA0;the&#xA0;Program<br/>
459specifies&#xA0;a&#xA0;version&#xA0;number&#xA0;of&#xA0;this&#xA0;License&#xA0;which&#xA0;applies&#xA0;to&#xA0;it&#xA0;and&#xA0;&quot;any<br/>
460later&#xA0;version&quot;,&#xA0;you&#xA0;have&#xA0;the&#xA0;option&#xA0;of&#xA0;following&#xA0;the&#xA0;terms&#xA0;and&#xA0;conditions<br/>
461either&#xA0;of&#xA0;that&#xA0;version&#xA0;or&#xA0;of&#xA0;any&#xA0;later&#xA0;version&#xA0;published&#xA0;by&#xA0;the&#xA0;Free<br/>
462Software&#xA0;Foundation.&#xA0;&#xA0;If&#xA0;the&#xA0;Program&#xA0;does&#xA0;not&#xA0;specify&#xA0;a&#xA0;version&#xA0;number&#xA0;of<br/>
463this&#xA0;License,&#xA0;you&#xA0;may&#xA0;choose&#xA0;any&#xA0;version&#xA0;ever&#xA0;published&#xA0;by&#xA0;the&#xA0;Free&#xA0;Software<br/>
464Foundation.<br/>
465<br/>
466&#xA0;&#xA0;10.&#xA0;If&#xA0;you&#xA0;wish&#xA0;to&#xA0;incorporate&#xA0;parts&#xA0;of&#xA0;the&#xA0;Program&#xA0;into&#xA0;other&#xA0;free<br/>
467programs&#xA0;whose&#xA0;distribution&#xA0;conditions&#xA0;are&#xA0;different,&#xA0;write&#xA0;to&#xA0;the&#xA0;author<br/>
468to&#xA0;ask&#xA0;for&#xA0;permission.&#xA0;&#xA0;For&#xA0;software&#xA0;which&#xA0;is&#xA0;copyrighted&#xA0;by&#xA0;the&#xA0;Free<br/>
469Software&#xA0;Foundation,&#xA0;write&#xA0;to&#xA0;the&#xA0;Free&#xA0;Software&#xA0;Foundation;&#xA0;we&#xA0;sometimes<br/>
470make&#xA0;exceptions&#xA0;for&#xA0;this.&#xA0;&#xA0;Our&#xA0;decision&#xA0;will&#xA0;be&#xA0;guided&#xA0;by&#xA0;the&#xA0;two&#xA0;goals<br/>
471of&#xA0;preserving&#xA0;the&#xA0;free&#xA0;status&#xA0;of&#xA0;all&#xA0;derivatives&#xA0;of&#xA0;our&#xA0;free&#xA0;software&#xA0;and<br/>
472of&#xA0;promoting&#xA0;the&#xA0;sharing&#xA0;and&#xA0;reuse&#xA0;of&#xA0;software&#xA0;generally.<br/>
473<br/>
474&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;NO&#xA0;WARRANTY<br/>
475<br/>
476&#xA0;&#xA0;11.&#xA0;BECAUSE&#xA0;THE&#xA0;PROGRAM&#xA0;IS&#xA0;LICENSED&#xA0;FREE&#xA0;OF&#xA0;CHARGE,&#xA0;THERE&#xA0;IS&#xA0;NO&#xA0;WARRANTY<br/>
477FOR&#xA0;THE&#xA0;PROGRAM,&#xA0;TO&#xA0;THE&#xA0;EXTENT&#xA0;PERMITTED&#xA0;BY&#xA0;APPLICABLE&#xA0;LAW.&#xA0;&#xA0;EXCEPT&#xA0;WHEN<br/>
478OTHERWISE&#xA0;STATED&#xA0;IN&#xA0;WRITING&#xA0;THE&#xA0;COPYRIGHT&#xA0;HOLDERS&#xA0;AND/OR&#xA0;OTHER&#xA0;PARTIES<br/>
479PROVIDE&#xA0;THE&#xA0;PROGRAM&#xA0;&quot;AS&#xA0;IS&quot;&#xA0;WITHOUT&#xA0;WARRANTY&#xA0;OF&#xA0;ANY&#xA0;KIND,&#xA0;EITHER&#xA0;EXPRESSED<br/>
480OR&#xA0;IMPLIED,&#xA0;INCLUDING,&#xA0;BUT&#xA0;NOT&#xA0;LIMITED&#xA0;TO,&#xA0;THE&#xA0;IMPLIED&#xA0;WARRANTIES&#xA0;OF<br/>
481MERCHANTABILITY&#xA0;AND&#xA0;FITNESS&#xA0;FOR&#xA0;A&#xA0;PARTICULAR&#xA0;PURPOSE.&#xA0;&#xA0;THE&#xA0;ENTIRE&#xA0;RISK&#xA0;AS<br/>
482TO&#xA0;THE&#xA0;QUALITY&#xA0;AND&#xA0;PERFORMANCE&#xA0;OF&#xA0;THE&#xA0;PROGRAM&#xA0;IS&#xA0;WITH&#xA0;YOU.&#xA0;&#xA0;SHOULD&#xA0;THE<br/>
483PROGRAM&#xA0;PROVE&#xA0;DEFECTIVE,&#xA0;YOU&#xA0;ASSUME&#xA0;THE&#xA0;COST&#xA0;OF&#xA0;ALL&#xA0;NECESSARY&#xA0;SERVICING,<br/>
484REPAIR&#xA0;OR&#xA0;CORRECTION.<br/>
485<br/>
486&#xA0;&#xA0;12.&#xA0;IN&#xA0;NO&#xA0;EVENT&#xA0;UNLESS&#xA0;REQUIRED&#xA0;BY&#xA0;APPLICABLE&#xA0;LAW&#xA0;OR&#xA0;AGREED&#xA0;TO&#xA0;IN&#xA0;WRITING<br/>
487WILL&#xA0;ANY&#xA0;COPYRIGHT&#xA0;HOLDER,&#xA0;OR&#xA0;ANY&#xA0;OTHER&#xA0;PARTY&#xA0;WHO&#xA0;MAY&#xA0;MODIFY&#xA0;AND/OR<br/>
488REDISTRIBUTE&#xA0;THE&#xA0;PROGRAM&#xA0;AS&#xA0;PERMITTED&#xA0;ABOVE,&#xA0;BE&#xA0;LIABLE&#xA0;TO&#xA0;YOU&#xA0;FOR&#xA0;DAMAGES,<br/>
489INCLUDING&#xA0;ANY&#xA0;GENERAL,&#xA0;SPECIAL,&#xA0;INCIDENTAL&#xA0;OR&#xA0;CONSEQUENTIAL&#xA0;DAMAGES&#xA0;ARISING<br/>
490OUT&#xA0;OF&#xA0;THE&#xA0;USE&#xA0;OR&#xA0;INABILITY&#xA0;TO&#xA0;USE&#xA0;THE&#xA0;PROGRAM&#xA0;(INCLUDING&#xA0;BUT&#xA0;NOT&#xA0;LIMITED<br/>
491TO&#xA0;LOSS&#xA0;OF&#xA0;DATA&#xA0;OR&#xA0;DATA&#xA0;BEING&#xA0;RENDERED&#xA0;INACCURATE&#xA0;OR&#xA0;LOSSES&#xA0;SUSTAINED&#xA0;BY<br/>
492YOU&#xA0;OR&#xA0;THIRD&#xA0;PARTIES&#xA0;OR&#xA0;A&#xA0;FAILURE&#xA0;OF&#xA0;THE&#xA0;PROGRAM&#xA0;TO&#xA0;OPERATE&#xA0;WITH&#xA0;ANY&#xA0;OTHER<br/>
493PROGRAMS),&#xA0;EVEN&#xA0;IF&#xA0;SUCH&#xA0;HOLDER&#xA0;OR&#xA0;OTHER&#xA0;PARTY&#xA0;HAS&#xA0;BEEN&#xA0;ADVISED&#xA0;OF&#xA0;THE<br/>
494POSSIBILITY&#xA0;OF&#xA0;SUCH&#xA0;DAMAGES.<br/>
495<br/>
496&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;END&#xA0;OF&#xA0;TERMS&#xA0;AND&#xA0;CONDITIONS<br/>
497<br/>
498&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;How&#xA0;to&#xA0;Apply&#xA0;These&#xA0;Terms&#xA0;to&#xA0;Your&#xA0;New&#xA0;Programs<br/>
499<br/>
500&#xA0;&#xA0;If&#xA0;you&#xA0;develop&#xA0;a&#xA0;new&#xA0;program,&#xA0;and&#xA0;you&#xA0;want&#xA0;it&#xA0;to&#xA0;be&#xA0;of&#xA0;the&#xA0;greatest<br/>
501possible&#xA0;use&#xA0;to&#xA0;the&#xA0;public,&#xA0;the&#xA0;best&#xA0;way&#xA0;to&#xA0;achieve&#xA0;this&#xA0;is&#xA0;to&#xA0;make&#xA0;it<br/>
502free&#xA0;software&#xA0;which&#xA0;everyone&#xA0;can&#xA0;redistribute&#xA0;and&#xA0;change&#xA0;under&#xA0;these&#xA0;terms.<br/>
503<br/>
504&#xA0;&#xA0;To&#xA0;do&#xA0;so,&#xA0;attach&#xA0;the&#xA0;following&#xA0;notices&#xA0;to&#xA0;the&#xA0;program.&#xA0;&#xA0;It&#xA0;is&#xA0;safest<br/>
505to&#xA0;attach&#xA0;them&#xA0;to&#xA0;the&#xA0;start&#xA0;of&#xA0;each&#xA0;source&#xA0;file&#xA0;to&#xA0;most&#xA0;effectively<br/>
506convey&#xA0;the&#xA0;exclusion&#xA0;of&#xA0;warranty;&#xA0;and&#xA0;each&#xA0;file&#xA0;should&#xA0;have&#xA0;at&#xA0;least<br/>
507the&#xA0;&quot;copyright&quot;&#xA0;line&#xA0;and&#xA0;a&#xA0;pointer&#xA0;to&#xA0;where&#xA0;the&#xA0;full&#xA0;notice&#xA0;is&#xA0;found.<br/>
508<br/>
509&#xA0;&#xA0;&#xA0;&#xA0;&lt;one&#xA0;line&#xA0;to&#xA0;give&#xA0;the&#xA0;program's&#xA0;name&#xA0;and&#xA0;a&#xA0;brief&#xA0;idea&#xA0;of&#xA0;what&#xA0;it&#xA0;does.&gt;<br/>
510&#xA0;&#xA0;&#xA0;&#xA0;Copyright&#xA0;(C)&#xA0;&lt;year&gt;&#xA0;&#xA0;&lt;name&#xA0;of&#xA0;author&gt;<br/>
511<br/>
512&#xA0;&#xA0;&#xA0;&#xA0;This&#xA0;program&#xA0;is&#xA0;free&#xA0;software;&#xA0;you&#xA0;can&#xA0;redistribute&#xA0;it&#xA0;and/or&#xA0;modify<br/>
513&#xA0;&#xA0;&#xA0;&#xA0;it&#xA0;under&#xA0;the&#xA0;terms&#xA0;of&#xA0;the&#xA0;GNU&#xA0;General&#xA0;Public&#xA0;License&#xA0;as&#xA0;published&#xA0;by<br/>
514&#xA0;&#xA0;&#xA0;&#xA0;the&#xA0;Free&#xA0;Software&#xA0;Foundation;&#xA0;either&#xA0;version&#xA0;2&#xA0;of&#xA0;the&#xA0;License,&#xA0;or<br/>
515&#xA0;&#xA0;&#xA0;&#xA0;(at&#xA0;your&#xA0;option)&#xA0;any&#xA0;later&#xA0;version.<br/>
516<br/>
517&#xA0;&#xA0;&#xA0;&#xA0;This&#xA0;program&#xA0;is&#xA0;distributed&#xA0;in&#xA0;the&#xA0;hope&#xA0;that&#xA0;it&#xA0;will&#xA0;be&#xA0;useful,<br/>
518&#xA0;&#xA0;&#xA0;&#xA0;but&#xA0;WITHOUT&#xA0;ANY&#xA0;WARRANTY;&#xA0;without&#xA0;even&#xA0;the&#xA0;implied&#xA0;warranty&#xA0;of<br/>
519&#xA0;&#xA0;&#xA0;&#xA0;MERCHANTABILITY&#xA0;or&#xA0;FITNESS&#xA0;FOR&#xA0;A&#xA0;PARTICULAR&#xA0;PURPOSE.&#xA0;&#xA0;See&#xA0;the<br/>
520&#xA0;&#xA0;&#xA0;&#xA0;GNU&#xA0;General&#xA0;Public&#xA0;License&#xA0;for&#xA0;more&#xA0;details.<br/>
521<br/>
522&#xA0;&#xA0;&#xA0;&#xA0;You&#xA0;should&#xA0;have&#xA0;received&#xA0;a&#xA0;copy&#xA0;of&#xA0;the&#xA0;GNU&#xA0;General&#xA0;Public&#xA0;License&#xA0;along<br/>
523&#xA0;&#xA0;&#xA0;&#xA0;with&#xA0;this&#xA0;program;&#xA0;if&#xA0;not,&#xA0;write&#xA0;to&#xA0;the&#xA0;Free&#xA0;Software&#xA0;Foundation,&#xA0;Inc.,<br/>
524&#xA0;&#xA0;&#xA0;&#xA0;51&#xA0;Franklin&#xA0;Street,&#xA0;Fifth&#xA0;Floor,&#xA0;Boston,&#xA0;MA&#xA0;02110-1301&#xA0;USA.<br/>
525<br/>
526Also&#xA0;add&#xA0;information&#xA0;on&#xA0;how&#xA0;to&#xA0;contact&#xA0;you&#xA0;by&#xA0;electronic&#xA0;and&#xA0;paper&#xA0;mail.<br/>
527<br/>
528If&#xA0;the&#xA0;program&#xA0;is&#xA0;interactive,&#xA0;make&#xA0;it&#xA0;output&#xA0;a&#xA0;short&#xA0;notice&#xA0;like&#xA0;this<br/>
529when&#xA0;it&#xA0;starts&#xA0;in&#xA0;an&#xA0;interactive&#xA0;mode:<br/>
530<br/>
531&#xA0;&#xA0;&#xA0;&#xA0;Gnomovision&#xA0;version&#xA0;69,&#xA0;Copyright&#xA0;(C)&#xA0;year&#xA0;name&#xA0;of&#xA0;author<br/>
532&#xA0;&#xA0;&#xA0;&#xA0;Gnomovision&#xA0;comes&#xA0;with&#xA0;ABSOLUTELY&#xA0;NO&#xA0;WARRANTY;&#xA0;for&#xA0;details&#xA0;type&#xA0;`show&#xA0;w'.<br/>
533&#xA0;&#xA0;&#xA0;&#xA0;This&#xA0;is&#xA0;free&#xA0;software,&#xA0;and&#xA0;you&#xA0;are&#xA0;welcome&#xA0;to&#xA0;redistribute&#xA0;it<br/>
534&#xA0;&#xA0;&#xA0;&#xA0;under&#xA0;certain&#xA0;conditions;&#xA0;type&#xA0;`show&#xA0;c'&#xA0;for&#xA0;details.<br/>
535<br/>
536The&#xA0;hypothetical&#xA0;commands&#xA0;`show&#xA0;w'&#xA0;and&#xA0;`show&#xA0;c'&#xA0;should&#xA0;show&#xA0;the&#xA0;appropriate<br/>
537parts&#xA0;of&#xA0;the&#xA0;General&#xA0;Public&#xA0;License.&#xA0;&#xA0;Of&#xA0;course,&#xA0;the&#xA0;commands&#xA0;you&#xA0;use&#xA0;may<br/>
538be&#xA0;called&#xA0;something&#xA0;other&#xA0;than&#xA0;`show&#xA0;w'&#xA0;and&#xA0;`show&#xA0;c';&#xA0;they&#xA0;could&#xA0;even&#xA0;be<br/>
539mouse-clicks&#xA0;or&#xA0;menu&#xA0;items--whatever&#xA0;suits&#xA0;your&#xA0;program.<br/>
540<br/>
541You&#xA0;should&#xA0;also&#xA0;get&#xA0;your&#xA0;employer&#xA0;(if&#xA0;you&#xA0;work&#xA0;as&#xA0;a&#xA0;programmer)&#xA0;or&#xA0;your<br/>
542school,&#xA0;if&#xA0;any,&#xA0;to&#xA0;sign&#xA0;a&#xA0;&quot;copyright&#xA0;disclaimer&quot;&#xA0;for&#xA0;the&#xA0;program,&#xA0;if<br/>
543necessary.&#xA0;&#xA0;Here&#xA0;is&#xA0;a&#xA0;sample;&#xA0;alter&#xA0;the&#xA0;names:<br/>
544<br/>
545&#xA0;&#xA0;Yoyodyne,&#xA0;Inc.,&#xA0;hereby&#xA0;disclaims&#xA0;all&#xA0;copyright&#xA0;interest&#xA0;in&#xA0;the&#xA0;program<br/>
546&#xA0;&#xA0;`Gnomovision'&#xA0;(which&#xA0;makes&#xA0;passes&#xA0;at&#xA0;compilers)&#xA0;written&#xA0;by&#xA0;James&#xA0;Hacker.<br/>
547<br/>
548&#xA0;&#xA0;&lt;signature&#xA0;of&#xA0;Ty&#xA0;Coon&gt;,&#xA0;1&#xA0;April&#xA0;1989<br/>
549&#xA0;&#xA0;Ty&#xA0;Coon,&#xA0;President&#xA0;of&#xA0;Vice<br/>
550<br/>
551This&#xA0;General&#xA0;Public&#xA0;License&#xA0;does&#xA0;not&#xA0;permit&#xA0;incorporating&#xA0;your&#xA0;program&#xA0;into<br/>
552proprietary&#xA0;programs.&#xA0;&#xA0;If&#xA0;your&#xA0;program&#xA0;is&#xA0;a&#xA0;subroutine&#xA0;library,&#xA0;you&#xA0;may<br/>
553consider&#xA0;it&#xA0;more&#xA0;useful&#xA0;to&#xA0;permit&#xA0;linking&#xA0;proprietary&#xA0;applications&#xA0;with&#xA0;the<br/>
554library.&#xA0;&#xA0;If&#xA0;this&#xA0;is&#xA0;what&#xA0;you&#xA0;want&#xA0;to&#xA0;do,&#xA0;use&#xA0;the&#xA0;GNU&#xA0;Lesser&#xA0;General<br/>
555Public&#xA0;License&#xA0;instead&#xA0;of&#xA0;this&#xA0;License.<br/>
556</span></code>
557<hr/>Input File: omh/license.omh
558
559<hr/>
560<center><b><big><big><a name="3" id="3">3: The Nonlinear Constrained Kalman-Bucy Smoother</a>
561</big></big></b></center>
562<br/>
563<b><big><a name="3.a" id="3.a">3.a: Syntax</a></big></b>
564
565<br/>
566<code><font color="blue"><span style='white-space: nowrap'>[</span></font></code><i><span style='white-space: nowrap'>x_out</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>u_out</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>]&#xA0;=&#xA0;ckbs_nonlinear(</span></font></code><i><span style='white-space: nowrap'>f_fun</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>g_fun</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>h_fun</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;...<br/>
567&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></font></code><i><span style='white-space: nowrap'>max_itr</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>epsilon</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>x_in</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>z</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>qinv</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>rinv</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>level</span></i><code><font color="blue"><span style='white-space: nowrap'>)</span></font></code>
568
569<br/>
570<br/>
571<b><big><a name="3.b" id="3.b">3.b: Purpose</a></big></b>
572<br/>
573This routine minimizes the
574Kalman-Bucy smoother residual sum of squares objective
575for a general nonlinear model functions
576(in the case where the model functions are affine, the routine
577<a href="#4">4: <span style='white-space: nowrap'>ckbs_affine</span></a>
578 is more efficient).
579
580<br/>
581<br/>
582<b><big><a name="3.c" id="3.c">3.c: Notation</a></big></b>
583<br/>
584The Kalman-Bucy smoother residual sum of squares is defined by
585
586<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
587<mtable rowalign="center" ><mtr><mtd columnalign="right" >
588<mi mathvariant='italic'>S</mi>
589<mo stretchy="false">(</mo>
590<msub><mi mathvariant='italic'>x</mi>
591<mn>1</mn>
592</msub>
593<mo stretchy="false">,</mo>
594<mo stretchy="false">&#x02026;</mo>
595<mo stretchy="false">,</mo>
596<msub><mi mathvariant='italic'>x</mi>
597<mi mathvariant='italic'>N</mi>
598</msub>
599<mo stretchy="false">)</mo>
600</mtd><mtd columnalign="center" >
601<mo stretchy="false">=</mo>
602</mtd><mtd columnalign="left" >
603<munderover><mo displaystyle='true' largeop='true'>&#x02211;</mo>
604<mrow><mi mathvariant='italic'>k</mi>
605<mo stretchy="false">=</mo>
606<mn>1</mn>
607</mrow>
608<mi mathvariant='italic'>N</mi>
609</munderover>
610<msub><mi mathvariant='italic'>S</mi>
611<mi mathvariant='italic'>k</mi>
612</msub>
613<mo stretchy="false">(</mo>
614<msub><mi mathvariant='italic'>x</mi>
615<mi mathvariant='italic'>k</mi>
616</msub>
617<mo stretchy="false">,</mo>
618<msub><mi mathvariant='italic'>x</mi>
619<mrow><mi mathvariant='italic'>k</mi>
620<mn>-1</mn>
621</mrow>
622</msub>
623<mo stretchy="false">)</mo>
624</mtd></mtr><mtr><mtd columnalign="right" >
625<msub><mi mathvariant='italic'>S</mi>
626<mi mathvariant='italic'>k</mi>
627</msub>
628<mo stretchy="false">(</mo>
629<msub><mi mathvariant='italic'>x</mi>
630<mi mathvariant='italic'>k</mi>
631</msub>
632<mo stretchy="false">,</mo>
633<msub><mi mathvariant='italic'>x</mi>
634<mrow><mi mathvariant='italic'>k</mi>
635<mn>-1</mn>
636</mrow>
637</msub>
638<mo stretchy="false">)</mo>
639</mtd><mtd columnalign="center" >
640<mo stretchy="false">=</mo>
641</mtd><mtd columnalign="left" >
642<mfrac><mrow><mn>1</mn>
643</mrow>
644<mrow><mn>2</mn>
645</mrow>
646</mfrac>
647<mo stretchy="false">[</mo>
648<msub><mi mathvariant='italic'>z</mi>
649<mi mathvariant='italic'>k</mi>
650</msub>
651<mo stretchy="false">-</mo>
652<msub><mi mathvariant='italic'>h</mi>
653<mi mathvariant='italic'>k</mi>
654</msub>
655<mo stretchy="false">(</mo>
656<msub><mi mathvariant='italic'>x</mi>
657<mi mathvariant='italic'>k</mi>
658</msub>
659<mo stretchy="false">)</mo>
660<msup><mo stretchy="false">]</mo>
661<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>T</mi>
662</mstyle></mrow>
663</msup>
664<mo stretchy="false">*</mo>
665<msubsup><mi mathvariant='italic'>R</mi>
666<mi mathvariant='italic'>k</mi>
667<mrow><mn>-1</mn>
668</mrow>
669</msubsup>
670<mo stretchy="false">*</mo>
671<mo stretchy="false">[</mo>
672<msub><mi mathvariant='italic'>z</mi>
673<mi mathvariant='italic'>k</mi>
674</msub>
675<mo stretchy="false">-</mo>
676<msub><mi mathvariant='italic'>h</mi>
677<mi mathvariant='italic'>k</mi>
678</msub>
679<mo stretchy="false">(</mo>
680<msub><mi mathvariant='italic'>x</mi>
681<mi mathvariant='italic'>k</mi>
682</msub>
683<mo stretchy="false">)</mo>
684<mo stretchy="false">]</mo>
685</mtd></mtr><mtr><mtd columnalign="right" >
686</mtd><mtd columnalign="center" >
687<mo stretchy="false">+</mo>
688</mtd><mtd columnalign="left" >
689<mfrac><mrow><mn>1</mn>
690</mrow>
691<mrow><mn>2</mn>
692</mrow>
693</mfrac>
694<mo stretchy="false">[</mo>
695<msub><mi mathvariant='italic'>x</mi>
696<mi mathvariant='italic'>k</mi>
697</msub>
698<mo stretchy="false">-</mo>
699<msub><mi mathvariant='italic'>g</mi>
700<mi mathvariant='italic'>k</mi>
701</msub>
702<mo stretchy="false">(</mo>
703<msub><mi mathvariant='italic'>x</mi>
704<mrow><mi mathvariant='italic'>k</mi>
705<mn>-1</mn>
706</mrow>
707</msub>
708<mo stretchy="false">)</mo>
709<msup><mo stretchy="false">]</mo>
710<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>T</mi>
711</mstyle></mrow>
712</msup>
713<mo stretchy="false">*</mo>
714<msubsup><mi mathvariant='italic'>Q</mi>
715<mi mathvariant='italic'>k</mi>
716<mrow><mn>-1</mn>
717</mrow>
718</msubsup>
719<mo stretchy="false">*</mo>
720<mo stretchy="false">[</mo>
721<msub><mi mathvariant='italic'>x</mi>
722<mi mathvariant='italic'>k</mi>
723</msub>
724<mo stretchy="false">-</mo>
725<msub><mi mathvariant='italic'>g</mi>
726<mi mathvariant='italic'>k</mi>
727</msub>
728<mo stretchy="false">(</mo>
729<msub><mi mathvariant='italic'>x</mi>
730<mrow><mi mathvariant='italic'>k</mi>
731<mn>-1</mn>
732</mrow>
733</msub>
734<mo stretchy="false">)</mo>
735<mo stretchy="false">]</mo>
736</mtd></mtr><mtr><mtd columnalign="right" >
737</mtd></mtr></mtable>
738</mrow></math>
739
740where the matrices
741<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
742<msub><mi mathvariant='italic'>R</mi>
743<mi mathvariant='italic'>k</mi>
744</msub>
745</mrow></math>
746
747 and
748<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
749<msub><mi mathvariant='italic'>Q</mi>
750<mi mathvariant='italic'>k</mi>
751</msub>
752</mrow></math>
753
754 are
755symmetric positive definite and
756
757<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
758<msub><mi mathvariant='italic'>x</mi>
759<mn>0</mn>
760</msub>
761</mrow></math>
762
763 is the constant zero.
764Note that
765<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
766<msub><mi mathvariant='italic'>g</mi>
767<mn>1</mn>
768</msub>
769<mo stretchy="false">(</mo>
770<msub><mi mathvariant='italic'>x</mi>
771<mn>0</mn>
772</msub>
773<mo stretchy="false">)</mo>
774</mrow></math>
775
776 is the initial state estimate
777and
778<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
779<msub><mi mathvariant='italic'>Q</mi>
780<mn>1</mn>
781</msub>
782</mrow></math>
783
784 is the corresponding covariance.
785
786<br/>
787<br/>
788<b><big><a name="3.d" id="3.d">3.d: Problem</a></big></b>
789<br/>
790Our constrained Kalman-Bucy smoother problem is
791
792<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
793<mtable rowalign="center" ><mtr><mtd columnalign="right" >
794<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>minimize</mi>
795</mstyle></mrow>
796</mtd><mtd columnalign="left" >
797<mi mathvariant='italic'>S</mi>
798<mo stretchy="false">(</mo>
799<msub><mi mathvariant='italic'>x</mi>
800<mn>1</mn>
801</msub>
802<mo stretchy="false">,</mo>
803<mo stretchy="false">&#x02026;</mo>
804<mo stretchy="false">,</mo>
805<msub><mi mathvariant='italic'>x</mi>
806<mi mathvariant='italic'>N</mi>
807</msub>
808<mo stretchy="false">)</mo>
809</mtd><mtd columnalign="left" >
810<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>w</mi>
811<mo stretchy="false">.</mo>
812<mi mathvariant='normal'>r</mi>
813<mo stretchy="false">.</mo>
814<mi mathvariant='normal'>t</mi>
815<mo stretchy="false">.</mo>
816</mstyle></mrow>
817<mspace width='.3em'/>
818<msub><mi mathvariant='italic'>x</mi>
819<mn>1</mn>
820</msub>
821<mo stretchy="false">&#x02208;</mo>
822<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
823</mstyle></mrow>
824<mi mathvariant='italic'>n</mi>
825</msup>
826<mo stretchy="false">,</mo>
827<mo stretchy="false">&#x02026;</mo>
828<mo stretchy="false">,</mo>
829<msub><mi mathvariant='italic'>x</mi>
830<mi mathvariant='italic'>N</mi>
831</msub>
832<mo stretchy="false">&#x02208;</mo>
833<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
834</mstyle></mrow>
835<mi mathvariant='italic'>n</mi>
836</msup>
837</mtd></mtr><mtr><mtd columnalign="right" >
838<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>subject</mi>
839<mspace width='.3em'/>
840<mi mathvariant='normal'>to</mi>
841</mstyle></mrow>
842</mtd><mtd columnalign="left" >
843<msub><mi mathvariant='italic'>f</mi>
844<mi mathvariant='italic'>k</mi>
845</msub>
846<mo stretchy="false">(</mo>
847<msub><mi mathvariant='italic'>x</mi>
848<mi mathvariant='italic'>k</mi>
849</msub>
850<mo stretchy="false">)</mo>
851<mo stretchy="false">&#x02264;</mo>
852<mn>0</mn>
853</mtd><mtd columnalign="left" >
854<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>for</mi>
855</mstyle></mrow>
856<mspace width='.3em'/>
857<mi mathvariant='italic'>k</mi>
858<mo stretchy="false">=</mo>
859<mn>1</mn>
860<mo stretchy="false">,</mo>
861<mo stretchy="false">&#x02026;</mo>
862<mo stretchy="false">,</mo>
863<mi mathvariant='italic'>N</mi>
864</mtd></mtr></mtable>
865</mrow></math>
866
867<br/>
868<b><big><a name="3.e" id="3.e">3.e: First Order Conditions</a></big></b>
869<br/>
870A state sequence
871<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
872<mo stretchy="false">(</mo>
873<msub><mi mathvariant='italic'>x</mi>
874<mn>1</mn>
875</msub>
876<mo stretchy="false">,</mo>
877<mo stretchy="false">&#x02026;</mo>
878<mo stretchy="false">,</mo>
879<msub><mi mathvariant='italic'>x</mi>
880<mi mathvariant='italic'>N</mi>
881</msub>
882<mo stretchy="false">)</mo>
883</mrow></math>
884
885 is considered a solution
886if there is a Lagrange multiplier sequence
887<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
888<mo stretchy="false">(</mo>
889<msub><mi mathvariant='italic'>u</mi>
890<mn>1</mn>
891</msub>
892<mo stretchy="false">,</mo>
893<mo stretchy="false">&#x02026;</mo>
894<mo stretchy="false">,</mo>
895<msub><mi mathvariant='italic'>u</mi>
896<mi mathvariant='italic'>N</mi>
897</msub>
898<mo stretchy="false">)</mo>
899</mrow></math>
900
901 
902such that the following conditions are satisfied for
903
904<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
905<mi mathvariant='italic'>i</mi>
906<mo stretchy="false">=</mo>
907<mn>1</mn>
908<mo stretchy="false">,</mo>
909<mo stretchy="false">&#x02026;</mo>
910<mo stretchy="false">,</mo>
911<mo stretchy="false">&#x02113;</mo>
912</mrow></math>
913
914 and
915<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
916<mi mathvariant='italic'>k</mi>
917<mo stretchy="false">=</mo>
918<mn>1</mn>
919<mo stretchy="false">,</mo>
920<mo stretchy="false">&#x02026;</mo>
921<mo stretchy="false">,</mo>
922<mi mathvariant='italic'>N</mi>
923</mrow></math>
924
925:
926
927<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
928<mtable rowalign="center" ><mtr><mtd columnalign="right" >
929<msub><mi mathvariant='italic'>f</mi>
930<mi mathvariant='italic'>k</mi>
931</msub>
932<mo stretchy="false">(</mo>
933<msub><mi mathvariant='italic'>x</mi>
934<mi mathvariant='italic'>k</mi>
935</msub>
936<mo stretchy="false">)</mo>
937</mtd><mtd columnalign="center" >
938<mo stretchy="false">&#x02264;</mo>
939</mtd><mtd columnalign="left" >
940<mi mathvariant='normal'>&#x003B5;</mi>
941</mtd></mtr><mtr><mtd columnalign="right" >
942<mn>0</mn>
943</mtd><mtd columnalign="center" >
944<mo stretchy="false">&#x02264;</mo>
945</mtd><mtd columnalign="left" >
946<msub><mi mathvariant='italic'>u</mi>
947<mi mathvariant='italic'>k</mi>
948</msub>
949</mtd></mtr><mtr><mtd columnalign="right" >
950<mo stretchy="false">|</mo>
951<msubsup><mi mathvariant='italic'>u</mi>
952<mi mathvariant='italic'>k</mi>
953<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>T</mi>
954</mstyle></mrow>
955</msubsup>
956<mo stretchy="false">*</mo>
957<msub><mo stretchy="false">&#x02202;</mo>
958<mi mathvariant='italic'>k</mi>
959</msub>
960<msub><mi mathvariant='italic'>f</mi>
961<mi mathvariant='italic'>k</mi>
962</msub>
963<mo stretchy="false">(</mo>
964<msub><mi mathvariant='italic'>x</mi>
965<mi mathvariant='italic'>k</mi>
966</msub>
967<mo stretchy="false">)</mo>
968<mo stretchy="false">+</mo>
969<msub><mo stretchy="false">&#x02202;</mo>
970<mi mathvariant='italic'>k</mi>
971</msub>
972<mi mathvariant='italic'>S</mi>
973<mo stretchy="false">(</mo>
974<msub><mi mathvariant='italic'>x</mi>
975<mn>1</mn>
976</msub>
977<mo stretchy="false">,</mo>
978<mo stretchy="false">&#x02026;</mo>
979<mo stretchy="false">,</mo>
980<msub><mi mathvariant='italic'>x</mi>
981<mi mathvariant='italic'>N</mi>
982</msub>
983<mo stretchy="false">)</mo>
984<mo stretchy="false">|</mo>
985</mtd><mtd columnalign="center" >
986<mo stretchy="false">&#x02264;</mo>
987</mtd><mtd columnalign="left" >
988<mi mathvariant='normal'>&#x003B5;</mi>
989</mtd></mtr><mtr><mtd columnalign="right" >
990<mo stretchy="false">|</mo>
991<msub><mi mathvariant='italic'>f</mi>
992<mi mathvariant='italic'>k</mi>
993</msub>
994<mo stretchy="false">(</mo>
995<msub><mi mathvariant='italic'>x</mi>
996<mi mathvariant='italic'>k</mi>
997</msub>
998<msub><mo stretchy="false">)</mo>
999<mi mathvariant='italic'>i</mi>
1000</msub>
1001<mo stretchy="false">|</mo>
1002<mo stretchy="false">*</mo>
1003<mo stretchy="false">(</mo>
1004<msub><mi mathvariant='italic'>u</mi>
1005<mi mathvariant='italic'>k</mi>
1006</msub>
1007<msub><mo stretchy="false">)</mo>
1008<mi mathvariant='italic'>i</mi>
1009</msub>
1010</mtd><mtd columnalign="center" >
1011<mo stretchy="false">&#x02264;</mo>
1012</mtd><mtd columnalign="left" >
1013<mi mathvariant='normal'>&#x003B5;</mi>
1014</mtd></mtr></mtable>
1015</mrow></math>
1016
1017Here the notation
1018
1019<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1020<msub><mo stretchy="false">&#x02202;</mo>
1021<mi mathvariant='italic'>k</mi>
1022</msub>
1023</mrow></math>
1024
1025 is used for the partial derivative of
1026with respect to
1027<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1028<msub><mi mathvariant='italic'>x</mi>
1029<mi mathvariant='italic'>k</mi>
1030</msub>
1031</mrow></math>
1032
1033 and the notation
1034
1035<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1036<mo stretchy="false">(</mo>
1037<msub><mi mathvariant='italic'>u</mi>
1038<mi mathvariant='italic'>k</mi>
1039</msub>
1040<msub><mo stretchy="false">)</mo>
1041<mi mathvariant='italic'>i</mi>
1042</msub>
1043</mrow></math>
1044
1045 denotes the <i>i</i>-th component of
1046<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1047<msub><mi mathvariant='italic'>u</mi>
1048<mi mathvariant='italic'>k</mi>
1049</msub>
1050</mrow></math>
1051
1052.
1053
1054<br/>
1055<br/>
1056<b><big><a name="3.f" id="3.f">3.f: f_fun</a></big></b>
1057<br/>
1058The <code><font color="blue">ckbs_nonlinear</font></code> argument <i>f_fun</i> 
1059is a function that supports both of the
1060following syntaxes
1061<code><font color="blue"><span style='white-space: nowrap'><br/>
1062&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;[</span></font></code><i><span style='white-space: nowrap'>fk</span></i><code><font color="blue"><span style='white-space: nowrap'>]&#xA0;=&#xA0;feval(</span></font></code><i><span style='white-space: nowrap'>f_fun</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>k</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>xk</span></i><code><font color="blue"><span style='white-space: nowrap'>)<br/>
1063&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;[</span></font></code><i><span style='white-space: nowrap'>fk</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>Fk</span></i><code><font color="blue"><span style='white-space: nowrap'>]&#xA0;=&#xA0;feval(</span></font></code><i><span style='white-space: nowrap'>f_fun</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>k</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>xk</span></i><code><font color="blue"><span style='white-space: nowrap'>)<br/>
1064</span></font></code>In the case where there are no constraints,
1065one can use the following function for <i>f_fun</i>:
1066<code><font color='blue'><pre style='display:inline'> 
1067        [fk, Fk] = f_fun(k, xk)
1068        n  = size(xk, 1);
1069        fk = -1;
1070        Fk =  zeros(1, n);
1071        return
1072        end
1073</pre></font></code>
1074
1075
1076<br/>
1077<br/>
1078<b><a name="3.f.a" id="3.f.a">3.f.a: k</a></b>
1079<br/>
1080The <i>f_fun</i> argument <i>k</i> is an integer with
1081
1082<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1083<mn>1</mn>
1084<mo stretchy="false">&#x02264;</mo>
1085<mi mathvariant='italic'>k</mi>
1086<mo stretchy="false">&#x02264;</mo>
1087<mi mathvariant='italic'>N</mi>
1088</mrow></math>
1089
1090.
1091
1092<br/>
1093<br/>
1094<b><a name="3.f.b" id="3.f.b">3.f.b: xk</a></b>
1095<br/>
1096The <i>f_fun</i> argument <i>xk</i> is an column vector with
1097length
1098<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1099<mi mathvariant='italic'>n</mi>
1100</mrow></math>
1101
1102. It specifies the state vector at time index <i>k</i>
1103
1104<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1105<mi mathvariant='italic'>xk</mi>
1106<mo stretchy="false">=</mo>
1107<msub><mi mathvariant='italic'>x</mi>
1108<mi mathvariant='italic'>k</mi>
1109</msub>
1110</mrow></math>
1111
1112.
1113
1114<br/>
1115<br/>
1116<b><a name="3.f.c" id="3.f.c">3.f.c: fk</a></b>
1117<br/>
1118The <i>f_fun</i> result <i>fk</i> is an column vector with
1119length
1120<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1121<mo stretchy="false">&#x02113;</mo>
1122</mrow></math>
1123
1124 and
1125
1126<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1127<mi mathvariant='italic'>fk</mi>
1128<mo stretchy="false">=</mo>
1129<msub><mi mathvariant='italic'>f</mi>
1130<mi mathvariant='italic'>k</mi>
1131</msub>
1132<mo stretchy="false">(</mo>
1133<msub><mi mathvariant='italic'>x</mi>
1134<mi mathvariant='italic'>k</mi>
1135</msub>
1136<mo stretchy="false">)</mo>
1137</mrow></math>
1138
1139<br/>
1140<b><a name="3.f.d" id="3.f.d">3.f.d: Fk</a></b>
1141<br/>
1142If the <i>f_fun</i> result <i>Fk</i> is present in the syntax,
1143it is the
1144<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1145<mo stretchy="false">&#x02113;</mo>
1146<mo stretchy="false">&#x000D7;</mo>
1147<mi mathvariant='italic'>n</mi>
1148</mrow></math>
1149
1150 matrix given by
1151and
1152
1153<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1154<mi mathvariant='italic'>Fk</mi>
1155<mo stretchy="false">=</mo>
1156<msub><mo stretchy="false">&#x02202;</mo>
1157<mi mathvariant='italic'>k</mi>
1158</msub>
1159<msub><mi mathvariant='italic'>f</mi>
1160<mi mathvariant='italic'>k</mi>
1161</msub>
1162<mo stretchy="false">(</mo>
1163<msub><mi mathvariant='italic'>x</mi>
1164<mi mathvariant='italic'>k</mi>
1165</msub>
1166<mo stretchy="false">)</mo>
1167</mrow></math>
1168
1169<br/>
1170<b><big><a name="3.g" id="3.g">3.g: g_fun</a></big></b>
1171<br/>
1172The <code><font color="blue">ckbs_nonlinear</font></code> argument <i>g_fun</i> 
1173is a function that supports both of
1174the following syntaxes
1175<code><font color="blue"><span style='white-space: nowrap'><br/>
1176&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;[</span></font></code><i><span style='white-space: nowrap'>gk</span></i><code><font color="blue"><span style='white-space: nowrap'>]&#xA0;=&#xA0;feval(</span></font></code><i><span style='white-space: nowrap'>g_fun</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>k</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>xk1</span></i><code><font color="blue"><span style='white-space: nowrap'>)<br/>
1177&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;[</span></font></code><i><span style='white-space: nowrap'>gk</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>Gk</span></i><code><font color="blue"><span style='white-space: nowrap'>]&#xA0;=&#xA0;feval(</span></font></code><i><span style='white-space: nowrap'>g_fun</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>k</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>xk1</span></i><code><font color="blue"><span style='white-space: nowrap'>)<br/>
1178</span></font></code><br/>
1179<b><a name="3.g.a" id="3.g.a">3.g.a: k</a></b>
1180<br/>
1181The <i>g_fun</i> argument <i>k</i> is an integer with
1182
1183<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1184<mn>1</mn>
1185<mo stretchy="false">&#x02264;</mo>
1186<mi mathvariant='italic'>k</mi>
1187<mo stretchy="false">&#x02264;</mo>
1188<mi mathvariant='italic'>N</mi>
1189</mrow></math>
1190
1191.
1192The case
1193<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1194<mi mathvariant='italic'>k</mi>
1195<mo stretchy="false">=</mo>
1196<mn>1</mn>
1197</mrow></math>
1198
1199 serves to specify the initial state estimate.
1200
1201<br/>
1202<br/>
1203<b><a name="3.g.b" id="3.g.b">3.g.b: xk1</a></b>
1204<br/>
1205The <i>g_fun</i> argument <i>xk1</i> is an column vector with
1206length
1207<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1208<mi mathvariant='italic'>n</mi>
1209</mrow></math>
1210
1211. It specifies the state vector at time index <i>k</i>
1212
1213<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1214<mi mathvariant='italic'>xk</mi>
1215<mn>1</mn>
1216<mo stretchy="false">=</mo>
1217<msub><mi mathvariant='italic'>x</mi>
1218<mrow><mi mathvariant='italic'>k</mi>
1219<mn>-1</mn>
1220</mrow>
1221</msub>
1222</mrow></math>
1223
1224.
1225In the case
1226<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1227<mi mathvariant='italic'>k</mi>
1228<mo stretchy="false">=</mo>
1229<mn>1</mn>
1230</mrow></math>
1231
1232, the value of <i>xk1</i> does not matter.
1233
1234<br/>
1235<br/>
1236<b><a name="3.g.c" id="3.g.c">3.g.c: gk</a></b>
1237<br/>
1238The <i>g_fun</i> result <i>gk</i> is an column vector with
1239length
1240<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1241<mi mathvariant='italic'>n</mi>
1242</mrow></math>
1243
1244 and
1245
1246<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1247<mi mathvariant='italic'>gk</mi>
1248<mo stretchy="false">=</mo>
1249<msub><mi mathvariant='italic'>g</mi>
1250<mi mathvariant='italic'>k</mi>
1251</msub>
1252<mo stretchy="false">(</mo>
1253<msub><mi mathvariant='italic'>x</mi>
1254<mrow><mi mathvariant='italic'>k</mi>
1255<mn>-1</mn>
1256</mrow>
1257</msub>
1258<mo stretchy="false">)</mo>
1259</mrow></math>
1260
1261In the case
1262<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1263<mi mathvariant='italic'>k</mi>
1264<mo stretchy="false">=</mo>
1265<mn>1</mn>
1266</mrow></math>
1267
1268, the value of <i>gk</i> is the initial state
1269estimate at time index <i>k</i>.
1270
1271<br/>
1272<br/>
1273<b><a name="3.g.d" id="3.g.d">3.g.d: Gk</a></b>
1274<br/>
1275If the <i>g_fun</i> result <i>Gk</i> is present in the syntax,
1276it is the
1277<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1278<mi mathvariant='italic'>n</mi>
1279<mo stretchy="false">&#x000D7;</mo>
1280<mi mathvariant='italic'>n</mi>
1281</mrow></math>
1282
1283 matrix given by
1284and
1285
1286<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1287<mi mathvariant='italic'>Gk</mi>
1288<mo stretchy="false">=</mo>
1289<msub><mo stretchy="false">&#x02202;</mo>
1290<mrow><mi mathvariant='italic'>k</mi>
1291<mn>-1</mn>
1292</mrow>
1293</msub>
1294<msub><mi mathvariant='italic'>g</mi>
1295<mi mathvariant='italic'>k</mi>
1296</msub>
1297<mo stretchy="false">(</mo>
1298<msub><mi mathvariant='italic'>x</mi>
1299<mrow><mi mathvariant='italic'>k</mi>
1300<mn>-1</mn>
1301</mrow>
1302</msub>
1303<mo stretchy="false">)</mo>
1304</mrow></math>
1305
1306In the case
1307<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1308<mi mathvariant='italic'>k</mi>
1309<mo stretchy="false">=</mo>
1310<mn>1</mn>
1311</mrow></math>
1312
1313, the value of <i>Gk</i> is the zero matrix;
1314i.e.,
1315<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1316<msub><mi mathvariant='italic'>g</mi>
1317<mi mathvariant='italic'>k</mi>
1318</msub>
1319</mrow></math>
1320
1321 does not depend on the value of
1322<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1323<msub><mi mathvariant='italic'>x</mi>
1324<mrow><mi mathvariant='italic'>k</mi>
1325<mn>-1</mn>
1326</mrow>
1327</msub>
1328</mrow></math>
1329
1330.
1331
1332<br/>
1333<br/>
1334<b><big><a name="3.h" id="3.h">3.h: h_fun</a></big></b>
1335<br/>
1336The <code><font color="blue">ckbs_nonlinear</font></code> argument <i>h_fun</i> 
1337is a function that supports both of the
1338following syntaxes
1339<code><font color="blue"><span style='white-space: nowrap'><br/>
1340&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;[</span></font></code><i><span style='white-space: nowrap'>hk</span></i><code><font color="blue"><span style='white-space: nowrap'>]&#xA0;=&#xA0;feval(</span></font></code><i><span style='white-space: nowrap'>h_fun</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>k</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>xk</span></i><code><font color="blue"><span style='white-space: nowrap'>)<br/>
1341&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;[</span></font></code><i><span style='white-space: nowrap'>hk</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>Hk</span></i><code><font color="blue"><span style='white-space: nowrap'>]&#xA0;=&#xA0;feval(</span></font></code><i><span style='white-space: nowrap'>h_fun</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>k</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>xk</span></i><code><font color="blue"><span style='white-space: nowrap'>)<br/>
1342</span></font></code><br/>
1343<b><a name="3.h.a" id="3.h.a">3.h.a: k</a></b>
1344<br/>
1345The <i>h_fun</i> argument <i>k</i> is an integer with
1346
1347<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1348<mn>1</mn>
1349<mo stretchy="false">&#x02264;</mo>
1350<mi mathvariant='italic'>k</mi>
1351<mo stretchy="false">&#x02264;</mo>
1352<mi mathvariant='italic'>N</mi>
1353</mrow></math>
1354
1355.
1356
1357<br/>
1358<br/>
1359<b><a name="3.h.b" id="3.h.b">3.h.b: xk</a></b>
1360<br/>
1361The <i>h_fun</i> argument <i>xk</i> is an column vector with
1362length
1363<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1364<mi mathvariant='italic'>n</mi>
1365</mrow></math>
1366
1367. It specifies the state vector at time index <i>k</i>
1368
1369<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1370<mi mathvariant='italic'>xk</mi>
1371<mo stretchy="false">=</mo>
1372<msub><mi mathvariant='italic'>x</mi>
1373<mi mathvariant='italic'>k</mi>
1374</msub>
1375</mrow></math>
1376
1377.
1378
1379<br/>
1380<br/>
1381<b><a name="3.h.c" id="3.h.c">3.h.c: hk</a></b>
1382<br/>
1383The <i>h_fun</i> result <i>hk</i> is an column vector with
1384length
1385<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1386<mi mathvariant='italic'>m</mi>
1387</mrow></math>
1388
1389 and
1390
1391<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1392<mi mathvariant='italic'>hk</mi>
1393<mo stretchy="false">=</mo>
1394<msub><mi mathvariant='italic'>h</mi>
1395<mi mathvariant='italic'>k</mi>
1396</msub>
1397<mo stretchy="false">(</mo>
1398<msub><mi mathvariant='italic'>x</mi>
1399<mi mathvariant='italic'>k</mi>
1400</msub>
1401<mo stretchy="false">)</mo>
1402</mrow></math>
1403
1404<br/>
1405<b><a name="3.h.d" id="3.h.d">3.h.d: Hk</a></b>
1406<br/>
1407If the <i>h_fun</i> result <i>Hk</i> is present in the syntax,
1408it is the
1409<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1410<mi mathvariant='italic'>m</mi>
1411<mo stretchy="false">&#x000D7;</mo>
1412<mi mathvariant='italic'>n</mi>
1413</mrow></math>
1414
1415 matrix given by
1416and
1417
1418<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1419<mi mathvariant='italic'>Hk</mi>
1420<mo stretchy="false">=</mo>
1421<msub><mo stretchy="false">&#x02202;</mo>
1422<mi mathvariant='italic'>k</mi>
1423</msub>
1424<msub><mi mathvariant='italic'>h</mi>
1425<mi mathvariant='italic'>k</mi>
1426</msub>
1427<mo stretchy="false">(</mo>
1428<msub><mi mathvariant='italic'>x</mi>
1429<mi mathvariant='italic'>k</mi>
1430</msub>
1431<mo stretchy="false">)</mo>
1432</mrow></math>
1433
1434<br/>
1435<b><big><a name="3.i" id="3.i">3.i: max_itr</a></big></b>
1436<br/>
1437The integer scalar <i>max_itr</i> specifies the maximum number of
1438iterations of the algorithm to execute. It must be greater than or
1439equal to zero. Note that if it is zero, the first row of the
1440<a href="#3.r">3.r: <span style='white-space: nowrap'>info</span></a>
1441 return value will still be computed.
1442This can be useful for deciding what is a good value for the argument
1443<a href="#3.j">3.j: <span style='white-space: nowrap'>epsilon</span></a>
1444.
1445
1446<br/>
1447<br/>
1448<b><big><a name="3.j" id="3.j">3.j: epsilon</a></big></b>
1449<br/>
1450The <code><font color="blue">ckbs_nonlinear</font></code> argument <i>epsilon</i> is a positive scalar.
1451It specifies the convergence
1452criteria value; i.e.,
1453
1454<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1455<mi mathvariant='normal'>&#x003B5;</mi>
1456<mo stretchy="false">=</mo>
1457<mi mathvariant='italic'>epsilon</mi>
1458</mrow></math>
1459
1460In some instances, <code><font color="blue">ckbs_nonlinear</font></code> will return after printing
1461a warning without convergence; see <a href="#3.r">3.r: <span style='white-space: nowrap'>info</span></a>
1462.
1463
1464<br/>
1465<br/>
1466<b><big><a name="3.k" id="3.k">3.k: x_in</a></big></b>
1467<br/>
1468The <code><font color="blue">ckbs_nonlinear</font></code> argument <i>x_in</i> 
1469is a two dimensional array with size
1470<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1471<mi mathvariant='italic'>n</mi>
1472<mo stretchy="false">&#x000D7;</mo>
1473<mi mathvariant='italic'>N</mi>
1474</mrow></math>
1475
1476.
1477It specifies a sequence of state values; i.e.,
1478for
1479<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1480<mi mathvariant='italic'>k</mi>
1481<mo stretchy="false">=</mo>
1482<mn>1</mn>
1483<mo stretchy="false">,</mo>
1484<mo stretchy="false">&#x02026;</mo>
1485<mo stretchy="false">,</mo>
1486<mi mathvariant='italic'>N</mi>
1487</mrow></math>
1488
1489
1490
1491<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1492<mi mathvariant='italic'>x</mi>
1493<mo stretchy="false">_</mo>
1494<mi mathvariant='italic'>in</mi>
1495<mo stretchy="false">(</mo>
1496<mo stretchy="false">:</mo>
1497<mo stretchy="false">,</mo>
1498<mi mathvariant='italic'>k</mi>
1499<mo stretchy="false">)</mo>
1500<mo stretchy="false">=</mo>
1501<msub><mi mathvariant='italic'>x</mi>
1502<mi mathvariant='italic'>k</mi>
1503</msub>
1504</mrow></math>
1505
1506The closer the initial state sequence is to the solution
1507the faster, and more likely, the <code><font color="blue">ckbs_nonlinear</font></code> will converge.
1508The initial state sequence need not be feasible; i.e.
1509it is not necessary that
1510
1511<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1512<msub><mi mathvariant='italic'>f</mi>
1513<mi mathvariant='italic'>k</mi>
1514</msub>
1515<mo stretchy="false">(</mo>
1516<msub><mi mathvariant='italic'>x</mi>
1517<mi mathvariant='italic'>k</mi>
1518</msub>
1519<mo stretchy="false">)</mo>
1520<mo stretchy="false">&#x02264;</mo>
1521<mn>0</mn>
1522</mrow></math>
1523
1524for all
1525<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1526<mi mathvariant='italic'>k</mi>
1527</mrow></math>
1528
1529.
1530
1531<br/>
1532<br/>
1533<b><big><a name="3.l" id="3.l">3.l: z</a></big></b>
1534<br/>
1535The <code><font color="blue">ckbs_nonlinear</font></code> argument <i>z</i> is a two dimensional array
1536with size
1537<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1538<mi mathvariant='italic'>m</mi>
1539<mo stretchy="false">&#x000D7;</mo>
1540<mi mathvariant='italic'>N</mi>
1541</mrow></math>
1542
1543.
1544It specifies the sequence of measurement vectors; i.e.,
1545for
1546<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1547<mi mathvariant='italic'>k</mi>
1548<mo stretchy="false">=</mo>
1549<mn>1</mn>
1550<mo stretchy="false">,</mo>
1551<mo stretchy="false">&#x02026;</mo>
1552<mo stretchy="false">,</mo>
1553<mi mathvariant='italic'>N</mi>
1554</mrow></math>
1555
1556
1557
1558<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1559<mi mathvariant='italic'>z</mi>
1560<mo stretchy="false">(</mo>
1561<mo stretchy="false">:</mo>
1562<mo stretchy="false">,</mo>
1563<mi mathvariant='italic'>k</mi>
1564<mo stretchy="false">)</mo>
1565<mo stretchy="false">=</mo>
1566<msub><mi mathvariant='italic'>z</mi>
1567<mi mathvariant='italic'>k</mi>
1568</msub>
1569</mrow></math>
1570
1571<br/>
1572<b><big><a name="3.m" id="3.m">3.m: qinv</a></big></b>
1573<br/>
1574The <code><font color="blue">ckbs_nonlinear</font></code> argument <i>qinv</i> 
1575is a three dimensional array
1576with size
1577<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1578<mi mathvariant='italic'>n</mi>
1579<mo stretchy="false">&#x000D7;</mo>
1580<mi mathvariant='italic'>n</mi>
1581<mo stretchy="false">&#x000D7;</mo>
1582<mi mathvariant='italic'>N</mi>
1583</mrow></math>
1584
1585.
1586It specifies the inverse of the variance of the measurement noise; i.e.,
1587for
1588<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1589<mi mathvariant='italic'>k</mi>
1590<mo stretchy="false">=</mo>
1591<mn>1</mn>
1592<mo stretchy="false">,</mo>
1593<mo stretchy="false">&#x02026;</mo>
1594<mo stretchy="false">,</mo>
1595<mi mathvariant='italic'>N</mi>
1596</mrow></math>
1597
1598
1599
1600<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1601<mi mathvariant='italic'>qinv</mi>
1602<mo stretchy="false">(</mo>
1603<mo stretchy="false">:</mo>
1604<mo stretchy="false">,</mo>
1605<mo stretchy="false">:</mo>
1606<mo stretchy="false">,</mo>
1607<mi mathvariant='italic'>k</mi>
1608<mo stretchy="false">)</mo>
1609<mo stretchy="false">=</mo>
1610<msubsup><mi mathvariant='italic'>Q</mi>
1611<mi mathvariant='italic'>k</mi>
1612<mrow><mn>-1</mn>
1613</mrow>
1614</msubsup>
1615</mrow></math>
1616
1617In the case
1618<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1619<mi mathvariant='italic'>k</mi>
1620<mo stretchy="false">=</mo>
1621<mn>1</mn>
1622</mrow></math>
1623
1624, the value of
1625<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1626<msub><mi mathvariant='italic'>Q</mi>
1627<mi mathvariant='italic'>k</mi>
1628</msub>
1629</mrow></math>
1630
1631 is the variance
1632of the initial state estimate (see <a href="#3.g">3.g: <span style='white-space: nowrap'>g_fun</span></a>
1633.
1634
1635<br/>
1636<br/>
1637<b><big><a name="3.n" id="3.n">3.n: rinv</a></big></b>
1638<br/>
1639The <code><font color="blue">ckbs_nonlinear</font></code> argument <i>rinv</i> 
1640is a three dimensional array,
1641with size
1642<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1643<mi mathvariant='italic'>m</mi>
1644<mo stretchy="false">&#x000D7;</mo>
1645<mi mathvariant='italic'>m</mi>
1646<mo stretchy="false">&#x000D7;</mo>
1647<mi mathvariant='italic'>N</mi>
1648</mrow></math>
1649
1650.
1651it specifies the inverse of the variance of the transition noise; i.e.,
1652for
1653<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1654<mi mathvariant='italic'>k</mi>
1655<mo stretchy="false">=</mo>
1656<mn>1</mn>
1657<mo stretchy="false">,</mo>
1658<mo stretchy="false">&#x02026;</mo>
1659<mo stretchy="false">,</mo>
1660<mi mathvariant='italic'>N</mi>
1661</mrow></math>
1662
1663
1664
1665<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1666<mi mathvariant='italic'>rinv</mi>
1667<mo stretchy="false">(</mo>
1668<mo stretchy="false">:</mo>
1669<mo stretchy="false">,</mo>
1670<mo stretchy="false">:</mo>
1671<mo stretchy="false">,</mo>
1672<mi mathvariant='italic'>k</mi>
1673<mo stretchy="false">)</mo>
1674<mo stretchy="false">=</mo>
1675<msubsup><mi mathvariant='italic'>R</mi>
1676<mi mathvariant='italic'>k</mi>
1677<mrow><mn>-1</mn>
1678</mrow>
1679</msubsup>
1680</mrow></math>
1681
1682It is ok to signify a missing data value by setting the corresponding
1683row and column of <i>rinv</i> to zero. This also enables use
1684to interpolate the state vector
1685<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1686<msub><mi mathvariant='italic'>x</mi>
1687<mi mathvariant='italic'>k</mi>
1688</msub>
1689</mrow></math>
1690
1691 to points where
1692there are no measurements.
1693
1694<br/>
1695<br/>
1696<b><big><a name="3.o" id="3.o">3.o: level</a></big></b>
1697<br/>
1698The integer scalar <i>level</i> specifies the level of tracing to do.
1699If <code><font color="blue"></font></code><i><span style='white-space: nowrap'>level</span></i><code><font color="blue"><span style='white-space: nowrap'>&#xA0;==&#xA0;0</span></font></code>, no tracing is done.
1700If <code><font color="blue"></font></code><i><span style='white-space: nowrap'>level</span></i><code><font color="blue"><span style='white-space: nowrap'>&#xA0;&gt;=&#xA0;1</span></font></code>, the row index <i>q</i>
1701and the correspond row of <i>info</i> 
1702are printed as soon as soon as they are computed.
1703If <code><font color="blue"></font></code><i><span style='white-space: nowrap'>level</span></i><code><font color="blue"><span style='white-space: nowrap'>&#xA0;&gt;=&#xA0;2</span></font></code>, a check of the derivative calculations
1704is printed before the calculations start. In this case, control will
1705return to the keyboard so that you can print values, continue,
1706or abort the calculation.
1707
1708<br/>
1709<br/>
1710<b><big><a name="3.p" id="3.p">3.p: x_out</a></big></b>
1711<br/>
1712The result <i>x_out</i> 
1713is a two dimensional array with size
1714<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1715<mi mathvariant='italic'>n</mi>
1716<mo stretchy="false">&#x000D7;</mo>
1717<mi mathvariant='italic'>N</mi>
1718</mrow></math>
1719
1720.
1721
1722<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1723<mo stretchy="false">(</mo>
1724<msub><mi mathvariant='italic'>x</mi>
1725<mn>1</mn>
1726</msub>
1727<mo stretchy="false">,</mo>
1728<mo stretchy="false">&#x02026;</mo>
1729<mo stretchy="false">,</mo>
1730<msub><mi mathvariant='italic'>x</mi>
1731<mi mathvariant='italic'>N</mi>
1732</msub>
1733<mo stretchy="false">)</mo>
1734</mrow></math>
1735
1736.
1737It contains an approximation for the optimal sequence; i.e.,
1738for
1739<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1740<mi mathvariant='italic'>k</mi>
1741<mo stretchy="false">=</mo>
1742<mn>1</mn>
1743<mo stretchy="false">,</mo>
1744<mo stretchy="false">&#x02026;</mo>
1745<mo stretchy="false">,</mo>
1746<mi mathvariant='italic'>N</mi>
1747</mrow></math>
1748
1749
1750
1751<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1752<mi mathvariant='italic'>x</mi>
1753<mo stretchy="false">_</mo>
1754<mi mathvariant='italic'>out</mi>
1755<mo stretchy="false">(</mo>
1756<mo stretchy="false">:</mo>
1757<mo stretchy="false">,</mo>
1758<mi mathvariant='italic'>k</mi>
1759<mo stretchy="false">)</mo>
1760<mo stretchy="false">=</mo>
1761<msub><mi mathvariant='italic'>x</mi>
1762<mi mathvariant='italic'>k</mi>
1763</msub>
1764</mrow></math>
1765
1766<br/>
1767<b><big><a name="3.q" id="3.q">3.q: u_out</a></big></b>
1768<br/>
1769The result <i>u_out</i> 
1770is a two dimensional array with size %
1771<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1772<mo stretchy="false">&#x02113;</mo>
1773<mo stretchy="false">&#x000D7;</mo>
1774<mi mathvariant='italic'>N</mi>
1775</mrow></math>
1776
1777.
1778It contains the Lagrange multiplier sequence
1779corresponding to <i>x_out</i>; i.e.,
1780for
1781<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1782<mi mathvariant='italic'>k</mi>
1783<mo stretchy="false">=</mo>
1784<mn>1</mn>
1785<mo stretchy="false">,</mo>
1786<mo stretchy="false">&#x02026;</mo>
1787<mo stretchy="false">,</mo>
1788<mi mathvariant='italic'>N</mi>
1789</mrow></math>
1790
1791
1792
1793<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1794<mi mathvariant='italic'>u</mi>
1795<mo stretchy="false">_</mo>
1796<mi mathvariant='italic'>out</mi>
1797<mo stretchy="false">(</mo>
1798<mo stretchy="false">:</mo>
1799<mo stretchy="false">,</mo>
1800<mi mathvariant='italic'>k</mi>
1801<mo stretchy="false">)</mo>
1802<mo stretchy="false">=</mo>
1803<msub><mi mathvariant='italic'>u</mi>
1804<mi mathvariant='italic'>k</mi>
1805</msub>
1806</mrow></math>
1807
1808The pair <i>x_out</i>, <i>u_out</i> satisfy the
1809<a href="#3.e">3.e: <span style='white-space: nowrap'>first&#xA0;order&#xA0;conditions</span></a>
1810.
1811
1812<br/>
1813<br/>
1814<b><big><a name="3.r" id="3.r">3.r: info</a></big></b>
1815<br/>
1816The result <i>info</i> is a matrix with each row corresponding
1817to an iteration of the algorithm.
1818Note that <code><font color="blue">ckbs_nonlinear</font></code> has satisfied the convergence condition if
1819and only if
1820<code><font color="blue"><span style='white-space: nowrap'><br/>
1821&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;all(&#xA0;</span></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>(end,&#xA0;1:3)&#xA0;&lt;=&#xA0;</span></font></code><i><span style='white-space: nowrap'>epsilon</span></i><code><font color="blue"><span style='white-space: nowrap'>&#xA0;)<br/>
1822</span></font></code><code><span style='white-space: nowrap'><br/>
1823<br/>
1824</span></code>We use
1825<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1826<mo stretchy="false">{</mo>
1827<msubsup><mi mathvariant='italic'>x</mi>
1828<mi mathvariant='italic'>k</mi>
1829<mi mathvariant='italic'>q</mi>
1830</msubsup>
1831<mo stretchy="false">}</mo>
1832</mrow></math>
1833
1834 to denote the state vector sequence at the
1835at the end of iteration
1836<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1837<mi mathvariant='italic'>q</mi>
1838<mn>-1</mn>
1839</mrow></math>
1840
1841 and
1842
1843<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1844<mo stretchy="false">{</mo>
1845<msubsup><mi mathvariant='italic'>u</mi>
1846<mi mathvariant='italic'>k</mi>
1847<mi mathvariant='italic'>q</mi>
1848</msubsup>
1849<mo stretchy="false">}</mo>
1850</mrow></math>
1851
1852 for the dual vector sequence (
1853<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1854<msubsup><mi mathvariant='italic'>u</mi>
1855<mi mathvariant='italic'>k</mi>
1856<mi mathvariant='italic'>q</mi>
1857</msubsup>
1858<mo stretchy="false">&#x02265;</mo>
1859<mn>0</mn>
1860</mrow></math>
1861
1862).
1863
1864<br/>
1865<br/>
1866<b><a name="3.r.a" id="3.r.a">3.r.a: max_f</a></b>
1867<br/>
1868The value
1869<code><font color="blue"><span style='white-space: nowrap'><br/>
1870&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></font></code><i><span style='white-space: nowrap'>max_f</span></i><code><font color="blue"><span style='white-space: nowrap'>(</span></font></code><i><span style='white-space: nowrap'>q</span></i><code><font color="blue"><span style='white-space: nowrap'>)&#xA0;=&#xA0;</span></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>(</span></font></code><i><span style='white-space: nowrap'>q</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;1)<br/>
1871</span></font></code>is a bound on the constraint functions
1872at the end of iteration <i>q-1</i>. To be specific
1873
1874<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1875<mi mathvariant='italic'>max</mi>
1876<mo stretchy="false">_</mo>
1877<mi mathvariant='italic'>f</mi>
1878<mo stretchy="false">(</mo>
1879<mi mathvariant='italic'>q</mi>
1880<mo stretchy="false">)</mo>
1881<mo stretchy="false">=</mo>
1882<munder><mi>max</mi>
1883<mrow><mi mathvariant='italic'>i</mi>
1884<mo stretchy="false">,</mo>
1885<mi mathvariant='italic'>k</mi>
1886</mrow>
1887</munder>
1888<mo stretchy="false">[</mo>
1889<msub><mi mathvariant='italic'>f</mi>
1890<mi mathvariant='italic'>k</mi>
1891</msub>
1892<mo stretchy="false">(</mo>
1893<msubsup><mi mathvariant='italic'>x</mi>
1894<mi mathvariant='italic'>k</mi>
1895<mi mathvariant='italic'>q</mi>
1896</msubsup>
1897<msub><mo stretchy="false">)</mo>
1898<mi mathvariant='italic'>i</mi>
1899</msub>
1900<mo stretchy="false">]</mo>
1901</mrow></math>
1902
1903where the maximum is with respect to
1904
1905<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1906<mi mathvariant='italic'>i</mi>
1907<mo stretchy="false">=</mo>
1908<mn>1</mn>
1909<mo stretchy="false">,</mo>
1910<mo stretchy="false">&#x02026;</mo>
1911<mo stretchy="false">,</mo>
1912<mo stretchy="false">&#x02113;</mo>
1913</mrow></math>
1914
1915 and
1916
1917<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1918<mi mathvariant='italic'>k</mi>
1919<mo stretchy="false">=</mo>
1920<mn>1</mn>
1921<mo stretchy="false">,</mo>
1922<mo stretchy="false">&#x02026;</mo>
1923<mo stretchy="false">,</mo>
1924<mi mathvariant='italic'>N</mi>
1925</mrow></math>
1926
1927.
1928Convergence requires this value to be less than or equal <i>epsilon</i>.
1929
1930<br/>
1931<br/>
1932<b><a name="3.r.b" id="3.r.b">3.r.b: max_grad</a></b>
1933<br/>
1934The value
1935<code><font color="blue"><span style='white-space: nowrap'><br/>
1936&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></font></code><i><span style='white-space: nowrap'>max_grad</span></i><code><font color="blue"><span style='white-space: nowrap'>(</span></font></code><i><span style='white-space: nowrap'>q)</span></i><code><font color="blue"><span style='white-space: nowrap'>&#xA0;=&#xA0;</span></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>(</span></font></code><i><span style='white-space: nowrap'>q</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;2)<br/>
1937</span></font></code>is a bound on the partial of the
1938Lagrangian with respect to
1939<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
1940<mi mathvariant='italic'>x</mi>
1941</mrow></math>
1942
1943
1944at the end of iteration <i>q-1</i>. To be specific
1945
1946<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
1947<mi mathvariant='italic'>max</mi>
1948<mo stretchy="false">_</mo>
1949<mi mathvariant='italic'>grad</mi>
1950<mo stretchy="false">(</mo>
1951<mi mathvariant='italic'>q</mi>
1952<mo stretchy="false">)</mo>
1953<mo stretchy="false">=</mo>
1954<munder><mi>max</mi>
1955<mrow><mi mathvariant='italic'>j</mi>
1956<mo stretchy="false">,</mo>
1957<mi mathvariant='italic'>k</mi>
1958</mrow>
1959</munder>
1960<msub><mrow><mo stretchy="true">[</mo><mrow><mrow><mo stretchy="true">|</mo><mrow><mo stretchy="false">(</mo>
1961<msubsup><mi mathvariant='italic'>u</mi>
1962<mi mathvariant='italic'>k</mi>
1963<mi mathvariant='italic'>q</mi>
1964</msubsup>
1965<msup><mo stretchy="false">)</mo>
1966<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>T</mi>
1967</mstyle></mrow>
1968</msup>
1969<mo stretchy="false">*</mo>
1970<msub><mo stretchy="false">&#x02202;</mo>
1971<mi mathvariant='italic'>k</mi>
1972</msub>
1973<msub><mi mathvariant='italic'>f</mi>
1974<mi mathvariant='italic'>k</mi>
1975</msub>
1976<mo stretchy="false">(</mo>
1977<msubsup><mi mathvariant='italic'>x</mi>
1978<mi mathvariant='italic'>k</mi>
1979<mi mathvariant='italic'>q</mi>
1980</msubsup>
1981<mo stretchy="false">)</mo>
1982<mo stretchy="false">+</mo>
1983<msub><mo stretchy="false">&#x02202;</mo>
1984<mi mathvariant='italic'>k</mi>
1985</msub>
1986<mi mathvariant='italic'>S</mi>
1987<mo stretchy="false">(</mo>
1988<msubsup><mi mathvariant='italic'>x</mi>
1989<mn>1</mn>
1990<mi mathvariant='italic'>q</mi>
1991</msubsup>
1992<mo stretchy="false">,</mo>
1993<mo stretchy="false">&#x02026;</mo>
1994<mo stretchy="false">,</mo>
1995<msubsup><mi mathvariant='italic'>x</mi>
1996<mi mathvariant='italic'>N</mi>
1997<mi mathvariant='italic'>q</mi>
1998</msubsup>
1999<mo stretchy="false">)</mo>
2000</mrow><mo stretchy="true">|</mo></mrow>
2001</mrow><mo stretchy="true">]</mo></mrow>
2002<mi mathvariant='italic'>j</mi>
2003</msub>
2004</mrow></math>
2005
2006where the maximum is with respect to
2007
2008<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2009<mi mathvariant='italic'>j</mi>
2010<mo stretchy="false">=</mo>
2011<mn>1</mn>
2012<mo stretchy="false">,</mo>
2013<mo stretchy="false">&#x02026;</mo>
2014<mo stretchy="false">,</mo>
2015<mi mathvariant='italic'>n</mi>
2016</mrow></math>
2017
2018 and
2019
2020<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2021<mi mathvariant='italic'>k</mi>
2022<mo stretchy="false">=</mo>
2023<mn>1</mn>
2024<mo stretchy="false">,</mo>
2025<mo stretchy="false">&#x02026;</mo>
2026<mo stretchy="false">,</mo>
2027<mi mathvariant='italic'>N</mi>
2028</mrow></math>
2029
2030.
2031This value should converge to zero.
2032
2033<br/>
2034<br/>
2035<b><a name="3.r.c" id="3.r.c">3.r.c: max_fu</a></b>
2036<br/>
2037The value
2038<code><font color="blue"><span style='white-space: nowrap'><br/>
2039&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></font></code><i><span style='white-space: nowrap'>max_fu</span></i><code><font color="blue"><span style='white-space: nowrap'>&#xA0;=&#xA0;</span></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>(</span></font></code><i><span style='white-space: nowrap'>q</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;3)<br/>
2040</span></font></code>is a bound on
2041the complementarity conditions
2042at the end of iteration <i>q-1</i>. To be specific
2043
2044<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
2045<mi mathvariant='italic'>max</mi>
2046<mo stretchy="false">_</mo>
2047<mi mathvariant='italic'>fu</mi>
2048<mo stretchy="false">(</mo>
2049<mi mathvariant='italic'>q</mi>
2050<mo stretchy="false">)</mo>
2051<mo stretchy="false">=</mo>
2052<munder><mi>max</mi>
2053<mrow><mi mathvariant='italic'>i</mi>
2054<mo stretchy="false">,</mo>
2055<mi mathvariant='italic'>k</mi>
2056</mrow>
2057</munder>
2058<mo stretchy="false">[</mo>
2059<mo stretchy="false">|</mo>
2060<msub><mi mathvariant='italic'>f</mi>
2061<mi mathvariant='italic'>k</mi>
2062</msub>
2063<mo stretchy="false">(</mo>
2064<msub><mi mathvariant='italic'>x</mi>
2065<mi mathvariant='italic'>k</mi>
2066</msub>
2067<msub><mo stretchy="false">)</mo>
2068<mi mathvariant='italic'>i</mi>
2069</msub>
2070<mo stretchy="false">|</mo>
2071<mo stretchy="false">*</mo>
2072<mo stretchy="false">(</mo>
2073<msub><mi mathvariant='italic'>u</mi>
2074<mi mathvariant='italic'>k</mi>
2075</msub>
2076<msub><mo stretchy="false">)</mo>
2077<mi mathvariant='italic'>i</mi>
2078</msub>
2079<mo stretchy="false">]</mo>
2080</mrow></math>
2081
2082where the maximum is with respect to
2083
2084<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2085<mi mathvariant='italic'>i</mi>
2086<mo stretchy="false">=</mo>
2087<mn>1</mn>
2088<mo stretchy="false">,</mo>
2089<mo stretchy="false">&#x02026;</mo>
2090<mo stretchy="false">,</mo>
2091<mo stretchy="false">&#x02113;</mo>
2092</mrow></math>
2093
2094 and
2095
2096<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2097<mi mathvariant='italic'>k</mi>
2098<mo stretchy="false">=</mo>
2099<mn>1</mn>
2100<mo stretchy="false">,</mo>
2101<mo stretchy="false">&#x02026;</mo>
2102<mo stretchy="false">,</mo>
2103<mi mathvariant='italic'>N</mi>
2104</mrow></math>
2105
2106.
2107This value should converge to be less than or equal zero.
2108
2109<br/>
2110<br/>
2111<b><a name="3.r.d" id="3.r.d">3.r.d: obj_cur</a></b>
2112<br/>
2113The value
2114<code><font color="blue"><span style='white-space: nowrap'><br/>
2115&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></font></code><i><span style='white-space: nowrap'>obj_cur</span></i><code><font color="blue"><span style='white-space: nowrap'>(</span></font></code><i><span style='white-space: nowrap'>q</span></i><code><font color="blue"><span style='white-space: nowrap'>)&#xA0;=&#xA0;</span></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>(</span></font></code><i><span style='white-space: nowrap'>q</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;4)<br/>
2116</span></font></code>is the value of the objective function
2117at the end of
2118<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2119<mi mathvariant='italic'>q</mi>
2120<mn>-1</mn>
2121</mrow></math>
2122
2123; i.e.,
2124
2125<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
2126<mi mathvariant='italic'>obj</mi>
2127<mo stretchy="false">_</mo>
2128<mi mathvariant='italic'>cur</mi>
2129<mo stretchy="false">(</mo>
2130<mi mathvariant='italic'>q</mi>
2131<mo stretchy="false">)</mo>
2132<mo stretchy="false">=</mo>
2133<mi mathvariant='italic'>S</mi>
2134<mo stretchy="false">(</mo>
2135<msubsup><mi mathvariant='italic'>x</mi>
2136<mn>1</mn>
2137<mi mathvariant='italic'>q</mi>
2138</msubsup>
2139<mo stretchy="false">,</mo>
2140<mo stretchy="false">&#x02026;</mo>
2141<mo stretchy="false">,</mo>
2142<msubsup><mi mathvariant='italic'>x</mi>
2143<mi mathvariant='italic'>k</mi>
2144<mi mathvariant='italic'>q</mi>
2145</msubsup>
2146<mo stretchy="false">)</mo>
2147</mrow></math>
2148
2149(Note that
2150<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2151<mi mathvariant='italic'>info</mi>
2152<mo stretchy="false">(</mo>
2153<mn>1</mn>
2154<mo stretchy="false">,</mo>
2155<mn>4</mn>
2156<mo stretchy="false">)</mo>
2157</mrow></math>
2158
2159 is the value of the objective
2160corresponding to <i>x_in</i>.
2161
2162<br/>
2163<br/>
2164<b><a name="3.r.e" id="3.r.e">3.r.e: lambda</a></b>
2165<br/>
2166The value
2167<code><font color="blue"><span style='white-space: nowrap'><br/>
2168&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></font></code><i><span style='white-space: nowrap'>lambda</span></i><code><font color="blue"><span style='white-space: nowrap'>(</span></font></code><i><span style='white-space: nowrap'>q</span></i><code><font color="blue"><span style='white-space: nowrap'>)&#xA0;=&#xA0;</span></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>(</span></font></code><i><span style='white-space: nowrap'>q</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;5)<br/>
2169</span></font></code>is the line search step size used during
2170iteration
2171<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2172<mi mathvariant='italic'>q</mi>
2173<mn>-1</mn>
2174</mrow></math>
2175
2176 of <code><font color="blue">ckbs_nonlinear</font></code>.
2177If the problem is nearly affine (if the affine approximate is accurate)
2178this will be one.
2179Much small step sizes indicate highly non-affine problems
2180(with the exception that <code><font color="blue"></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>(1,&#xA0;5)</span></font></code> is always zero).
2181
2182<br/>
2183<br/>
2184<b><a name="3.r.f" id="3.r.f">3.r.f: lam_aff</a></b>
2185<br/>
2186The value
2187<code><font color="blue"><span style='white-space: nowrap'><br/>
2188&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></font></code><i><span style='white-space: nowrap'>lam_aff</span></i><code><font color="blue"><span style='white-space: nowrap'>(</span></font></code><i><span style='white-space: nowrap'>q</span></i><code><font color="blue"><span style='white-space: nowrap'>)&#xA0;=&#xA0;</span></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>(</span></font></code><i><span style='white-space: nowrap'>q</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;6)<br/>
2189</span></font></code>is the minimum line search step size
2190while solving the affine sub-problem that corresponds to
2191iteration
2192<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2193<mi mathvariant='italic'>q</mi>
2194<mn>-1</mn>
2195</mrow></math>
2196
2197 of <code><font color="blue">ckbs_nonlinear</font></code>.
2198If the sub-problem solution is working well,
2199this will be one.
2200Much small step sizes indicate the sub-problem solution is not working well.
2201
2202
2203
2204<br/>
2205<br/>
2206<b><a name="3.r.g" id="3.r.g">3.r.g: Penalty Parameter</a></b>
2207<br/>
2208The exact penalty function
2209
2210<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
2211<mi mathvariant='italic'>S</mi>
2212<mo stretchy="false">(</mo>
2213<msub><mi mathvariant='italic'>x</mi>
2214<mn>1</mn>
2215</msub>
2216<mo stretchy="false">,</mo>
2217<mo stretchy="false">&#x02026;</mo>
2218<mo stretchy="false">,</mo>
2219<msub><mi mathvariant='italic'>x</mi>
2220<mi mathvariant='italic'>k</mi>
2221</msub>
2222<mo stretchy="false">)</mo>
2223<mo stretchy="false">+</mo>
2224<mi mathvariant='normal'>&#x003B1;</mi>
2225<munderover><mo displaystyle='true' largeop='true'>&#x02211;</mo>
2226<mrow><mi mathvariant='italic'>k</mi>
2227<mo stretchy="false">=</mo>
2228<mn>1</mn>
2229</mrow>
2230<mi mathvariant='italic'>N</mi>
2231</munderover>
2232<munderover><mo displaystyle='true' largeop='true'>&#x02211;</mo>
2233<mrow><mi mathvariant='italic'>i</mi>
2234<mo stretchy="false">=</mo>
2235<mn>1</mn>
2236</mrow>
2237<mo stretchy="false">&#x02113;</mo>
2238</munderover>
2239<mi>max</mi>
2240<mo stretchy="false">[</mo>
2241<msub><mi mathvariant='italic'>f</mi>
2242<mi mathvariant='italic'>k</mi>
2243</msub>
2244<mo stretchy="false">(</mo>
2245<msub><mi mathvariant='italic'>x</mi>
2246<mi mathvariant='italic'>k</mi>
2247</msub>
2248<msub><mo stretchy="false">)</mo>
2249<mi mathvariant='italic'>i</mi>
2250</msub>
2251<mo stretchy="false">,</mo>
2252<mn>0</mn>
2253<mo stretchy="false">]</mo>
2254</mrow></math>
2255
2256is used to determine the line search step size.
2257The value <code><font color="blue"></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>(</span></font></code><i><span style='white-space: nowrap'>a</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;7)</span></font></code> is the penalty parameter
2258
2259<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2260<mi mathvariant='normal'>&#x003B1;</mi>
2261</mrow></math>
2262
2263 during iteration
2264<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2265<mi mathvariant='italic'>q</mi>
2266<mn>-1</mn>
2267</mrow></math>
2268
2269 of <code><font color="blue">ckbs_nonlinear</font></code>.
2270
2271<br/>
2272<br/>
2273<b><big><a name="3.s" id="3.s">3.s: Example</a></big></b>
2274
2275
2276<br/>
2277<br/>
2278<b><a name="3.s.a" id="3.s.a">3.s.a: Simple</a></b>
2279<br/>
2280The file <a href="#3.1">3.1: <span style='white-space: nowrap'>nonlinear_ok_simple.m</span></a>
2281 contains a simple example
2282and test of <code><font color="blue">ckbs_nonlinear</font></code>.
2283It returns true if <code><font color="blue">ckbs_nonlinear</font></code> passes the tests
2284and false otherwise.
2285
2286<br/>
2287<br/>
2288<b><a name="3.s.b" id="3.s.b">3.s.b: Box Constraints</a></b>
2289<br/>
2290The file <a href="#3.2">3.2: <span style='white-space: nowrap'>nonlinear_ok_box.m</span></a>
2291 contains an example
2292and test of <code><font color="blue">ckbs_nonlinear</font></code> with box constraints
2293and a nonlinear measurement function.
2294It returns true if <code><font color="blue">ckbs_nonlinear</font></code> passes the tests
2295and false otherwise.
2296
2297<br/>
2298<br/>
2299<b><a name="3.s.c" id="3.s.c">3.s.c: Nonlinear Constraints</a></b>
2300<br/>
2301The file <a href="#3.3">3.3: <span style='white-space: nowrap'>nonlinear_ok_sin.m</span></a>
2302 contains an example
2303and test of <code><font color="blue">ckbs_nonlinear</font></code> with a sine wave constraint
2304and a nonlinear measurement function.
2305It returns true if <code><font color="blue">ckbs_nonlinear</font></code> passes the tests
2306and false otherwise.
2307
2308
2309
2310<hr/>Input File: src/ckbs_nonlinear.m
2311
2312<hr/>
2313 
2314
2315
2316<center><b><big><big><a name="3.1" id="3.1">3.1: Simple ckbs_nonlinear Example and Test</a>
2317</big></big></b></center>
2318<br/>
2319<b><big><a name="3.1.a" id="3.1.a">3.1.a: Call Back Functions</a></big></b>
2320
2321<table><tr><td align='left'  valign='top'>
2322
2323<a href="#3.1.1">3.1.1: nonlinear_ok_simple_f.m</a></td><td>
2324Example Constraint Function: nonlinear_ok_simple_f</td></tr>
2325<tr><td>
2326
2327<a href="#3.1.2">3.1.2: nonlinear_ok_simple_g.m</a></td><td>
2328Example Transition Function: nonlinear_ok_simple_g</td></tr>
2329<tr><td>
2330
2331<a href="#3.1.3">3.1.3: nonlinear_ok_simple_h.m</a></td><td>
2332Example Measurement Function: nonlinear_ok_simple_h</td></tr>
2333<tr><td>
2334
2335</td></tr>
2336</table>
2337<br/>
2338<b><big><a name="3.1.b" id="3.1.b">3.1.b: Source Code</a></big></b>
2339
2340 <code><font color='blue'><pre style='display:inline'> 
2341function [ok] = nonlinear_ok_simple()
2342% --------------------------------------------------------------------
2343max_itr = 20;      % maximum number of iterations
2344epsilon = 1e-5;    % convergence criteria
2345N       = 3;       % number of time points
2346ell     = 2;       % number of constraints
2347m       = 1;       % number of measurements per time point
2348n       = 3;       % number of state vector components per time point
2349sigma   = 1;       % variance of measurement noise
2350level   = 0;       % level of tracing in ckbs_nonlinear
2351%
2352% simulated true trajectory
2353x_true  = ones(n, 1) * (1 : N);
2354%
2355% simulate measurement noise
2356e_true  = zeros(m, N);
2357%
2358% initial x vector
2359x_in = zeros(n, N);
2360%
2361% --------------------------------------------------------------------
2362if m &gt; n
2363        error('nonlinear_ok_simple: m &gt; n');
2364end
2365if ell &gt; n
2366        error('nonlinear_ok_simple: ell &gt; n');
2367end
2368%
2369global nonlinear_ok_simple_m
2370global nonlinear_ok_simple_ell
2371global nonlinear_ok_simple_N
2372%
2373nonlinear_ok_simple_m   = m;
2374nonlinear_ok_simple_ell = ell;
2375nonlinear_ok_simple_N   = N;
2376%
2377% measurement variances
2378rinv    = zeros(m, m, N);
2379qinv    = zeros(n, n, N);
2380qinvk   = eye(n) / (sigma * sigma);
2381rinvk   = eye(m) / (sigma * sigma);
2382z       = zeros(m, N);
2383for k = 1 : N
2384        xk           = x_true(:, k);
2385        ek           = e_true(:, k);
2386        hk           = nonlinear_ok_simple_h(k, xk);
2387        z(:, k)      = hk + ek;
2388        qinv(:,:, k) = qinvk;
2389        rinv(:,:, k) = rinvk;
2390end
2391%
2392% pass the maximum state value to f
2393global nonlinear_ok_simple_f_max
2394nonlinear_ok_simple_f_max = (N - .5) * ones(m, 1);
2395%
2396% ----------------------------------------------------------------------
2397f_fun = 'nonlinear_ok_simple_f';
2398g_fun = 'nonlinear_ok_simple_g';
2399h_fun = 'nonlinear_ok_simple_h';
2400[x_out, u_out, info] = ckbs_nonlinear( ...
2401        f_fun,    ...
2402        g_fun,    ...
2403        h_fun,    ...
2404        max_itr,  ...
2405        epsilon,  ...
2406        x_in,     ...
2407        z,        ...
2408        qinv,     ...
2409        rinv,     ...
2410        level     ...
2411);
2412% ----------------------------------------------------------------------
2413ok     = size(info, 1) &lt;= max_itr;
2414f_out  = zeros(ell, N);
2415g_out  = zeros(n,   N);
2416h_out  = zeros(m,   N);
2417df_out = zeros(ell, n, N);
2418dg_out = zeros(n, n,   N);
2419dh_out = zeros(m, n,   N);
2420xk1    = zeros(n, 1);
2421for k = 1 : N
2422        xk       = x_out(:, k);
2423        uk       = u_out(:, k);
2424        [fk, Fk] = feval(f_fun, k, xk);
2425        [gk, Gk] = feval(g_fun, k, xk1);
2426        [hk, Hk] = feval(h_fun, k, xk);
2427        %
2428        ok       = ok &amp; all( fk &lt;= epsilon);
2429        ok       = ok &amp; all( abs(fk) .* uk &lt;= epsilon );
2430        %
2431        f_out(:, k) = fk - Fk * xk;
2432        g_out(:, k) = gk - Gk * xk1;
2433        h_out(:, k) = hk - Hk * xk;
2434        df_out(:,:, k) = Fk;
2435        dg_out(:,:, k) = Gk;
2436        dh_out(:,:, k) = Hk;
2437        xk1 = xk;
2438end
2439ok   = ok &amp; all( all( u_out &gt;= 0 ) );
2440grad  = ckbs_sumsq_grad(x_out, z, g_out, h_out, dg_out, dh_out, qinv, rinv);
2441for k = 1 : N
2442        uk  = u_out(:, k);
2443        Fk  = df_out(:,:, k);
2444        dk  = grad(:, k);
2445        %
2446        ok  = ok &amp; all( abs(Fk' * uk + dk) &lt;= epsilon );
2447end
2448return
2449end
2450</pre></font></code>
2451 
2452
2453<hr/>Input File: test/nonlinear_ok_simple.m
2454
2455<hr/>
2456 
2457
2458
2459
2460<center><b><big><big><a name="3.1.1" id="3.1.1">3.1.1: Example Constraint Function: nonlinear_ok_simple_f</a>
2461</big></big></b></center>
2462<br/>
2463<b><big><a name="3.1.1.a" id="3.1.1.a">3.1.1.a: Source Code</a></big></b>
2464
2465 <code><font color='blue'><pre style='display:inline'> 
2466function [fk, Fk] = nonlinear_ok_simple_f(k, xk)
2467        global nonlinear_ok_simple_N
2468        global nonlinear_ok_simple_ell
2469        %
2470        N   = nonlinear_ok_simple_N;
2471        ell = nonlinear_ok_simple_ell;
2472        n   = size(xk, 1);
2473        % xk(1:ell)^2 &lt;= N - .5
2474        fk = xk(1:ell).^2 - (N - .5);
2475        Fk = zeros(ell, n);
2476        for i = 1 : ell
2477                Fk(i, i) = 2 * xk(i);
2478        end
2479        return
2480end
2481</pre></font></code>
2482 
2483
2484<hr/>Input File: test/nonlinear_ok_simple_f.m
2485
2486<hr/>
2487 
2488
2489
2490
2491<center><b><big><big><a name="3.1.2" id="3.1.2">3.1.2: Example Transition Function: nonlinear_ok_simple_g</a>
2492</big></big></b></center>
2493<br/>
2494<b><big><a name="3.1.2.a" id="3.1.2.a">3.1.2.a: Source Code</a></big></b>
2495
2496 <code><font color='blue'><pre style='display:inline'> 
2497function [gk, Gk] = nonlinear_ok_simple_g(k, xk1)
2498        n  = size(xk1, 1);
2499        if k == 1
2500                Gk = zeros(n, n);
2501                gk = Gk * xk1 + 1;
2502        else
2503                Gk = eye(n);
2504                gk = Gk * xk1 + 1;
2505        end
2506        return
2507end
2508</pre></font></code>
2509 
2510
2511<hr/>Input File: test/nonlinear_ok_simple_g.m
2512
2513<hr/>
2514 
2515
2516
2517
2518<center><b><big><big><a name="3.1.3" id="3.1.3">3.1.3: Example Measurement Function: nonlinear_ok_simple_h</a>
2519</big></big></b></center>
2520<br/>
2521<b><big><a name="3.1.3.a" id="3.1.3.a">3.1.3.a: Source Code</a></big></b>
2522
2523 <code><font color='blue'><pre style='display:inline'> 
2524function [hk, Hk] = nonlinear_ok_simple_h(k, xk)
2525        global nonlinear_ok_simple_m
2526        %
2527        n        = size(xk, 1);
2528        m        = nonlinear_ok_simple_m;
2529        hk       = xk(1:m);
2530        Hk       = [ eye(m) , zeros(m, n-m) ];
2531        return
2532end
2533</pre></font></code>
2534 
2535
2536<hr/>Input File: test/nonlinear_ok_simple_h.m
2537
2538<hr/>
2539 
2540
2541
2542<center><b><big><big><a name="3.2" id="3.2">3.2: ckbs_nonlinear Box Constrained Tracking Example and Test</a>
2543</big></big></b></center>
2544<br/>
2545<b><big><a name="3.2.a" id="3.2.a">3.2.a: Syntax</a></big></b>
2546
2547<br/>
2548<code><font color="blue"><span style='white-space: nowrap'>[</span></font></code><i><span style='white-space: nowrap'>ok</span></i><code><font color="blue"><span style='white-space: nowrap'>]&#xA0;=&#xA0;nonlinear_ok_box(</span></font></code><i><span style='white-space: nowrap'>draw_plot</span></i><code><font color="blue"><span style='white-space: nowrap'>)</span></font></code>
2549
2550<br/>
2551<br/>
2552<b><big><a name="3.2.b" id="3.2.b">3.2.b: draw_plot</a></big></b>
2553<br/>
2554If this argument is true, a plot is drawn showing the results
2555and the <code><font color="blue">nonlinear_ok_box.out</font></code> file is written for use with
2556the program <code><font color="blue">nonlinear_ok_box.r</font></code>.
2557
2558<br/>
2559<br/>
2560<b><big><a name="3.2.c" id="3.2.c">3.2.c: ok</a></big></b>
2561<br/>
2562If the return value <i>ok</i> is true, the test passed,
2563otherwise the test failed.
2564
2565<br/>
2566<br/>
2567<b><big><a name="3.2.d" id="3.2.d">3.2.d: State Vector</a></big></b>
2568
2569<table><tr><td align='left'  valign='top'>
2570
2571
2572<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2573<mi mathvariant='italic'>x</mi>
2574<mn>1</mn>
2575<mo stretchy="false">(</mo>
2576<mi mathvariant='italic'>t</mi>
2577<mo stretchy="false">)</mo>
2578</mrow></math>
2579
2580  </td><td align='left'  valign='top'>
2581 first component of velocity  </td></tr><tr><td align='left'  valign='top'>
2582
2583
2584<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2585<mi mathvariant='italic'>x</mi>
2586<mn>2</mn>
2587<mo stretchy="false">(</mo>
2588<mi mathvariant='italic'>t</mi>
2589<mo stretchy="false">)</mo>
2590</mrow></math>
2591
2592  </td><td align='left'  valign='top'>
2593 first component of position  </td></tr><tr><td align='left'  valign='top'>
2594
2595
2596<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2597<mi mathvariant='italic'>x</mi>
2598<mn>3</mn>
2599<mo stretchy="false">(</mo>
2600<mi mathvariant='italic'>t</mi>
2601<mo stretchy="false">)</mo>
2602</mrow></math>
2603
2604  </td><td align='left'  valign='top'>
2605 second component of velocity  </td></tr><tr><td align='left'  valign='top'>
2606
2607
2608<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2609<mi mathvariant='italic'>x</mi>
2610<mn>4</mn>
2611<mo stretchy="false">(</mo>
2612<mi mathvariant='italic'>t</mi>
2613<mo stretchy="false">)</mo>
2614</mrow></math>
2615
2616  </td><td align='left'  valign='top'>
2617 second component of position 
2618</td></tr>
2619</table>
2620<br/>
2621<b><big><a name="3.2.e" id="3.2.e">3.2.e: Measurement Vector</a></big></b>
2622
2623<table><tr><td align='left'  valign='top'>
2624
2625
2626<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2627<mi mathvariant='italic'>z</mi>
2628<mn>1</mn>
2629<mo stretchy="false">(</mo>
2630<mi mathvariant='italic'>t</mi>
2631<mo stretchy="false">)</mo>
2632</mrow></math>
2633
2634  </td><td align='left'  valign='top'>
2635 range to the station s1  plus noise </td></tr><tr><td align='left'  valign='top'>
2636
2637
2638<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2639<mi mathvariant='italic'>z</mi>
2640<mn>2</mn>
2641<mo stretchy="false">(</mo>
2642<mi mathvariant='italic'>t</mi>
2643<mo stretchy="false">)</mo>
2644</mrow></math>
2645
2646  </td><td align='left'  valign='top'>
2647 range to the station s2  plus noise
2648</td></tr>
2649</table>
2650<br/>
2651<b><big><a name="3.2.f" id="3.2.f">3.2.f: Constraint</a></big></b>
2652
2653<br/>
2654
2655<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
2656<mn>2</mn>
2657<mo stretchy="false">+</mo>
2658<mi mathvariant='italic'>x</mi>
2659<mn>4</mn>
2660<mo stretchy="false">_</mo>
2661<mi mathvariant='italic'>min</mi>
2662<mo stretchy="false">&#x02265;</mo>
2663<msub><mi mathvariant='italic'>x</mi>
2664<mn>4</mn>
2665</msub>
2666<mo stretchy="false">(</mo>
2667<mi mathvariant='italic'>t</mi>
2668<mo stretchy="false">)</mo>
2669<mo stretchy="false">&#x02265;</mo>
2670<mi mathvariant='italic'>x</mi>
2671<mn>4</mn>
2672<mo stretchy="false">_</mo>
2673<mi mathvariant='italic'>min</mi>
2674</mrow></math>
2675
2676.
2677
2678
2679<br/>
2680<br/>
2681<b><big><a name="3.2.g" id="3.2.g">3.2.g: Call Back Functions</a></big></b>
2682
2683<table><tr><td align='left'  valign='top'>
2684
2685<a href="#3.2.1">3.2.1: nonlinear_ok_box_f.m</a></td><td>
2686Example Constraint Function: nonlinear_ok_box_f</td></tr>
2687<tr><td>
2688
2689<a href="#3.2.2">3.2.2: nonlinear_ok_box_g.m</a></td><td>
2690Example Transition Function: nonlinear_ok_box_g</td></tr>
2691<tr><td>
2692
2693<a href="#3.2.3">3.2.3: nonlinear_ok_box_h.m</a></td><td>
2694Example Measurement Function: nonlinear_ok_box_h</td></tr>
2695<tr><td>
2696
2697<a href="#3.2.4">3.2.4: nonlinear_ok_box_nof.m</a></td><td>
2698Example no Constraint Function: nonlinear_ok_box_nof</td></tr>
2699<tr><td>
2700
2701</td></tr>
2702</table>
2703<br/>
2704<b><big><a name="3.2.h" id="3.2.h">3.2.h: Source Code</a></big></b>
2705
2706 <code><font color='blue'><pre style='display:inline'> 
2707function [ok] = nonlinear_ok_box(draw_plot)
2708if nargin &lt; 1
2709        draw_plot = false;
2710end
2711% --------------------------------------------------------
2712% You can change these parameters
2713N       = 50;            % number of measurement time points
2714dt      = 2 * pi / N;    % time between measurement points
2715sigma   = .25;           % standard deviation of measurement noise
2716gamma   = 1;             % multiplier for transition variance
2717max_itr = 50;            % maximum number of iterations
2718epsilon = 1e-4;          % convergence criteria
2719x4_min  = .25;           % minimum value for x4_true
2720h_min   = 0;             % minimum horizontal value in plots
2721h_max   = 7;             % maximum horizontal value in plots
2722v_min   = 0;             % minimum vertical value in plots
2723v_max   = 2.5;           % maximum vertical value in plots
2724s1      = [ 0 , 0 ];     % station one
2725s2      = [ 2*pi , 0 ];  % station two
2726%
2727% level of tracing during the optimization
2728if draw_plot
2729        level   = 1;
2730else
2731        level   = 0;
2732end
2733% ---------------------------------------------------------
2734%
2735% global variables used by nonlinear_ok_box_h
2736global nonlinear_ok_box_s1
2737global nonlinear_ok_box_s2
2738nonlinear_ok_box_s1 = s1;
2739nonlinear_ok_box_s2 = s2;
2740%
2741ok = true;
2742%
2743%  Define the problem
2744rand('seed', 1234);
2745%
2746% number of constraints per time point
2747ell   = 2;
2748%
2749% number of measurements per time point
2750m     = 2;
2751%
2752% number of state vector components per time point
2753n     = 4;
2754%
2755% simulate the true trajectory and measurement noise
2756t        =  (1 : N) * dt;
2757x2_true  = t;
2758x4_max   = x4_min + 2;
2759x4_true  = x4_min + 1 - sin(t);
2760x1_true  = ones(1, N);
2761x3_true  = - cos(t);
2762x_true   = [ x1_true ; x2_true ; x3_true ; x4_true ];
2763v1_true  = sigma * randn(1, N);
2764v2_true  = sigma * randn(1, N);
2765%
2766% corresponding measurement values
2767rinv    = zeros(m, m, N);
2768z       = zeros(m, N);
2769rinvk   = eye(m) / (sigma * sigma);
2770for k = 1 : N
2771        x_k          = x_true(:, k);
2772        h_k          = nonlinear_ok_box_h(k, x_k);
2773        z(:, k)      = h_k + [ v1_true(k) ; v2_true(k) ];
2774        rinv(:,:, k) = rinvk;
2775end
2776%
2777% covariance for the transition noise
2778qk       = diag( [ dt, dt^3 / 3 , dt, dt^3 / 3 ] );
2779qk(1, 2) = dt^2 / 2;
2780qk(2, 1) = dt^2 / 2;
2781qk(3, 4) = dt^2 / 2;
2782qk(4, 3) = dt^2 / 2;
2783qk       = qk * gamma;
2784qinvk    = inv(qk);
2785qinv     = zeros(n, n, N);
2786for k = 2 : N
2787        qinv(:,:, k) = qinvk;
2788end
2789%
2790% covariance for the initial estimate
2791qinv(:,:,1) = eye(n) * 100 * gamma;
2792%
2793% initial x vector
2794x_in = zeros(n, N);
2795for k = 1 : N
2796        x_in(:, k) = [ 0 ; 1 ; 0 ; 1 ];
2797end
2798%
2799% global variables used by nonlinear_ok_box_f
2800global nonlinear_ok_box_x4_min
2801global nonlinear_ok_box_x4_max
2802nonlinear_ok_box_x4_min = x4_min;
2803nonlinear_ok_box_x4_max = x4_max;
2804%
2805% global variables used by nonlinear_ok_box_g
2806global nonlinear_ok_box_x1
2807global nonlinear_ok_box_dt
2808nonlinear_ok_box_x1 = x_true(:, 1);
2809nonlinear_ok_box_dt = dt;
2810%
2811% ----------------------------------------------------------------------
2812f_fun = 'nonlinear_ok_box_f';
2813g_fun = 'nonlinear_ok_box_g';
2814h_fun = 'nonlinear_ok_box_h';
2815[x_out, u_out, info] = ckbs_nonlinear( ...
2816        f_fun,    ...
2817        g_fun,    ...
2818        h_fun,    ...
2819        max_itr,  ...
2820        epsilon,  ...
2821        x_in,     ...
2822        z,        ...
2823        qinv,     ...
2824        rinv,     ...
2825        level     ...
2826);
2827% ----------------------------------------------------------------------
2828ok         = ok &amp; (size(info,1) &lt;= max_itr);
2829f_out      = zeros(ell, N);
2830g_out      = zeros(n, N);
2831h_out      = zeros(m, N);
2832df_out     = zeros(ell, n, N);
2833dg_out     = zeros(n, n, N);
2834dh_out     = zeros(m, n, N);
2835xk1        = zeros(n, 1);
2836for k = 1 : N
2837        xk    = x_out(:, k);
2838        uk    = u_out(:, k);
2839        [fk, Fk]   = nonlinear_ok_box_f(k, xk);
2840        [gk, Gk]   = nonlinear_ok_box_g(k, xk1);
2841        [hk, Hk]   = nonlinear_ok_box_h(k, xk);
2842        %
2843        ok   = ok &amp; all( fk &lt;= epsilon );
2844        ok   = ok &amp; all( abs(fk) .* uk &lt;= epsilon );
2845        %
2846        df_out(:,:, k) = Fk;
2847        dg_out(:,:, k) = Gk;
2848        dh_out(:,:, k) = Hk;
2849        f_out(:, k)    = fk - Fk * xk;
2850        g_out(:, k)    = gk - Gk * xk1;
2851        h_out(:, k)    = hk - Hk * xk;
2852        xk1 = xk;
2853end
2854ok   = ok &amp; all( all( u_out &gt;= 0 ) );
2855%
2856d_out = ckbs_sumsq_grad(x_out, z, g_out, h_out, dg_out, dh_out, qinv, rinv);
2857for k = 1 : N
2858        uk = u_out(:, k);
2859        Fk = df_out(:,:, k);
2860        dk = d_out(:, k);
2861        %
2862        ok = ok &amp; (max ( abs( Fk' * uk + dk ) ) &lt;= epsilon);
2863end
2864if ~ ok
2865        keyboard
2866end
2867if draw_plot
2868        figure(1);
2869        clf
2870        hold on
2871        plot(x_true(2,:)', x_true(4,:)', 'b-' );
2872        plot(x_out(2,:)', x_out(4,:)', 'g-' );
2873        plot(x_true(2,:)', x4_min * ones(N,1), 'r-');
2874        plot(x_true(2,:)', x4_max * ones(N,1), 'r-');
2875        axis([h_min, h_max, v_min, v_max]);
2876        title('Constrained: blue=truth, green=estimate, red=constraint');
2877        hold off
2878        %
2879        % constrained estimate
2880        x_con = x_out;
2881end
2882% ----------------------------------------------------------------------
2883% Unconstrained case
2884f_fun = 'nonlinear_ok_box_nof';
2885[x_out, u_out, info] = ckbs_nonlinear( ...
2886        f_fun,    ...
2887        g_fun,    ...
2888        h_fun,    ...
2889        max_itr,  ...
2890        epsilon,  ...
2891        x_in,     ...
2892        z,        ...
2893        qinv,     ...
2894        rinv,     ...
2895        level     ...
2896);
2897% ----------------------------------------------------------------------
2898ok   = ok &amp; (size(info,1) &lt;= max_itr);
2899xk1  = zeros(n, 1);
2900for k = 1 : N
2901        xk    = x_out(:, k);
2902        [gk, Gk]   = nonlinear_ok_box_g(k, xk1);
2903        [hk, Hk]   = nonlinear_ok_box_h(k, xk);
2904        %
2905        dg_out(:,:, k) = Gk;
2906        dh_out(:,:, k) = Hk;
2907        g_out(:, k)    = gk - Gk * xk1;
2908        h_out(:, k)    = hk - Hk * xk;
2909        xk1 = xk;
2910end
2911d_out  = ckbs_sumsq_grad(x_out, z, g_out, h_out, dg_out, dh_out, qinv, rinv);
2912ok     = ok &amp; (max( max( abs(d_out) ) ) &lt;= epsilon);
2913if draw_plot
2914        figure(2);
2915        clf
2916        hold on
2917        plot(x_true(2,:)', x_true(4,:)', 'b-' );
2918        plot(x_out(2,:)', x_out(4,:)', 'g-' );
2919        plot(x_true(2,:)', x4_min * ones(1,N), 'r-');
2920        plot(x_true(2,:)', x4_max * ones(1,N), 'r-');
2921        axis([h_min, h_max, v_min, v_max]);
2922        title('Unconstrained: blue=truth, green=estimate, red=constraint');
2923        hold off
2924        %
2925        % unconstrained estimate
2926        x_free = x_out;
2927        %
2928        % write out constrained and unconstrained results
2929        [fid, msg] = fopen('nonlinear_ok_box.out', 'wt');
2930        if size(msg, 2) &gt; 0
2931                disp(['nonlinear_ok: ', msg]);
2932        end
2933        %                      123456789012345678901234'
2934        heading =             ' x2_true  x2_con x2_free'  ;
2935        heading = [ heading , ' x4_true  x4_con x4_free' ];
2936        heading = [ heading , '      z1      z2\n'       ];
2937        fprintf(fid, heading);
2938        for k = 1 : N
2939                fprintf(fid,'%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f\n', ...
2940                        x_true(2,k), x_con(2,k), x_free(2,k), ...
2941                        x_true(4,k), x_con(4,k), x_free(4,k), ...
2942                        z(1,k), z(2,k) ...
2943                );
2944        end
2945        fclose(fid);
2946end
2947return
2948end
2949</pre></font></code>
2950 
2951
2952<hr/>Input File: test/nonlinear_ok_box.m
2953
2954<hr/>
2955 
2956
2957
2958
2959<center><b><big><big><a name="3.2.1" id="3.2.1">3.2.1: Example Constraint Function: nonlinear_ok_box_f</a>
2960</big></big></b></center>
2961<br/>
2962<b><big><a name="3.2.1.a" id="3.2.1.a">3.2.1.a: Source Code</a></big></b>
2963
2964 <code><font color='blue'><pre style='display:inline'> 
2965function [fk, Fk] = nonlinear_ok_box_f(k, xk)
2966        global nonlinear_ok_box_x4_min
2967        global nonlinear_ok_box_x4_max
2968        %
2969        % constrained so that x4_min &lt;= x4(t) &lt;= x4_max
2970        x4_min = nonlinear_ok_box_x4_min;
2971        x4_max = nonlinear_ok_box_x4_max;
2972        ell    = 2;
2973        n      = size(xk, 1);
2974        %
2975        fk = [ ...
2976                xk(4) - x4_max;
2977                x4_min - xk(4) ...
2978        ];
2979        Fk = zeros(ell, n);
2980        Fk(1, 4) = 1;
2981        Fk(2, 4) = -1;
2982        return
2983end
2984</pre></font></code>
2985 
2986
2987<hr/>Input File: test/nonlinear_ok_box_f.m
2988
2989<hr/>
2990 
2991
2992
2993
2994<center><b><big><big><a name="3.2.2" id="3.2.2">3.2.2: Example Transition Function: nonlinear_ok_box_g</a>
2995</big></big></b></center>
2996<br/>
2997<b><big><a name="3.2.2.a" id="3.2.2.a">3.2.2.a: Source Code</a></big></b>
2998
2999 <code><font color='blue'><pre style='display:inline'> 
3000function [gk, Gk] = nonlinear_ok_box_g(k, xk1)
3001        global nonlinear_ok_box_x1
3002        global nonlinear_ok_box_dt
3003        if k == 1
3004                Gk = zeros(4, 4);
3005                gk = nonlinear_ok_box_x1;
3006                return;
3007        end
3008        dt = nonlinear_ok_box_dt;
3009        Gk = [ ...
3010                1  0  0  0
3011                dt 1  0  0
3012                0  0  1  0
3013                0  0  dt 1 ...
3014        ];
3015        gk = Gk * xk1;
3016        return
3017end
3018</pre></font></code>
3019 
3020
3021<hr/>Input File: test/nonlinear_ok_box_g.m
3022
3023<hr/>
3024 
3025
3026
3027
3028<center><b><big><big><a name="3.2.3" id="3.2.3">3.2.3: Example Measurement Function: nonlinear_ok_box_h</a>
3029</big></big></b></center>
3030<br/>
3031<b><big><a name="3.2.3.a" id="3.2.3.a">3.2.3.a: Source Code</a></big></b>
3032
3033 <code><font color='blue'><pre style='display:inline'> 
3034function [hk, Hk] = nonlinear_ok_box_h(k, xk)
3035        global nonlinear_ok_box_s1
3036        global nonlinear_ok_box_s2
3037        s1  = nonlinear_ok_box_s1;
3038        s2  = nonlinear_ok_box_s2;
3039        r1  = sqrt( (xk(2) - s1(1))^2 + (xk(4) - s1(2))^2 );
3040        r2  = sqrt( (xk(2) - s2(1))^2 + (xk(4) - s2(2))^2 );
3041        hk = [ r1 ; r2 ];
3042        dr1 = [ 0, xk(2) - s1(1), 0, xk(4) - s1(2) ] / r1;
3043        dr2 = [ 0, xk(2) - s2(1), 0, xk(4) - s2(2) ] / r2;
3044        Hk = [ dr1 ; dr2 ];
3045        return
3046end
3047</pre></font></code>
3048 
3049
3050<hr/>Input File: test/nonlinear_ok_box_h.m
3051
3052<hr/>
3053 
3054
3055
3056
3057<center><b><big><big><a name="3.2.4" id="3.2.4">3.2.4: Example no Constraint Function: nonlinear_ok_box_nof</a>
3058</big></big></b></center>
3059<br/>
3060<b><big><a name="3.2.4.a" id="3.2.4.a">3.2.4.a: Source Code</a></big></b>
3061
3062 <code><font color='blue'><pre style='display:inline'> 
3063function [fk, Fk] = nonlinear_ok_box_nof(k, xk)
3064        % no constraint case
3065        n  = size(xk, 1);
3066        fk = -1;
3067        Fk = zeros(1, n);
3068        return
3069end
3070</pre></font></code>
3071 
3072
3073<hr/>Input File: test/nonlinear_ok_box_nof.m
3074
3075<hr/>
3076 
3077
3078
3079<center><b><big><big><a name="3.3" id="3.3">3.3: ckbs_nonlinear Sine Wave Constrained Tracking Example and Test</a>
3080</big></big></b></center>
3081<br/>
3082<b><big><a name="3.3.a" id="3.3.a">3.3.a: Syntax</a></big></b>
3083
3084<br/>
3085<code><font color="blue"><span style='white-space: nowrap'>[</span></font></code><i><span style='white-space: nowrap'>ok</span></i><code><font color="blue"><span style='white-space: nowrap'>]&#xA0;=&#xA0;nonlinear_ok_sin(</span></font></code><i><span style='white-space: nowrap'>draw_plot</span></i><code><font color="blue"><span style='white-space: nowrap'>)</span></font></code>
3086
3087<br/>
3088<br/>
3089<b><big><a name="3.3.b" id="3.3.b">3.3.b: draw_plot</a></big></b>
3090<br/>
3091If this argument is true, a plot is drawn showing the results
3092and the <code><font color="blue">nonlinear_ok_sin.out</font></code> file is written for use with the
3093program <code><font color="blue">test/nonlinear_ok_sin.r</font></code>.
3094
3095<br/>
3096<br/>
3097<b><big><a name="3.3.c" id="3.3.c">3.3.c: ok</a></big></b>
3098<br/>
3099If the return value <i>ok</i> is true, the test passed,
3100otherwise the test failed.
3101
3102<br/>
3103<br/>
3104<b><big><a name="3.3.d" id="3.3.d">3.3.d: State Vector</a></big></b>
3105
3106<table><tr><td align='left'  valign='top'>
3107
3108
3109<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3110<mi mathvariant='italic'>x</mi>
3111<mn>1</mn>
3112<mo stretchy="false">(</mo>
3113<mi mathvariant='italic'>t</mi>
3114<mo stretchy="false">)</mo>
3115</mrow></math>
3116
3117  </td><td align='left'  valign='top'>
3118 first component of velocity   </td></tr><tr><td align='left'  valign='top'>
3119
3120
3121<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3122<mi mathvariant='italic'>x</mi>
3123<mn>2</mn>
3124<mo stretchy="false">(</mo>
3125<mi mathvariant='italic'>t</mi>
3126<mo stretchy="false">)</mo>
3127</mrow></math>
3128
3129  </td><td align='left'  valign='top'>
3130 first component of position  </td></tr><tr><td align='left'  valign='top'>
3131
3132
3133<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3134<mi mathvariant='italic'>x</mi>
3135<mn>3</mn>
3136<mo stretchy="false">(</mo>
3137<mi mathvariant='italic'>t</mi>
3138<mo stretchy="false">)</mo>
3139</mrow></math>
3140
3141  </td><td align='left'  valign='top'>
3142 second component of velocity   </td></tr><tr><td align='left'  valign='top'>
3143
3144
3145<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3146<mi mathvariant='italic'>x</mi>
3147<mn>4</mn>
3148<mo stretchy="false">(</mo>
3149<mi mathvariant='italic'>t</mi>
3150<mo stretchy="false">)</mo>
3151</mrow></math>
3152
3153  </td><td align='left'  valign='top'>
3154 second component of position 
3155</td></tr>
3156</table>
3157<br/>
3158<b><big><a name="3.3.e" id="3.3.e">3.3.e: Measurement Vector</a></big></b>
3159
3160<table><tr><td align='left'  valign='top'>
3161
3162
3163<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3164<mi mathvariant='italic'>z</mi>
3165<mn>1</mn>
3166<mo stretchy="false">(</mo>
3167<mi mathvariant='italic'>t</mi>
3168<mo stretchy="false">)</mo>
3169</mrow></math>
3170
3171  </td><td align='left'  valign='top'>
3172 range to station s1 plus noise </td></tr><tr><td align='left'  valign='top'>
3173
3174
3175<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3176<mi mathvariant='italic'>z</mi>
3177<mn>2</mn>
3178<mo stretchy="false">(</mo>
3179<mi mathvariant='italic'>t</mi>
3180<mo stretchy="false">)</mo>
3181</mrow></math>
3182
3183  </td><td align='left'  valign='top'>
3184 range to station s2  plus noise
3185</td></tr>
3186</table>
3187<br/>
3188<b><big><a name="3.3.f" id="3.3.f">3.3.f: Constraint</a></big></b>
3189
3190<br/>
3191
3192<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3193<mi mathvariant='italic'>x</mi>
3194<mn>4</mn>
3195<mo stretchy="false">(</mo>
3196<mi mathvariant='italic'>t</mi>
3197<mo stretchy="false">)</mo>
3198<mo stretchy="false">&#x02265;</mo>
3199<mn>1</mn>
3200<mo stretchy="false">-</mo>
3201<mi mathvariant='italic'>sin</mi>
3202<mo stretchy="false">(</mo>
3203<mi mathvariant='italic'>x</mi>
3204<mn>2</mn>
3205<mo stretchy="false">(</mo>
3206<mi mathvariant='italic'>t</mi>
3207<mo stretchy="false">)</mo>
3208<mo stretchy="false">)</mo>
3209</mrow></math>
3210
3211<br/>
3212<br/>
3213<b><big><a name="3.3.g" id="3.3.g">3.3.g: Call Back Functions</a></big></b>
3214
3215<table><tr><td align='left'  valign='top'>
3216
3217<a href="#3.3.1">3.3.1: nonlinear_ok_sin_f.m</a></td><td>
3218Example Constraint Function: nonlinear_ok_sin_f</td></tr>
3219<tr><td>
3220
3221<a href="#3.2.2">3.2.2: nonlinear_ok_box_g.m</a></td><td>
3222Example Transition Function: nonlinear_ok_box_g</td></tr>
3223<tr><td>
3224
3225<a href="#3.2.3">3.2.3: nonlinear_ok_box_h.m</a></td><td>
3226Example Measurement Function: nonlinear_ok_box_h</td></tr>
3227<tr><td>
3228
3229<a href="#3.2.4">3.2.4: nonlinear_ok_box_nof.m</a></td><td>
3230Example no Constraint Function: nonlinear_ok_box_nof</td></tr>
3231<tr><td>
3232
3233</td></tr>
3234</table>
3235<br/>
3236<b><big><a name="3.3.h" id="3.3.h">3.3.h: Source Code</a></big></b>
3237
3238 <code><font color='blue'><pre style='display:inline'> 
3239function [ok] = nonlinear_ok_sin(draw_plot)
3240if nargin &lt; 1
3241        draw_plot = false;
3242end
3243% --------------------------------------------------------
3244% You can change these parameters
3245N       = 50;            % number of measurement time points
3246dt      = 2 * pi / N;    % time between measurement points
3247sigma   = .25;           % standard deviation of measurement noise
3248gamma   = 1.;            % multiplier for transition variance
3249max_itr = 50;            % maximum number of iterations
3250epsilon = 1e-4;          % convergence criteria
3251x4_min  = .25;           % minimum value for x4 constraint
3252h_min   = 0;             % minimum horizontal value in plots
3253h_max   = 7;             % maximum horizontal value in plots
3254v_min   = 0;             % minimum vertical value in plots
3255v_max   = 2.5;           % maximum vertical value in plots
3256x4_dist = .05;           % distance true path is from the constraint
3257s1      = [ 0 , 0 ];     % station one
3258s2      = [ 2*pi , 0 ];  % station two
3259%
3260% level of tracing during the optimization
3261if draw_plot
3262        level   = 1;
3263else
3264        level   = 0;
3265end
3266% ---------------------------------------------------------
3267% global variables used by nonlinear_ok_box_h
3268global nonlinear_ok_box_s1
3269global nonlinear_ok_box_s2
3270nonlinear_ok_box_s1 = s1;
3271nonlinear_ok_box_s2 = s2;
3272%
3273% global variable used by nonlinear_ok_sin_f
3274global nonlinear_ok_sin_x4_min
3275nonlinear_ok_sin_x4_min = x4_min;
3276%
3277ok = true;
3278%
3279%  Define the problem
3280rand('seed', 234);
3281%
3282% number of constraints per time point
3283ell   = 1;
3284%
3285% number of measurements per time point
3286m     = 2;
3287%
3288% number of state vector components per time point
3289n     = 4;
3290%
3291% simulate the true trajectory and measurement noise
3292t        =  (1 : N) * dt;
3293x1_true  = ones(1, N);
3294x2_true  = t;
3295x3_true  = - cos(t);
3296x4_true  = x4_dist + 1 - sin(t) + x4_min;
3297x_true   = [ x1_true ; x2_true ; x3_true ; x4_true ];
3298v1_true  = sigma * randn(1, N);
3299v2_true  = sigma * randn(1, N);
3300%
3301% corresponding measurement values
3302rinv    = zeros(m, m, N);
3303z       = zeros(m, N);
3304rinvk   = eye(m) / (sigma * sigma);
3305for k = 1 : N
3306        x_k          = x_true(:, k);
3307        h_k          = nonlinear_ok_box_h(k, x_k);
3308        z(:, k)      = h_k + [ v1_true(k) ; v2_true(k) ];
3309        rinv(:,:, k) = rinvk;
3310end
3311%
3312% covariance for the transition noise
3313qk       = diag( [ dt, dt^3 / 3 , dt, dt^3 / 3 ] );
3314qk(1, 2) = dt^2 / 2;
3315qk(2, 1) = dt^2 / 2;
3316qk(3, 4) = dt^2 / 2;
3317qk(4, 3) = dt^2 / 2;
3318qk       = qk * gamma;
3319qinvk    = inv(qk);
3320qinv     = zeros(n, n, N);
3321for k = 2 : N
3322        qinv(:,:, k) = qinvk;
3323end
3324%
3325% covariance for the initial estimate
3326qinv(:,:,1) = eye(n) * 100 * gamma;
3327%
3328% initial x vector
3329x_in       = zeros(n, N);
3330x_in(4, :) = 1;
3331%
3332% nonlinear_ok_sin use same g function as nonlinear_box_ok
3333% global variables used by nonlinear_ok_box_g
3334global nonlinear_ok_box_x1
3335global nonlinear_ok_box_dt
3336nonlinear_ok_box_x1 = x_true(:, 1);
3337nonlinear_ok_box_dt = dt;
3338%
3339% ----------------------------------------------------------------------
3340f_fun = 'nonlinear_ok_sin_f';  % special nonlinear_ok_sin constraints
3341g_fun = 'nonlinear_ok_box_g';  % same transition function as nonlinear_ok_box
3342h_fun = 'nonlinear_ok_box_h';  % same measurement function as nonlinear_ok_box
3343[x_out, u_out, info] = ckbs_nonlinear( ...
3344        f_fun,    ...
3345        g_fun,    ...
3346        h_fun,    ...
3347        max_itr,  ...
3348        epsilon,  ...
3349        x_in,     ...
3350        z,        ...
3351        qinv,     ...
3352        rinv,     ...
3353        level     ...
3354);
3355% ----------------------------------------------------------------------
3356ok         = ok &amp; (size(info,1) &lt;= max_itr);
3357f_out      = zeros(ell, N);
3358g_out      = zeros(n, N);
3359h_out      = zeros(m, N);
3360df_out     = zeros(ell, n, N);
3361dg_out     = zeros(n, n, N);
3362dh_out     = zeros(m, n, N);
3363xk1        = zeros(n, 1);
3364for k = 1 : N
3365        xk    = x_out(:, k);
3366        uk    = u_out(:, k);
3367        [fk, Fk]   = nonlinear_ok_sin_f(k, xk);
3368        [gk, Gk]   = nonlinear_ok_box_g(k, xk1);
3369        [hk, Hk]   = nonlinear_ok_box_h(k, xk);
3370        %
3371        ok   = ok &amp; all( fk &lt;= epsilon );
3372        ok   = ok &amp; all( abs(fk) .* uk &lt;= epsilon );
3373        %
3374        df_out(:,:, k) = Fk;
3375        dg_out(:,:, k) = Gk;
3376        dh_out(:,:, k) = Hk;
3377        f_out(:, k)    = fk - Fk * xk;
3378        g_out(:, k)    = gk - Gk * xk1;
3379        h_out(:, k)    = hk - Hk * xk;
3380        xk1 = xk;
3381end
3382ok   = ok &amp; all( all( u_out &gt;= 0 ) );
3383%
3384d_out = ckbs_sumsq_grad(x_out, z, g_out, h_out, dg_out, dh_out, qinv, rinv);
3385for k = 1 : N
3386        uk = u_out(:, k);
3387        Fk = df_out(:,:, k);
3388        dk = d_out(:, k);
3389        %
3390        ok = ok &amp; (max ( abs( Fk' * uk + dk ) ) &lt;= epsilon);
3391end
3392if ~ ok
3393        keyboard
3394end
3395if draw_plot
3396        figure(1);
3397        clf
3398        hold on
3399        plot(x_true(2,:)', x_true(4,:)', 'b-' );
3400        plot(x_out(2,:)', x_out(4,:)', 'g-' );
3401        plot(x_true(2,:)', 1 - sin(x_true(2,:))' + x4_min, 'r-');
3402        axis([h_min, h_max, v_min, v_max]);
3403        title('Constrained: blue=truth, green=estimate, red=constraint');
3404        hold off
3405        %
3406        % constrained estimate
3407        x_con = x_out;
3408end
3409% ----------------------------------------------------------------------
3410% Unconstrained case
3411f_fun = 'nonlinear_ok_box_nof';  % same function as used by nonlinear_ok_box
3412[x_out, u_out, info] = ckbs_nonlinear( ...
3413        f_fun,    ...
3414        g_fun,    ...
3415        h_fun,    ...
3416        max_itr,  ...
3417        epsilon,  ...
3418        x_in,     ...
3419        z,        ...
3420        qinv,     ...
3421        rinv,     ...
3422        level     ...
3423);
3424% ----------------------------------------------------------------------
3425ok   = ok &amp; (size(info,1) &lt;= max_itr);
3426xk1  = zeros(n, 1);
3427for k = 1 : N
3428        xk    = x_out(:, k);
3429        [gk, Gk]   = nonlinear_ok_box_g(k, xk1);
3430        [hk, Hk]   = nonlinear_ok_box_h(k, xk);
3431        %
3432        dg_out(:,:, k) = Gk;
3433        dh_out(:,:, k) = Hk;
3434        g_out(:, k)    = gk - Gk * xk1;
3435        h_out(:, k)    = hk - Hk * xk;
3436        xk1 = xk;
3437end
3438d_out  = ckbs_sumsq_grad(x_out, z, g_out, h_out, dg_out, dh_out, qinv, rinv);
3439ok     = ok &amp; (max( max( abs(d_out) ) ) &lt;= epsilon);
3440if draw_plot
3441        figure(2);
3442        clf
3443        hold on
3444        plot(x_true(2,:)', x_true(4,:)', 'b-' );
3445        plot(x_out(2,:)', x_out(4,:)', 'g-' );
3446        plot(x_true(2,:)', 1 - sin(x_true(2,:))' + x4_min, 'r-');
3447        axis([h_min, h_max, v_min, v_max]);
3448        title('Unconstrained: blue=truth, green=estimate, red=constraint');
3449        hold off
3450        %
3451        % unconstrained estimate
3452        x_free = x_out;
3453        %
3454        % write out constrained and unconstrained results
3455        [fid, msg] = fopen('nonlinear_ok_sin.out', 'wt');
3456        if size(msg, 2) &gt; 0
3457                disp(['nonlinear_ok: ', msg]);
3458        end
3459        %                      123456789012345678901234'
3460        heading =             ' x2_true  x2_con x2_free'  ;
3461        heading = [ heading , ' x4_true  x4_con x4_free' ];
3462        heading = [ heading , '      z1      z2\n'       ];
3463        fprintf(fid, heading);
3464        for k = 1 : N
3465                fprintf(fid,'%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f\n', ...
3466                        x_true(2,k), x_con(2,k), x_free(2,k), ...
3467                        x_true(4,k), x_con(4,k), x_free(4,k), ...
3468                        z(1,k), z(2,k) ...
3469                );
3470        end
3471        fclose(fid);
3472end
3473return
3474end
3475</pre></font></code>
3476 
3477
3478<hr/>Input File: test/nonlinear_ok_sin.m
3479
3480<hr/>
3481 
3482
3483
3484
3485<center><b><big><big><a name="3.3.1" id="3.3.1">3.3.1: Example Constraint Function: nonlinear_ok_sin_f</a>
3486</big></big></b></center>
3487<br/>
3488<b><big><a name="3.3.1.a" id="3.3.1.a">3.3.1.a: Source Code</a></big></b>
3489
3490 <code><font color='blue'><pre style='display:inline'> 
3491function [fk, Fk] = nonlinear_ok_sin_f(k, xk)
3492        global nonlinear_ok_sin_x4_min
3493        x4_min = nonlinear_ok_sin_x4_min;
3494        %
3495        % constrained so that x(4) &gt;= 1 - sin( x(1) ) + x4_min
3496        ell      = 1;
3497        n        = size(xk, 1);
3498        %
3499        fk       = 1 - sin( xk(2) ) + x4_min - xk(4);
3500        Fk       = zeros(ell, n);
3501        Fk(1, 2) = - cos( xk(2) );
3502        Fk(1, 4) = -1;
3503        return
3504end
3505</pre></font></code>
3506 
3507
3508<hr/>Input File: test/nonlinear_ok_sin_f.m
3509
3510<hr/>
3511 
3512
3513
3514
3515
3516
3517
3518
3519
3520<center><b><big><big><a name="4" id="4">4: Constrained Affine Kalman Bucy Smoother</a>
3521</big></big></b></center>
3522<br/>
3523<b><big><a name="4.a" id="4.a">4.a: Syntax</a></big></b>
3524
3525<br/>
3526<code><font color="blue"><span style='white-space: nowrap'>[</span></font></code><i><span style='white-space: nowrap'>xOut</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>uOut</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>]&#xA0;=&#xA0;ckbs_affine(</span></font></code><i><span style='white-space: nowrap'>max_itr</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>epsilon</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>z</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>b</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>g</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>h</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>db</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>dg</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>dh</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>qinv</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>rinv</span></i><code><font color="blue"><span style='white-space: nowrap'>)</span></font></code>
3527
3528<br/>
3529<br/>
3530<b><big><a name="4.b" id="4.b">4.b: Purpose</a></big></b>
3531<br/>
3532This routine minimizes the
3533affine Kalman-Bucy smoother residual sum of squares objective
3534subject to an affine inequality constraint.
3535
3536<br/>
3537<br/>
3538<b><big><a name="4.c" id="4.c">4.c: Notation</a></big></b>
3539<br/>
3540The affine Kalman-Bucy smoother residual sum of squares is defined by
3541
3542<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
3543<mtable rowalign="center" ><mtr><mtd columnalign="right" >
3544<mi mathvariant='italic'>S</mi>
3545<mo stretchy="false">(</mo>
3546<msub><mi mathvariant='italic'>x</mi>
3547<mn>1</mn>
3548</msub>
3549<mo stretchy="false">,</mo>
3550<mo stretchy="false">&#x02026;</mo>
3551<mo stretchy="false">,</mo>
3552<msub><mi mathvariant='italic'>x</mi>
3553<mi mathvariant='italic'>N</mi>
3554</msub>
3555<mo stretchy="false">)</mo>
3556</mtd><mtd columnalign="center" >
3557<mo stretchy="false">=</mo>
3558</mtd><mtd columnalign="left" >
3559<munderover><mo displaystyle='true' largeop='true'>&#x02211;</mo>
3560<mrow><mi mathvariant='italic'>k</mi>
3561<mo stretchy="false">=</mo>
3562<mn>1</mn>
3563</mrow>
3564<mi mathvariant='italic'>N</mi>
3565</munderover>
3566<msub><mi mathvariant='italic'>S</mi>
3567<mi mathvariant='italic'>k</mi>
3568</msub>
3569<mo stretchy="false">(</mo>
3570<msub><mi mathvariant='italic'>x</mi>
3571<mi mathvariant='italic'>k</mi>
3572</msub>
3573<mo stretchy="false">,</mo>
3574<msub><mi mathvariant='italic'>x</mi>
3575<mrow><mi mathvariant='italic'>k</mi>
3576<mn>-1</mn>
3577</mrow>
3578</msub>
3579<mo stretchy="false">)</mo>
3580</mtd></mtr><mtr><mtd columnalign="right" >
3581<msub><mi mathvariant='italic'>S</mi>
3582<mi mathvariant='italic'>k</mi>
3583</msub>
3584<mo stretchy="false">(</mo>
3585<msub><mi mathvariant='italic'>x</mi>
3586<mi mathvariant='italic'>k</mi>
3587</msub>
3588<mo stretchy="false">,</mo>
3589<msub><mi mathvariant='italic'>x</mi>
3590<mrow><mi mathvariant='italic'>k</mi>
3591<mn>-1</mn>
3592</mrow>
3593</msub>
3594<mo stretchy="false">)</mo>
3595</mtd><mtd columnalign="center" >
3596<mo stretchy="false">=</mo>
3597</mtd><mtd columnalign="left" >
3598<mfrac><mrow><mn>1</mn>
3599</mrow>
3600<mrow><mn>2</mn>
3601</mrow>
3602</mfrac>
3603<mo stretchy="false">(</mo>
3604<msub><mi mathvariant='italic'>z</mi>
3605<mi mathvariant='italic'>k</mi>
3606</msub>
3607<mo stretchy="false">-</mo>
3608<msub><mi mathvariant='italic'>h</mi>
3609<mi mathvariant='italic'>k</mi>
3610</msub>
3611<mo stretchy="false">-</mo>
3612<msub><mi mathvariant='italic'>H</mi>
3613<mi mathvariant='italic'>k</mi>
3614</msub>
3615<mo stretchy="false">*</mo>
3616<msub><mi mathvariant='italic'>x</mi>
3617<mi mathvariant='italic'>k</mi>
3618</msub>
3619<msup><mo stretchy="false">)</mo>
3620<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>T</mi>
3621</mstyle></mrow>
3622</msup>
3623<mo stretchy="false">*</mo>
3624<msubsup><mi mathvariant='italic'>R</mi>
3625<mi mathvariant='italic'>k</mi>
3626<mrow><mn>-1</mn>
3627</mrow>
3628</msubsup>
3629<mo stretchy="false">*</mo>
3630<mo stretchy="false">(</mo>
3631<msub><mi mathvariant='italic'>z</mi>
3632<mi mathvariant='italic'>k</mi>
3633</msub>
3634<mo stretchy="false">-</mo>
3635<msub><mi mathvariant='italic'>h</mi>
3636<mi mathvariant='italic'>k</mi>
3637</msub>
3638<mo stretchy="false">-</mo>
3639<msub><mi mathvariant='italic'>H</mi>
3640<mi mathvariant='italic'>k</mi>
3641</msub>
3642<mo stretchy="false">*</mo>
3643<msub><mi mathvariant='italic'>x</mi>
3644<mi mathvariant='italic'>k</mi>
3645</msub>
3646<mo stretchy="false">)</mo>
3647</mtd></mtr><mtr><mtd columnalign="right" >
3648</mtd><mtd columnalign="center" >
3649<mo stretchy="false">+</mo>
3650</mtd><mtd columnalign="left" >
3651<mfrac><mrow><mn>1</mn>
3652</mrow>
3653<mrow><mn>2</mn>
3654</mrow>
3655</mfrac>
3656<mo stretchy="false">(</mo>
3657<msub><mi mathvariant='italic'>x</mi>
3658<mi mathvariant='italic'>k</mi>
3659</msub>
3660<mo stretchy="false">-</mo>
3661<msub><mi mathvariant='italic'>g</mi>
3662<mi mathvariant='italic'>k</mi>
3663</msub>
3664<mo stretchy="false">-</mo>
3665<msub><mi mathvariant='italic'>G</mi>
3666<mi mathvariant='italic'>k</mi>
3667</msub>
3668<mo stretchy="false">*</mo>
3669<msub><mi mathvariant='italic'>x</mi>
3670<mrow><mi mathvariant='italic'>k</mi>
3671<mn>-1</mn>
3672</mrow>
3673</msub>
3674<msup><mo stretchy="false">)</mo>
3675<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>T</mi>
3676</mstyle></mrow>
3677</msup>
3678<mo stretchy="false">*</mo>
3679<msubsup><mi mathvariant='italic'>Q</mi>
3680<mi mathvariant='italic'>k</mi>
3681<mrow><mn>-1</mn>
3682</mrow>
3683</msubsup>
3684<mo stretchy="false">*</mo>
3685<mo stretchy="false">(</mo>
3686<msub><mi mathvariant='italic'>x</mi>
3687<mi mathvariant='italic'>k</mi>
3688</msub>
3689<mo stretchy="false">-</mo>
3690<msub><mi mathvariant='italic'>g</mi>
3691<mi mathvariant='italic'>k</mi>
3692</msub>
3693<mo stretchy="false">-</mo>
3694<msub><mi mathvariant='italic'>G</mi>
3695<mi mathvariant='italic'>k</mi>
3696</msub>
3697<mo stretchy="false">*</mo>
3698<msub><mi mathvariant='italic'>x</mi>
3699<mrow><mi mathvariant='italic'>k</mi>
3700<mn>-1</mn>
3701</mrow>
3702</msub>
3703<mo stretchy="false">)</mo>
3704</mtd></mtr><mtr><mtd columnalign="right" >
3705</mtd></mtr></mtable>
3706</mrow></math>
3707
3708where the matrices
3709<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3710<msub><mi mathvariant='italic'>R</mi>
3711<mi mathvariant='italic'>k</mi>
3712</msub>
3713</mrow></math>
3714
3715 and
3716<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3717<msub><mi mathvariant='italic'>Q</mi>
3718<mi mathvariant='italic'>k</mi>
3719</msub>
3720</mrow></math>
3721
3722 are
3723symmetric positive definite and
3724
3725<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3726<msub><mi mathvariant='italic'>x</mi>
3727<mn>0</mn>
3728</msub>
3729</mrow></math>
3730
3731 is the constant zero.
3732Note that
3733<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3734<msub><mi mathvariant='italic'>g</mi>
3735<mn>1</mn>
3736</msub>
3737</mrow></math>
3738
3739 is the initial state estimate
3740and
3741<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3742<msub><mi mathvariant='italic'>Q</mi>
3743<mn>1</mn>
3744</msub>
3745</mrow></math>
3746
3747 is the corresponding covariance.
3748
3749<br/>
3750<br/>
3751<b><big><a name="4.d" id="4.d">4.d: Problem</a></big></b>
3752<br/>
3753The affine constrained Kalman-Bucy smoother problem is
3754
3755<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
3756<mtable rowalign="center" ><mtr><mtd columnalign="right" >
3757<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>minimize</mi>
3758</mstyle></mrow>
3759</mtd><mtd columnalign="left" >
3760<mi mathvariant='italic'>S</mi>
3761<mo stretchy="false">(</mo>
3762<msub><mi mathvariant='italic'>x</mi>
3763<mn>1</mn>
3764</msub>
3765<mo stretchy="false">,</mo>
3766<mo stretchy="false">&#x02026;</mo>
3767<mo stretchy="false">,</mo>
3768<msub><mi mathvariant='italic'>x</mi>
3769<mi mathvariant='italic'>N</mi>
3770</msub>
3771<mo stretchy="false">)</mo>
3772</mtd><mtd columnalign="left" >
3773<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>w</mi>
3774<mo stretchy="false">.</mo>
3775<mi mathvariant='normal'>r</mi>
3776<mo stretchy="false">.</mo>
3777<mi mathvariant='normal'>t</mi>
3778<mo stretchy="false">.</mo>
3779</mstyle></mrow>
3780<mspace width='.3em'/>
3781<msub><mi mathvariant='italic'>x</mi>
3782<mn>1</mn>
3783</msub>
3784<mo stretchy="false">&#x02208;</mo>
3785<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
3786</mstyle></mrow>
3787<mi mathvariant='italic'>n</mi>
3788</msup>
3789<mo stretchy="false">,</mo>
3790<mo stretchy="false">&#x02026;</mo>
3791<mo stretchy="false">,</mo>
3792<msub><mi mathvariant='italic'>x</mi>
3793<mi mathvariant='italic'>N</mi>
3794</msub>
3795<mo stretchy="false">&#x02208;</mo>
3796<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
3797</mstyle></mrow>
3798<mi mathvariant='italic'>n</mi>
3799</msup>
3800</mtd></mtr><mtr><mtd columnalign="right" >
3801<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>subject</mi>
3802<mspace width='.3em'/>
3803<mi mathvariant='normal'>to</mi>
3804</mstyle></mrow>
3805</mtd><mtd columnalign="left" >
3806<msub><mi mathvariant='italic'>b</mi>
3807<mi mathvariant='italic'>k</mi>
3808</msub>
3809<mo stretchy="false">+</mo>
3810<msub><mi mathvariant='italic'>B</mi>
3811<mi mathvariant='italic'>k</mi>
3812</msub>
3813<mo stretchy="false">*</mo>
3814<msub><mi mathvariant='italic'>x</mi>
3815<mi mathvariant='italic'>k</mi>
3816</msub>
3817<mo stretchy="false">&#x02264;</mo>
3818<mn>0</mn>
3819</mtd><mtd columnalign="left" >
3820<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>for</mi>
3821</mstyle></mrow>
3822<mspace width='.3em'/>
3823<mi mathvariant='italic'>k</mi>
3824<mo stretchy="false">=</mo>
3825<mn>1</mn>
3826<mo stretchy="false">,</mo>
3827<mo stretchy="false">&#x02026;</mo>
3828<mo stretchy="false">,</mo>
3829<mi mathvariant='italic'>N</mi>
3830</mtd></mtr></mtable>
3831</mrow></math>
3832
3833<br/>
3834<b><big><a name="4.e" id="4.e">4.e: First Order Conditions</a></big></b>
3835<br/>
3836A state sequence
3837<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3838<mo stretchy="false">(</mo>
3839<msub><mi mathvariant='italic'>x</mi>
3840<mn>1</mn>
3841</msub>
3842<mo stretchy="false">,</mo>
3843<mo stretchy="false">&#x02026;</mo>
3844<mo stretchy="false">,</mo>
3845<msub><mi mathvariant='italic'>x</mi>
3846<mi mathvariant='italic'>N</mi>
3847</msub>
3848<mo stretchy="false">)</mo>
3849</mrow></math>
3850
3851 is considered a solution
3852if there is a Lagrange multiplier sequence
3853<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3854<mo stretchy="false">(</mo>
3855<msub><mi mathvariant='italic'>u</mi>
3856<mn>1</mn>
3857</msub>
3858<mo stretchy="false">,</mo>
3859<mo stretchy="false">&#x02026;</mo>
3860<mo stretchy="false">,</mo>
3861<msub><mi mathvariant='italic'>u</mi>
3862<mi mathvariant='italic'>N</mi>
3863</msub>
3864<mo stretchy="false">)</mo>
3865</mrow></math>
3866
3867 
3868such that the following conditions are satisfied.
3869
3870<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
3871<mtable rowalign="center" ><mtr><mtd columnalign="right" >
3872<msub><mi mathvariant='italic'>b</mi>
3873<mi mathvariant='italic'>k</mi>
3874</msub>
3875<mo stretchy="false">+</mo>
3876<msub><mi mathvariant='italic'>B</mi>
3877<mi mathvariant='italic'>k</mi>
3878</msub>
3879<mo stretchy="false">*</mo>
3880<msub><mi mathvariant='italic'>x</mi>
3881<mi mathvariant='italic'>k</mi>
3882</msub>
3883</mtd><mtd columnalign="center" >
3884<mo stretchy="false">&#x02264;</mo>
3885</mtd><mtd columnalign="left" >
3886<mi mathvariant='normal'>&#x003B5;</mi>
3887</mtd></mtr><mtr><mtd columnalign="right" >
3888<mn>0</mn>
3889</mtd><mtd columnalign="center" >
3890<mo stretchy="false">&#x02264;</mo>
3891</mtd><mtd columnalign="left" >
3892<msub><mi mathvariant='italic'>u</mi>
3893<mi mathvariant='italic'>k</mi>
3894</msub>
3895</mtd></mtr><mtr><mtd columnalign="right" >
3896<mo stretchy="false">|</mo>
3897<mo stretchy="false">(</mo>
3898<msubsup><mi mathvariant='italic'>B</mi>
3899<mi mathvariant='italic'>k</mi>
3900<mi mathvariant='italic'>T</mi>
3901</msubsup>
3902<mo stretchy="false">*</mo>
3903<msub><mi mathvariant='italic'>u</mi>
3904<mi mathvariant='italic'>k</mi>
3905</msub>
3906<mo stretchy="false">+</mo>
3907<msub><mi mathvariant='italic'>d</mi>
3908<mi mathvariant='italic'>k</mi>
3909</msub>
3910<msub><mo stretchy="false">)</mo>
3911<mi mathvariant='italic'>j</mi>
3912</msub>
3913<mo stretchy="false">|</mo>
3914</mtd><mtd columnalign="center" >
3915<mo stretchy="false">&#x02264;</mo>
3916</mtd><mtd columnalign="left" >
3917<mi mathvariant='normal'>&#x003B5;</mi>
3918</mtd></mtr><mtr><mtd columnalign="right" >
3919<mo stretchy="false">|</mo>
3920<mo stretchy="false">(</mo>
3921<msub><mi mathvariant='italic'>u</mi>
3922<mi mathvariant='italic'>k</mi>
3923</msub>
3924<msub><mo stretchy="false">)</mo>
3925<mi mathvariant='italic'>i</mi>
3926</msub>
3927<mo stretchy="false">*</mo>
3928<mo stretchy="false">(</mo>
3929<msub><mi mathvariant='italic'>b</mi>
3930<mi mathvariant='italic'>k</mi>
3931</msub>
3932<mo stretchy="false">+</mo>
3933<msub><mi mathvariant='italic'>B</mi>
3934<mi mathvariant='italic'>k</mi>
3935</msub>
3936<mo stretchy="false">*</mo>
3937<msub><mi mathvariant='italic'>x</mi>
3938<mi mathvariant='italic'>k</mi>
3939</msub>
3940<msub><mo stretchy="false">)</mo>
3941<mi mathvariant='italic'>i</mi>
3942</msub>
3943<mo stretchy="false">|</mo>
3944</mtd><mtd columnalign="center" >
3945<mo stretchy="false">&#x02264;</mo>
3946</mtd><mtd columnalign="left" >
3947<mi mathvariant='normal'>&#x003B5;</mi>
3948</mtd></mtr></mtable>
3949</mrow></math>
3950
3951for
3952<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3953<mi mathvariant='italic'>j</mi>
3954<mo stretchy="false">=</mo>
3955<mn>1</mn>
3956<mo stretchy="false">,</mo>
3957<mo stretchy="false">&#x02026;</mo>
3958<mo stretchy="false">,</mo>
3959<mi mathvariant='italic'>n</mi>
3960</mrow></math>
3961
3962,
3963
3964<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3965<mi mathvariant='italic'>i</mi>
3966<mo stretchy="false">=</mo>
3967<mn>1</mn>
3968<mo stretchy="false">,</mo>
3969<mo stretchy="false">&#x02026;</mo>
3970<mo stretchy="false">,</mo>
3971<mo stretchy="false">&#x02113;</mo>
3972</mrow></math>
3973
3974, and
3975
3976<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3977<mi mathvariant='italic'>k</mi>
3978<mo stretchy="false">=</mo>
3979<mn>1</mn>
3980<mo stretchy="false">,</mo>
3981<mo stretchy="false">&#x02026;</mo>
3982<mo stretchy="false">,</mo>
3983<mi mathvariant='italic'>N</mi>
3984</mrow></math>
3985
3986.
3987Here
3988
3989<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3990<msub><mi mathvariant='italic'>d</mi>
3991<mi mathvariant='italic'>k</mi>
3992</msub>
3993</mrow></math>
3994
3995 is the partial derivative of
3996<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
3997<mi mathvariant='italic'>S</mi>
3998<mo stretchy="false">(</mo>
3999<msub><mi mathvariant='italic'>x</mi>
4000<mn>1</mn>
4001</msub>
4002<mo stretchy="false">,</mo>
4003<mo stretchy="false">&#x02026;</mo>
4004<mo stretchy="false">,</mo>
4005<msub><mi mathvariant='italic'>x</mi>
4006<mi mathvariant='italic'>N</mi>
4007</msub>
4008<mo stretchy="false">)</mo>
4009</mrow></math>
4010
4011
4012with respect to
4013<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4014<msub><mi mathvariant='italic'>x</mi>
4015<mi mathvariant='italic'>k</mi>
4016</msub>
4017</mrow></math>
4018
4019
4020and
4021<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4022<mo stretchy="false">(</mo>
4023<msub><mi mathvariant='italic'>u</mi>
4024<mi mathvariant='italic'>k</mi>
4025</msub>
4026<msub><mo stretchy="false">)</mo>
4027<mi mathvariant='italic'>i</mi>
4028</msub>
4029</mrow></math>
4030
4031 denotes the <i>i</i>-th component of
4032<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4033<msub><mi mathvariant='italic'>u</mi>
4034<mi mathvariant='italic'>k</mi>
4035</msub>
4036</mrow></math>
4037
4038.
4039
4040<br/>
4041<br/>
4042<b><big><a name="4.f" id="4.f">4.f: max_itr</a></big></b>
4043<br/>
4044The integer scalar <i>max_itr</i> specifies the maximum number of
4045iterations of the algorithm to execute. It must be greater than or
4046equal to zero. Note that if it is zero, the first row of the
4047<a href="#4.s">4.s: <span style='white-space: nowrap'>info</span></a>
4048 return value will still be computed.
4049This can be useful for deciding what is a good value for the argument
4050<a href="#4.g">4.g: <span style='white-space: nowrap'>epsilon</span></a>
4051.
4052
4053<br/>
4054<br/>
4055<b><big><a name="4.g" id="4.g">4.g: epsilon</a></big></b>
4056<br/>
4057The positive scalar <i>epsilon</i> specifies the convergence
4058criteria value; i.e.,
4059
4060<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
4061<mi mathvariant='normal'>&#x003B5;</mi>
4062<mo stretchy="false">=</mo>
4063<mi mathvariant='italic'>epsilon</mi>
4064</mrow></math>
4065
4066<br/>
4067<b><big><a name="4.h" id="4.h">4.h: z</a></big></b>
4068<br/>
4069The argument <i>z</i> is a two dimensional array,
4070for
4071<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4072<mi mathvariant='italic'>k</mi>
4073<mo stretchy="false">=</mo>
4074<mn>1</mn>
4075<mo stretchy="false">,</mo>
4076<mo stretchy="false">&#x02026;</mo>
4077<mo stretchy="false">,</mo>
4078<mi mathvariant='italic'>N</mi>
4079</mrow></math>
4080
4081
4082
4083<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
4084<msub><mi mathvariant='italic'>z</mi>
4085<mi mathvariant='italic'>k</mi>
4086</msub>
4087<mo stretchy="false">=</mo>
4088<mi mathvariant='italic'>z</mi>
4089<mo stretchy="false">(</mo>
4090<mo stretchy="false">:</mo>
4091<mo stretchy="false">,</mo>
4092<mi mathvariant='italic'>k</mi>
4093<mo stretchy="false">)</mo>
4094</mrow></math>
4095
4096and <i>z</i> has size
4097<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4098<mi mathvariant='italic'>m</mi>
4099<mo stretchy="false">&#x000D7;</mo>
4100<mi mathvariant='italic'>N</mi>
4101</mrow></math>
4102
4103.
4104
4105<br/>
4106<br/>
4107<b><big><a name="4.i" id="4.i">4.i: b</a></big></b>
4108<br/>
4109The argument <i>b</i> is a two dimensional array,
4110for
4111<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4112<mi mathvariant='italic'>k</mi>
4113<mo stretchy="false">=</mo>
4114<mn>1</mn>
4115<mo stretchy="false">,</mo>
4116<mo stretchy="false">&#x02026;</mo>
4117<mo stretchy="false">,</mo>
4118<mi mathvariant='italic'>N</mi>
4119</mrow></math>
4120
4121
4122
4123<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
4124<msub><mi mathvariant='italic'>b</mi>
4125<mi mathvariant='italic'>k</mi>
4126</msub>
4127<mo stretchy="false">=</mo>
4128<mi mathvariant='italic'>b</mi>
4129<mo stretchy="false">(</mo>
4130<mo stretchy="false">:</mo>
4131<mo stretchy="false">,</mo>
4132<mi mathvariant='italic'>k</mi>
4133<mo stretchy="false">)</mo>
4134</mrow></math>
4135
4136and <i>b</i> has size
4137<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4138<mo stretchy="false">&#x02113;</mo>
4139<mo stretchy="false">&#x000D7;</mo>
4140<mi mathvariant='italic'>N</mi>
4141</mrow></math>
4142
4143.
4144If
4145<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4146<mo stretchy="false">&#x02113;</mo>
4147<mo stretchy="false">=</mo>
4148<mn>0</mn>
4149</mrow></math>
4150
4151, the problem is not constrained; i.e.,
4152it is the affine Kalman-Bucy smoother problem.
4153
4154<br/>
4155<br/>
4156<b><big><a name="4.j" id="4.j">4.j: g</a></big></b>
4157<br/>
4158The argument <i>g</i> is a two dimensional array,
4159for
4160<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4161<mi mathvariant='italic'>k</mi>
4162<mo stretchy="false">=</mo>
4163<mn>1</mn>
4164<mo stretchy="false">,</mo>
4165<mo stretchy="false">&#x02026;</mo>
4166<mo stretchy="false">,</mo>
4167<mi mathvariant='italic'>N</mi>
4168</mrow></math>
4169
4170
4171
4172<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
4173<msub><mi mathvariant='italic'>g</mi>
4174<mi mathvariant='italic'>k</mi>
4175</msub>
4176<mo stretchy="false">=</mo>
4177<mi mathvariant='italic'>g</mi>
4178<mo stretchy="false">(</mo>
4179<mo stretchy="false">:</mo>
4180<mo stretchy="false">,</mo>
4181<mi mathvariant='italic'>k</mi>
4182<mo stretchy="false">)</mo>
4183</mrow></math>
4184
4185and <i>g</i> has size
4186<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4187<mi mathvariant='italic'>n</mi>
4188<mo stretchy="false">&#x000D7;</mo>
4189<mi mathvariant='italic'>N</mi>
4190</mrow></math>
4191
4192.
4193The value
4194<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4195<msub><mi mathvariant='italic'>g</mi>
4196<mn>1</mn>
4197</msub>
4198</mrow></math>
4199
4200 serves as the initial state estimate.
4201
4202<br/>
4203<br/>
4204<b><big><a name="4.k" id="4.k">4.k: h</a></big></b>
4205<br/>
4206The argument <i>h</i> is a two dimensional array,
4207for
4208<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4209<mi mathvariant='italic'>k</mi>
4210<mo stretchy="false">=</mo>
4211<mn>1</mn>
4212<mo stretchy="false">,</mo>
4213<mo stretchy="false">&#x02026;</mo>
4214<mo stretchy="false">,</mo>
4215<mi mathvariant='italic'>N</mi>
4216</mrow></math>
4217
4218
4219
4220<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
4221<msub><mi mathvariant='italic'>h</mi>
4222<mi mathvariant='italic'>k</mi>
4223</msub>
4224<mo stretchy="false">=</mo>
4225<mi mathvariant='italic'>h</mi>
4226<mo stretchy="false">(</mo>
4227<mo stretchy="false">:</mo>
4228<mo stretchy="false">,</mo>
4229<mi mathvariant='italic'>k</mi>
4230<mo stretchy="false">)</mo>
4231</mrow></math>
4232
4233and <i>h</i> has size
4234<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4235<mi mathvariant='italic'>m</mi>
4236<mo stretchy="false">&#x000D7;</mo>
4237<mi mathvariant='italic'>N</mi>
4238</mrow></math>
4239
4240.
4241
4242<br/>
4243<br/>
4244<b><big><a name="4.l" id="4.l">4.l: db</a></big></b>
4245<br/>
4246The argument <i>db</i> is a three dimensional array,
4247for
4248<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4249<mi mathvariant='italic'>k</mi>
4250<mo stretchy="false">=</mo>
4251<mn>1</mn>
4252<mo stretchy="false">,</mo>
4253<mo stretchy="false">&#x02026;</mo>
4254<mo stretchy="false">,</mo>
4255<mi mathvariant='italic'>N</mi>
4256</mrow></math>
4257
4258
4259
4260<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
4261<msub><mi mathvariant='italic'>B</mi>
4262<mi mathvariant='italic'>k</mi>
4263</msub>
4264<mo stretchy="false">=</mo>
4265<mi mathvariant='italic'>db</mi>
4266<mo stretchy="false">(</mo>
4267<mo stretchy="false">:</mo>
4268<mo stretchy="false">,</mo>
4269<mo stretchy="false">:</mo>
4270<mo stretchy="false">,</mo>
4271<mi mathvariant='italic'>k</mi>
4272<mo stretchy="false">)</mo>
4273</mrow></math>
4274
4275and <i>db</i> has size
4276<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4277<mo stretchy="false">&#x02113;</mo>
4278<mo stretchy="false">&#x000D7;</mo>
4279<mi mathvariant='italic'>n</mi>
4280<mo stretchy="false">&#x000D7;</mo>
4281<mi mathvariant='italic'>N</mi>
4282</mrow></math>
4283
4284.
4285
4286
4287<br/>
4288<br/>
4289<b><big><a name="4.m" id="4.m">4.m: dg</a></big></b>
4290<br/>
4291The argument <i>dg</i> is a three dimensional array,
4292for
4293<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4294<mi mathvariant='italic'>k</mi>
4295<mo stretchy="false">=</mo>
4296<mn>1</mn>
4297<mo stretchy="false">,</mo>
4298<mo stretchy="false">&#x02026;</mo>
4299<mo stretchy="false">,</mo>
4300<mi mathvariant='italic'>N</mi>
4301</mrow></math>
4302
4303
4304
4305<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
4306<msub><mi mathvariant='italic'>G</mi>
4307<mi mathvariant='italic'>k</mi>
4308</msub>
4309<mo stretchy="false">=</mo>
4310<mi mathvariant='italic'>dg</mi>
4311<mo stretchy="false">(</mo>
4312<mo stretchy="false">:</mo>
4313<mo stretchy="false">,</mo>
4314<mo stretchy="false">:</mo>
4315<mo stretchy="false">,</mo>
4316<mi mathvariant='italic'>k</mi>
4317<mo stretchy="false">)</mo>
4318</mrow></math>
4319
4320and <i>dg</i> has size
4321<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4322<mi mathvariant='italic'>n</mi>
4323<mo stretchy="false">&#x000D7;</mo>
4324<mi mathvariant='italic'>n</mi>
4325<mo stretchy="false">&#x000D7;</mo>
4326<mi mathvariant='italic'>N</mi>
4327</mrow></math>
4328
4329.
4330The initial state estimate
4331<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4332<msub><mi mathvariant='italic'>g</mi>
4333<mn>1</mn>
4334</msub>
4335</mrow></math>
4336
4337 does not depend on the value of
4338
4339<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4340<msub><mi mathvariant='italic'>x</mi>
4341<mn>0</mn>
4342</msub>
4343</mrow></math>
4344
4345, hence
4346<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4347<msub><mi mathvariant='italic'>G</mi>
4348<mn>1</mn>
4349</msub>
4350</mrow></math>
4351
4352 should be zero.
4353
4354<br/>
4355<br/>
4356<b><big><a name="4.n" id="4.n">4.n: dh</a></big></b>
4357<br/>
4358The argument <i>dh</i> is a three dimensional array,
4359for
4360<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4361<mi mathvariant='italic'>k</mi>
4362<mo stretchy="false">=</mo>
4363<mn>1</mn>
4364<mo stretchy="false">,</mo>
4365<mo stretchy="false">&#x02026;</mo>
4366<mo stretchy="false">,</mo>
4367<mi mathvariant='italic'>N</mi>
4368</mrow></math>
4369
4370
4371
4372<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
4373<msub><mi mathvariant='italic'>H</mi>
4374<mi mathvariant='italic'>k</mi>
4375</msub>
4376<mo stretchy="false">=</mo>
4377<mi mathvariant='italic'>dh</mi>
4378<mo stretchy="false">(</mo>
4379<mo stretchy="false">:</mo>
4380<mo stretchy="false">,</mo>
4381<mo stretchy="false">:</mo>
4382<mo stretchy="false">,</mo>
4383<mi mathvariant='italic'>k</mi>
4384<mo stretchy="false">)</mo>
4385</mrow></math>
4386
4387and <i>dh</i> has size
4388<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4389<mi mathvariant='italic'>m</mi>
4390<mo stretchy="false">&#x000D7;</mo>
4391<mi mathvariant='italic'>n</mi>
4392<mo stretchy="false">&#x000D7;</mo>
4393<mi mathvariant='italic'>N</mi>
4394</mrow></math>
4395
4396.
4397
4398<br/>
4399<br/>
4400<b><big><a name="4.o" id="4.o">4.o: qinv</a></big></b>
4401<br/>
4402The argument <i>qinv</i> is a three dimensional array,
4403for
4404<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4405<mi mathvariant='italic'>k</mi>
4406<mo stretchy="false">=</mo>
4407<mn>1</mn>
4408<mo stretchy="false">,</mo>
4409<mo stretchy="false">&#x02026;</mo>
4410<mo stretchy="false">,</mo>
4411<mi mathvariant='italic'>N</mi>
4412</mrow></math>
4413
4414
4415
4416<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
4417<msubsup><mi mathvariant='italic'>Q</mi>
4418<mi mathvariant='italic'>k</mi>
4419<mrow><mn>-1</mn>
4420</mrow>
4421</msubsup>
4422<mo stretchy="false">=</mo>
4423<mi mathvariant='italic'>qinv</mi>
4424<mo stretchy="false">(</mo>
4425<mo stretchy="false">:</mo>
4426<mo stretchy="false">,</mo>
4427<mo stretchy="false">:</mo>
4428<mo stretchy="false">,</mo>
4429<mi mathvariant='italic'>k</mi>
4430<mo stretchy="false">)</mo>
4431</mrow></math>
4432
4433and <i>qinv</i> has size
4434<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4435<mi mathvariant='italic'>n</mi>
4436<mo stretchy="false">&#x000D7;</mo>
4437<mi mathvariant='italic'>n</mi>
4438<mo stretchy="false">&#x000D7;</mo>
4439<mi mathvariant='italic'>N</mi>
4440</mrow></math>
4441
4442.
4443The value of
4444<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4445<msub><mi mathvariant='italic'>Q</mi>
4446<mi mathvariant='italic'>k</mi>
4447</msub>
4448</mrow></math>
4449
4450 is the variance of the initial state
4451estimate
4452<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4453<msub><mi mathvariant='italic'>g</mi>
4454<mn>1</mn>
4455</msub>
4456</mrow></math>
4457
4458.
4459
4460<br/>
4461<br/>
4462<b><big><a name="4.p" id="4.p">4.p: rinv</a></big></b>
4463<br/>
4464The argument <i>rinv</i> is a three dimensional array,
4465for
4466<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4467<mi mathvariant='italic'>k</mi>
4468<mo stretchy="false">=</mo>
4469<mn>1</mn>
4470<mo stretchy="false">,</mo>
4471<mo stretchy="false">&#x02026;</mo>
4472<mo stretchy="false">,</mo>
4473<mi mathvariant='italic'>N</mi>
4474</mrow></math>
4475
4476
4477
4478<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
4479<msubsup><mi mathvariant='italic'>R</mi>
4480<mi mathvariant='italic'>k</mi>
4481<mrow><mn>-1</mn>
4482</mrow>
4483</msubsup>
4484<mo stretchy="false">=</mo>
4485<mi mathvariant='italic'>rinv</mi>
4486<mo stretchy="false">(</mo>
4487<mo stretchy="false">:</mo>
4488<mo stretchy="false">,</mo>
4489<mo stretchy="false">:</mo>
4490<mo stretchy="false">,</mo>
4491<mi mathvariant='italic'>k</mi>
4492<mo stretchy="false">)</mo>
4493</mrow></math>
4494
4495and <i>rinv</i> has size
4496<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4497<mi mathvariant='italic'>m</mi>
4498<mo stretchy="false">&#x000D7;</mo>
4499<mi mathvariant='italic'>m</mi>
4500<mo stretchy="false">&#x000D7;</mo>
4501<mi mathvariant='italic'>N</mi>
4502</mrow></math>
4503
4504.
4505It is ok to signify a missing data value by setting the corresponding
4506row and column of <i>rinv</i> to zero. This also enables use
4507to interpolate the state vector
4508<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4509<msub><mi mathvariant='italic'>x</mi>
4510<mi mathvariant='italic'>k</mi>
4511</msub>
4512</mrow></math>
4513
4514 to points where
4515there are no measurements.
4516
4517<br/>
4518<br/>
4519<b><big><a name="4.q" id="4.q">4.q: xOut</a></big></b>
4520<br/>
4521The result <i>xOut</i> contains the optimal sequence
4522
4523<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4524<mo stretchy="false">(</mo>
4525<msub><mi mathvariant='italic'>x</mi>
4526<mn>1</mn>
4527</msub>
4528<mo stretchy="false">,</mo>
4529<mo stretchy="false">&#x02026;</mo>
4530<mo stretchy="false">,</mo>
4531<msub><mi mathvariant='italic'>x</mi>
4532<mi mathvariant='italic'>N</mi>
4533</msub>
4534<mo stretchy="false">)</mo>
4535</mrow></math>
4536
4537.
4538For
4539<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4540<mi mathvariant='italic'>k</mi>
4541<mo stretchy="false">=</mo>
4542<mn>1</mn>
4543<mo stretchy="false">,</mo>
4544<mo stretchy="false">&#x02026;</mo>
4545<mo stretchy="false">,</mo>
4546<mi mathvariant='italic'>N</mi>
4547</mrow></math>
4548
4549
4550
4551<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
4552<msub><mi mathvariant='italic'>x</mi>
4553<mi mathvariant='italic'>k</mi>
4554</msub>
4555<mo stretchy="false">=</mo>
4556<mi mathvariant='italic'>xOut</mi>
4557<mo stretchy="false">(</mo>
4558<mo stretchy="false">:</mo>
4559<mo stretchy="false">,</mo>
4560<mi mathvariant='italic'>k</mi>
4561<mo stretchy="false">)</mo>
4562</mrow></math>
4563
4564and <i>xOut</i> is a two dimensional array with size
4565<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4566<mi mathvariant='italic'>n</mi>
4567<mo stretchy="false">&#x000D7;</mo>
4568<mi mathvariant='italic'>N</mi>
4569</mrow></math>
4570
4571.
4572
4573<br/>
4574<br/>
4575<b><big><a name="4.r" id="4.r">4.r: uOut</a></big></b>
4576<br/>
4577The result <i>uOut</i> contains the Lagrange multiplier sequence
4578corresponding to <i>xOut</i>.
4579For
4580<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4581<mi mathvariant='italic'>k</mi>
4582<mo stretchy="false">=</mo>
4583<mn>1</mn>
4584<mo stretchy="false">,</mo>
4585<mo stretchy="false">&#x02026;</mo>
4586<mo stretchy="false">,</mo>
4587<mi mathvariant='italic'>N</mi>
4588</mrow></math>
4589
4590
4591
4592<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
4593<msub><mi mathvariant='italic'>u</mi>
4594<mi mathvariant='italic'>k</mi>
4595</msub>
4596<mo stretchy="false">=</mo>
4597<mi mathvariant='italic'>uOut</mi>
4598<mo stretchy="false">(</mo>
4599<mo stretchy="false">:</mo>
4600<mo stretchy="false">,</mo>
4601<mi mathvariant='italic'>k</mi>
4602<mo stretchy="false">)</mo>
4603</mrow></math>
4604
4605and <i>uOut</i> is a two dimensional array with size
4606
4607<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4608<mo stretchy="false">&#x02113;</mo>
4609<mo stretchy="false">&#x000D7;</mo>
4610<mi mathvariant='italic'>N</mi>
4611</mrow></math>
4612
4613.
4614The pair <i>xOut</i>, <i>uOut</i> satisfy the
4615<a href="#4.e">4.e: <span style='white-space: nowrap'>first&#xA0;order&#xA0;conditions</span></a>
4616.
4617
4618<br/>
4619<br/>
4620<b><big><a name="4.s" id="4.s">4.s: info</a></big></b>
4621<br/>
4622The result <i>info</i> is a matrix with each row corresponding
4623to an iteration of the algorithm.
4624Note that <code><font color="blue">ckbs_affine</font></code> has satisfied the convergence condition if
4625and only if
4626<code><font color="blue"><span style='white-space: nowrap'><br/>
4627&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;all(&#xA0;</span></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>(end,&#xA0;1:3)&#xA0;&lt;=&#xA0;</span></font></code><i><span style='white-space: nowrap'>epsilon</span></i><code><font color="blue"><span style='white-space: nowrap'>&#xA0;)<br/>
4628</span></font></code><code><span style='white-space: nowrap'><br/>
4629<br/>
4630</span></code>We use
4631<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4632<msubsup><mi mathvariant='italic'>x</mi>
4633<mi mathvariant='italic'>k</mi>
4634<mi mathvariant='italic'>q</mi>
4635</msubsup>
4636</mrow></math>
4637
4638 (
4639<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4640<msubsup><mi mathvariant='italic'>u</mi>
4641<mi mathvariant='italic'>k</mi>
4642<mi mathvariant='italic'>q</mi>
4643</msubsup>
4644</mrow></math>
4645
4646)
4647to denote the state vector (dual vector)
4648for time point
4649<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4650<mi mathvariant='italic'>k</mi>
4651</mrow></math>
4652
4653 and at the end of iteration
4654<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4655<mi mathvariant='italic'>q</mi>
4656<mn>-1</mn>
4657</mrow></math>
4658
4659
4660We use
4661<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4662<msubsup><mi mathvariant='italic'>d</mi>
4663<mi mathvariant='italic'>k</mi>
4664<mi mathvariant='italic'>q</mi>
4665</msubsup>
4666</mrow></math>
4667
4668 for the partial derivative of
4669
4670<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4671<mi mathvariant='italic'>S</mi>
4672<mo stretchy="false">(</mo>
4673<msubsup><mi mathvariant='italic'>x</mi>
4674<mn>1</mn>
4675<mi mathvariant='italic'>q</mi>
4676</msubsup>
4677<mo stretchy="false">,</mo>
4678<mo stretchy="false">&#x02026;</mo>
4679<mo stretchy="false">,</mo>
4680<msubsup><mi mathvariant='italic'>x</mi>
4681<mi mathvariant='italic'>N</mi>
4682<mi mathvariant='italic'>q</mi>
4683</msubsup>
4684<mo stretchy="false">)</mo>
4685</mrow></math>
4686
4687 with respect to
4688<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4689<msub><mi mathvariant='italic'>x</mi>
4690<mi mathvariant='italic'>k</mi>
4691</msub>
4692</mrow></math>
4693
4694.
4695
4696<br/>
4697<br/>
4698<b><a name="4.s.a" id="4.s.a">4.s.a: Constraint Bound</a></b>
4699<br/>
4700The value <code><font color="blue"></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>(</span></font></code><i><span style='white-space: nowrap'>q</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;1)</span></font></code> is
4701a bound on the constraint functions
4702at the end of iteration
4703<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4704<mi mathvariant='italic'>q</mi>
4705<mn>-1</mn>
4706</mrow></math>
4707
4708. To be specific
4709
4710<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
4711<mi mathvariant='italic'>info</mi>
4712<mo stretchy="false">(</mo>
4713<mi mathvariant='italic'>q</mi>
4714<mo stretchy="false">,</mo>
4715<mn>1</mn>
4716<mo stretchy="false">)</mo>
4717<mo stretchy="false">=</mo>
4718<munder><mi>max</mi>
4719<mrow><mi mathvariant='italic'>i</mi>
4720<mo stretchy="false">,</mo>
4721<mi mathvariant='italic'>k</mi>
4722</mrow>
4723</munder>
4724<mo stretchy="false">(</mo>
4725<msub><mi mathvariant='italic'>b</mi>
4726<mi mathvariant='italic'>k</mi>
4727</msub>
4728<mo stretchy="false">+</mo>
4729<msub><mi mathvariant='italic'>B</mi>
4730<mi mathvariant='italic'>k</mi>
4731</msub>
4732<mo stretchy="false">*</mo>
4733<msub><mi mathvariant='italic'>x</mi>
4734<mi mathvariant='italic'>k</mi>
4735</msub>
4736<msub><mo stretchy="false">)</mo>
4737<mi mathvariant='italic'>i</mi>
4738</msub>
4739</mrow></math>
4740
4741<br/>
4742<b><a name="4.s.b" id="4.s.b">4.s.b: First Order Conditions</a></b>
4743<br/>
4744The value <code><font color="blue"></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>(</span></font></code><i><span style='white-space: nowrap'>q</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;2)</span></font></code> is
4745a bound on the partial derivative of the Lagrangian with respect to
4746the state vector sequence
4747at the end of iteration
4748<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4749<mi mathvariant='italic'>q</mi>
4750<mn>-1</mn>
4751</mrow></math>
4752
4753:
4754
4755<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
4756<mi mathvariant='italic'>info</mi>
4757<mo stretchy="false">(</mo>
4758<mi mathvariant='italic'>q</mi>
4759<mo stretchy="false">,</mo>
4760<mn>2</mn>
4761<mo stretchy="false">)</mo>
4762<mo stretchy="false">=</mo>
4763<mi>max</mi>
4764<mrow><mo stretchy="true">[</mo><mrow><mo stretchy="false">|</mo>
4765<mo stretchy="false">(</mo>
4766<msubsup><mi mathvariant='italic'>B</mi>
4767<mi mathvariant='italic'>k</mi>
4768<mi mathvariant='italic'>T</mi>
4769</msubsup>
4770<mo stretchy="false">*</mo>
4771<msub><mi mathvariant='italic'>u</mi>
4772<mi mathvariant='italic'>k</mi>
4773</msub>
4774<mo stretchy="false">+</mo>
4775<msub><mi mathvariant='italic'>d</mi>
4776<mi mathvariant='italic'>k</mi>
4777</msub>
4778<msub><mo stretchy="false">)</mo>
4779<mi mathvariant='italic'>j</mi>
4780</msub>
4781<mo stretchy="false">|</mo>
4782</mrow><mo stretchy="true">]</mo></mrow>
4783</mrow></math>
4784
4785where the maximum is with respect to
4786<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4787<mi mathvariant='italic'>j</mi>
4788<mo stretchy="false">=</mo>
4789<mn>1</mn>
4790<mo stretchy="false">,</mo>
4791<mo stretchy="false">&#x02026;</mo>
4792<mo stretchy="false">,</mo>
4793<mi mathvariant='italic'>n</mi>
4794</mrow></math>
4795
4796
4797and
4798<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4799<mi mathvariant='italic'>k</mi>
4800<mo stretchy="false">=</mo>
4801<mn>1</mn>
4802<mo stretchy="false">,</mo>
4803<mo stretchy="false">&#x02026;</mo>
4804<mo stretchy="false">,</mo>
4805<mi mathvariant='italic'>N</mi>
4806</mrow></math>
4807
4808.
4809
4810<br/>
4811<br/>
4812<b><a name="4.s.c" id="4.s.c">4.s.c: Complementarity Conditions</a></b>
4813<br/>
4814The value <code><font color="blue"></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>(</span></font></code><i><span style='white-space: nowrap'>q</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;3)</span></font></code> is
4815a bound on the complementarity conditions
4816at the end of iteration
4817<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4818<mi mathvariant='italic'>q</mi>
4819<mn>-1</mn>
4820</mrow></math>
4821
4822:
4823
4824<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
4825<mi mathvariant='italic'>info</mi>
4826<mo stretchy="false">(</mo>
4827<mi mathvariant='italic'>q</mi>
4828<mo stretchy="false">,</mo>
4829<mn>3</mn>
4830<mo stretchy="false">)</mo>
4831<mo stretchy="false">=</mo>
4832<mi>max</mi>
4833<mrow><mo stretchy="true">[</mo><mrow><mo stretchy="false">|</mo>
4834<mo stretchy="false">(</mo>
4835<msub><mi mathvariant='italic'>u</mi>
4836<mi mathvariant='italic'>k</mi>
4837</msub>
4838<msub><mo stretchy="false">)</mo>
4839<mi mathvariant='italic'>i</mi>
4840</msub>
4841<mo stretchy="false">*</mo>
4842<mo stretchy="false">(</mo>
4843<msub><mi mathvariant='italic'>b</mi>
4844<mi mathvariant='italic'>k</mi>
4845</msub>
4846<mo stretchy="false">+</mo>
4847<msub><mi mathvariant='italic'>B</mi>
4848<mi mathvariant='italic'>k</mi>
4849</msub>
4850<mo stretchy="false">*</mo>
4851<msub><mi mathvariant='italic'>x</mi>
4852<mi mathvariant='italic'>k</mi>
4853</msub>
4854<msub><mo stretchy="false">)</mo>
4855<mi mathvariant='italic'>i</mi>
4856</msub>
4857<mo stretchy="false">|</mo>
4858</mrow><mo stretchy="true">]</mo></mrow>
4859</mrow></math>
4860
4861where the maximum is with respect to
4862
4863<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4864<mi mathvariant='italic'>i</mi>
4865<mo stretchy="false">=</mo>
4866<mn>1</mn>
4867<mo stretchy="false">,</mo>
4868<mo stretchy="false">&#x02026;</mo>
4869<mo stretchy="false">,</mo>
4870<mo stretchy="false">&#x02113;</mo>
4871</mrow></math>
4872
4873 and
4874
4875<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4876<mi mathvariant='italic'>k</mi>
4877<mo stretchy="false">=</mo>
4878<mn>1</mn>
4879<mo stretchy="false">,</mo>
4880<mo stretchy="false">&#x02026;</mo>
4881<mo stretchy="false">,</mo>
4882<mi mathvariant='italic'>N</mi>
4883</mrow></math>
4884
4885.
4886
4887
4888<br/>
4889<br/>
4890<b><a name="4.s.d" id="4.s.d">4.s.d: Step Size</a></b>
4891<br/>
4892The value <code><font color="blue"></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>(</span></font></code><i><span style='white-space: nowrap'>q</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;4)</span></font></code> is the line search step size used during
4893iteration
4894<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4895<mi mathvariant='italic'>q</mi>
4896<mn>-1</mn>
4897</mrow></math>
4898
4899.
4900Small step sizes indicate problems with the interior point method
4901used to solve the affine problem
4902(with the exception that <code><font color="blue"></font></code><i><span style='white-space: nowrap'>info</span></i><code><font color="blue"><span style='white-space: nowrap'>(1,&#xA0;4)</span></font></code> is always zero).
4903
4904
4905
4906
4907<br/>
4908<br/>
4909<b><big><a name="4.t" id="4.t">4.t: Example</a></big></b>
4910<br/>
4911The file <a href="#4.1">4.1: <span style='white-space: nowrap'>affine_ok_box.m</span></a>
4912 contains an example and test of
4913<code><font color="blue">ckbs_affine</font></code>.
4914It returns true if <code><font color="blue">ckbs_affine</font></code> passes the test
4915and false otherwise.
4916
4917
4918<hr/>Input File: src/ckbs_affine.m
4919
4920<hr/>
4921 
4922
4923
4924<center><b><big><big><a name="4.1" id="4.1">4.1: ckbs_affine Box Constrained Smoothing Spline Example and Test</a>
4925</big></big></b></center>
4926<br/>
4927<b><big><a name="4.1.a" id="4.1.a">4.1.a: Syntax</a></big></b>
4928
4929<br/>
4930<code><font color="blue"><span style='white-space: nowrap'>[</span></font></code><i><span style='white-space: nowrap'>ok</span></i><code><font color="blue"><span style='white-space: nowrap'>]&#xA0;=&#xA0;affine_ok_box(</span></font></code><i><span style='white-space: nowrap'>draw_plot</span></i><code><font color="blue"><span style='white-space: nowrap'>)</span></font></code>
4931
4932<br/>
4933<br/>
4934<b><big><a name="4.1.b" id="4.1.b">4.1.b: draw_plot</a></big></b>
4935<br/>
4936If this argument is true, a plot is drawn showing the results
4937and the <code><font color="blue">nonlinear_ok_box.out</font></code> file is written for use with
4938the program <code><font color="blue">nonlinear_ok_box.r</font></code>.
4939
4940<br/>
4941<br/>
4942<b><big><a name="4.1.c" id="4.1.c">4.1.c: ok</a></big></b>
4943<br/>
4944If the return value <i>ok</i> is true, the test passed,
4945otherwise the test failed.
4946
4947<br/>
4948<br/>
4949<b><big><a name="4.1.d" id="4.1.d">4.1.d: State Vector</a></big></b>
4950
4951<table><tr><td align='left'  valign='top'>
4952
4953
4954<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4955<mi mathvariant='italic'>x</mi>
4956<mn>1</mn>
4957<mo stretchy="false">(</mo>
4958<mi mathvariant='italic'>t</mi>
4959<mo stretchy="false">)</mo>
4960</mrow></math>
4961
4962 </td><td align='left'  valign='top'>
4963 derivative of function we are estimating </td></tr><tr><td align='left'  valign='top'>
4964
4965
4966<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4967<mi mathvariant='italic'>x</mi>
4968<mn>2</mn>
4969<mo stretchy="false">(</mo>
4970<mi mathvariant='italic'>t</mi>
4971<mo stretchy="false">)</mo>
4972</mrow></math>
4973
4974 </td><td align='left'  valign='top'>
4975 value of function we are estimating
4976</td></tr>
4977</table>
4978<br/>
4979<b><big><a name="4.1.e" id="4.1.e">4.1.e: Measurement</a></big></b>
4980
4981<br/>
4982
4983<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4984<mi mathvariant='italic'>z</mi>
4985<mn>1</mn>
4986<mo stretchy="false">(</mo>
4987<mi mathvariant='italic'>t</mi>
4988<mo stretchy="false">)</mo>
4989</mrow></math>
4990
4991value of
4992<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
4993<mi mathvariant='italic'>x</mi>
4994<mn>2</mn>
4995<mo stretchy="false">(</mo>
4996<mi mathvariant='italic'>t</mi>
4997<mo stretchy="false">)</mo>
4998</mrow></math>
4999
5000 plus noise
5001
5002<br/>
5003<br/>
5004<b><big><a name="4.1.f" id="4.1.f">4.1.f: Constraint</a></big></b>
5005
5006
5007<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
5008<mtable rowalign="center" ><mtr><mtd columnalign="center" >
5009<mn>-1</mn>
5010<mo stretchy="false">&#x02264;</mo>
5011<mi mathvariant='italic'>x</mi>
5012<mn>1</mn>
5013<mo stretchy="false">(</mo>
5014<mi mathvariant='italic'>t</mi>
5015<mo stretchy="false">)</mo>
5016<mo stretchy="false">&#x02264;</mo>
5017<mo stretchy="false">+</mo>
5018<mn>1</mn>
5019</mtd></mtr><mtr><mtd columnalign="center" >
5020<mn>-1</mn>
5021<mo stretchy="false">&#x02264;</mo>
5022<mi mathvariant='italic'>x</mi>
5023<mn>2</mn>
5024<mo stretchy="false">(</mo>
5025<mi mathvariant='italic'>t</mi>
5026<mo stretchy="false">)</mo>
5027<mo stretchy="false">&#x02264;</mo>
5028<mo stretchy="false">+</mo>
5029<mn>1</mn>
5030</mtd></mtr></mtable>
5031</mrow></math>
5032
5033.
5034
5035<br/>
5036<br/>
5037<b><big><a name="4.1.g" id="4.1.g">4.1.g: Source Code</a></big></b>
5038
5039
5040 <code><font color='blue'><pre style='display:inline'> 
5041function [ok] = affine_ok_box(draw_plot)
5042% --------------------------------------------------------
5043% You can change these parameters
5044N     = 50;        % number of measurement time points
5045dt    = 2*pi / N;  % time between measurement points
5046gamma =  1;        % transition covariance multiplier
5047sigma =  .5;       % standard deviation of measurement noise
5048max_itr = 30;      % maximum number of iterations
5049epsilon = 1e-5;    % convergence criteria
5050h_min   = 0;       % minimum horizontal value in plots
5051h_max   = 7;       % maximum horizontal value in plots
5052v_min   = -2.0;    % minimum vertical value in plots
5053v_max   = +2.0;    % maximum vertical value in plots
5054% ---------------------------------------------------------
5055ok = true;
5056if nargin &lt; 1
5057        draw_plot = false;
5058end
5059%  Define the problem
5060rand('seed', 1234);
5061%
5062% number of constraints per time point
5063ell   = 4;
5064%
5065% number of measurements per time point
5066m     = 1;
5067%
5068% number of state vector components per time point
5069n     = 2;
5070%
5071% simulate the true trajectory and measurement noise
5072t       =  (1 : N) * dt;
5073x1_true = - cos(t);
5074x2_true = - sin(t);
5075x_true  = [ x1_true ; x2_true ];
5076v_true  = sigma * rand(1, N);
5077%
5078% measurement values and model
5079v_true  = sigma * randn(1, N);
5080z       = x2_true + v_true;
5081rk      = sigma * sigma;
5082rinvk   = 1 / rk;
5083rinv    = zeros(m, m, N);
5084h       = zeros(m, N);
5085dh      = zeros(m, n, N);
5086for k = 1 : N
5087        rinv(:, :, k) = rinvk;
5088        h(:, k)       = 0;
5089        dh(:,:, k)    = [ 0 , 1 ];
5090end
5091%
5092% transition model
5093g       = zeros(n, N);
5094dg      = zeros(n, n, N);
5095qinv    = zeros(n, n, N);
5096qk      = gamma * [ dt , dt^2/2 ; dt^2/2 , dt^3/3 ];
5097qinvk   = inv(qk);
5098for k = 2 : N
5099        g(:, k)       = 0;
5100        dg(:,:, k)    = [ 1 , 0 ; dt , 1 ];
5101        qinv(:,:, k)  = qinvk;
5102end
5103%
5104% initial state estimate
5105g(:, 1)      = x_true(:, 1);
5106qinv(:,:, 1) = 100 * eye(2);
5107%
5108% constraints
5109b       = zeros(ell, N);
5110db      = zeros(ell, n, N);
5111for k = 1 : N
5112        %
5113        % b(:, k) + db(:,:, k) * x(:, k) &lt;= 0
5114        b(:, k)    = [ -1 ; -1 ; -1 ; -1 ];
5115        db(:,:, k) = [ -1 , 0 ; 1 , 0 ; 0 , -1 ; 0 , 1 ];
5116end
5117%
5118% -------------------------------------------------------------------------
5119[xOut, uOut, info] = ...
5120        ckbs_affine(max_itr, epsilon, z, b, g, h, db, dg, dh, qinv, rinv);
5121% --------------------------------------------------------------------------
5122ok   = ok &amp; all( info(end, 1:3) &lt;= epsilon);
5123d    = ckbs_sumsq_grad(xOut, z, g, h, dg, dh, qinv, rinv);
5124for k = 1 : N
5125        xk = xOut(:, k);
5126        uk = uOut(:, k);
5127        bk = b(:, k);
5128        Bk = db(:,:, k);
5129        dk = d(:, k);
5130        sk = - bk - Bk * xk;
5131        %
5132        ok = ok &amp; (min(uk) &gt;= 0.);
5133        ok = ok &amp; (max (bk + Bk * xk) &lt;= epsilon);
5134        ok = ok &amp; (max ( abs( Bk' * uk + dk ) ) &lt;= epsilon);
5135        ok = ok &amp; (max ( uk .* sk ) &lt;= epsilon );
5136end
5137if draw_plot
5138        figure(1);
5139        clf
5140        hold on
5141        plot(t', x_true(2,:)', 'r-' );
5142        plot(t', z(1,:)', 'ko' );
5143        plot(t', xOut(2,:)', 'b-' );
5144        plot(t', - ones(N,1), 'b-');
5145        plot(t', ones(N,1), 'b-');
5146        axis([h_min, h_max, v_min, v_max]);
5147        title('Constrained');
5148        hold off
5149        %
5150        % constrained estimate
5151        x_con = xOut;
5152end
5153%
5154% Unconstrained Case
5155b           = zeros(0, N);
5156db          = zeros(0, n, N);
5157% -------------------------------------------------------------------------
5158[xOut, uOut, info] = ...
5159        ckbs_affine(max_itr, epsilon, z, b, g, h, db, dg, dh, qinv, rinv);
5160% --------------------------------------------------------------------------
5161ok   = ok &amp; all( info(end, 1:3) &lt;= epsilon);
5162d    = ckbs_sumsq_grad(xOut, z, g, h, dg, dh, qinv, rinv);
5163for k = 1 : N
5164        xk = xOut(:, k);
5165        dk = d(:, k);
5166        %
5167        ok = ok &amp; (min(dk) &lt;= epsilon);
5168end
5169if draw_plot
5170        figure(2);
5171        clf
5172        hold on
5173        plot(t', x_true(2,:)', 'r-' );
5174        plot(t', z(1,:)', 'ko' );
5175        plot(t', xOut(2,:)', 'b-' );
5176        plot(t', - ones(N,1), 'b-');
5177        plot(t', ones(N,1), 'b-');
5178        axis([h_min, h_max, v_min, v_max]);
5179        title('Unconstrained');
5180        hold off
5181        %
5182        % unconstrained estimate
5183        x_free = xOut;
5184        %
5185        % write out constrained and unconstrained results
5186        [fid, msg] = fopen('affine_ok_box.out', 'wt');
5187        if size(msg, 2) &gt; 0
5188                disp(['affine_ok: ', msg]);
5189        end
5190        %                      123456789012345678901234'
5191        heading =             '       t';
5192        heading = [ heading , ' x2_true  x2_con x2_free' ];
5193        heading = [ heading , '      z1\n'               ];
5194        fprintf(fid, heading);
5195        for k = 1 : N
5196                fprintf(fid,'%8.3f%8.3f%8.3f%8.3f%8.3f\n', ...
5197                        t(k), ...
5198                        x_true(2,k), x_con(2,k), x_free(2,k), ...
5199                        z(1,k) ...
5200                );
5201        end
5202        fclose(fid);
5203end
5204return
5205end
5206</pre></font></code>
5207 
5208
5209<hr/>Input File: test/affine_ok_box.m
5210
5211<hr/>
5212
5213
5214
5215<center><b><big><big><a name="5" id="5">5: ckbs Utility Functions</a>
5216</big></big></b></center>
5217<br/>
5218<b><big><a name="5.a" id="5.a">5.a: Contents</a></big></b>
5219<br/>
5220<table>
5221<tr><td><a href="#5.1" target="_top">ckbs_blkdiag_mul:&#xA0;5.1</a></td><td>Packed&#xA0;Block&#xA0;Diagonal&#xA0;Matrix&#xA0;Times&#xA0;a&#xA0;Vector</td></tr><tr><td><a href="#5.2" target="_top">ckbs_blkdiag_mul_t:&#xA0;5.2</a></td><td>Transpose&#xA0;of&#xA0;Packed&#xA0;Block&#xA0;Diagonal&#xA0;Matrix&#xA0;Times&#xA0;a&#xA0;Vector</td></tr><tr><td><a href="#5.3" target="_top">ckbs_sumsq_obj:&#xA0;5.3</a></td><td>Affine&#xA0;Residual&#xA0;Sum&#xA0;of&#xA0;Squares&#xA0;Objective</td></tr><tr><td><a href="#5.4" target="_top">ckbs_sumsq_grad:&#xA0;5.4</a></td><td>Affine&#xA0;Residual&#xA0;Sum&#xA0;of&#xA0;Squares&#xA0;Gradient</td></tr><tr><td><a href="#5.5" target="_top">ckbs_sumsq_hes:&#xA0;5.5</a></td><td>Affine&#xA0;Residual&#xA0;Sum&#xA0;of&#xA0;Squares&#xA0;Hessian</td></tr><tr><td><a href="#5.6" target="_top">ckbs_tridiag_solve:&#xA0;5.6</a></td><td>Symmetric&#xA0;Block&#xA0;Tridiagonal&#xA0;Algorithm</td></tr><tr><td><a href="#5.7" target="_top">ckbs_newton_step:&#xA0;5.7</a></td><td>Affine&#xA0;Constrained&#xA0;Kalman&#xA0;Bucy&#xA0;Smoother&#xA0;Newton&#xA0;Step</td></tr><tr><td><a href="#5.8" target="_top">ckbs_kuhn_tucker:&#xA0;5.8</a></td><td>Compute&#xA0;Residual&#xA0;in&#xA0;Kuhn-Tucker&#xA0;Conditions</td></tr></table>
5222<hr/>Input File: omh/utility.omh
5223
5224<hr/>
5225<center><b><big><big><a name="5.1" id="5.1">5.1: Packed Block Diagonal Matrix Times a Vector</a>
5226</big></big></b></center>
5227<br/>
5228<b><big><a name="5.1.a" id="5.1.a">5.1.a: Syntax</a></big></b>
5229
5230<br/>
5231<code><font color="blue"><span style='white-space: nowrap'>[</span></font></code><i><span style='white-space: nowrap'>w</span></i><code><font color="blue"><span style='white-space: nowrap'>]&#xA0;=&#xA0;ckbs_blkdiag_mul(</span></font></code><i><span style='white-space: nowrap'>Bdia</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>v</span></i><code><font color="blue"><span style='white-space: nowrap'>)</span></font></code>
5232
5233<br/>
5234<br/>
5235<b><big><a name="5.1.b" id="5.1.b">5.1.b: Purpose</a></big></b>
5236<br/>
5237This routine enables one to used the packed form of a block diagonal matrix
5238and returns the matrix times a vector; i.e.,
5239
5240<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
5241<mi mathvariant='italic'>w</mi>
5242<mo stretchy="false">=</mo>
5243<mi mathvariant='italic'>B</mi>
5244<mo stretchy="false">*</mo>
5245<mi mathvariant='italic'>v</mi>
5246</mrow></math>
5247
5248<br/>
5249<b><big><a name="5.1.c" id="5.1.c">5.1.c: Bdia</a></big></b>
5250<br/>
5251The argument <i>Bdia</i> is an
5252<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
5253<mi mathvariant='italic'>m</mi>
5254<mo stretchy="false">&#x000D7;</mo>
5255<mi mathvariant='italic'>n</mi>
5256<mo stretchy="false">&#x000D7;</mo>
5257<mi mathvariant='italic'>N</mi>
5258</mrow></math>
5259
5260 array.
5261For
5262<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
5263<mi mathvariant='italic'>k</mi>
5264<mo stretchy="false">=</mo>
5265<mn>1</mn>
5266<mo stretchy="false">,</mo>
5267<mo stretchy="false">&#x02026;</mo>
5268<mo stretchy="false">,</mo>
5269<mi mathvariant='italic'>N</mi>
5270</mrow></math>
5271
5272 we define
5273<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
5274<msub><mi mathvariant='italic'>B</mi>
5275<mi mathvariant='italic'>k</mi>
5276</msub>
5277<mo stretchy="false">&#x02208;</mo>
5278<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
5279</mstyle></mrow>
5280<mrow><mi mathvariant='italic'>m</mi>
5281<mo stretchy="false">&#x000D7;</mo>
5282<mi mathvariant='italic'>n</mi>
5283</mrow>
5284</msup>
5285</mrow></math>
5286
5287 by
5288
5289<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
5290<msub><mi mathvariant='italic'>B</mi>
5291<mi mathvariant='italic'>k</mi>
5292</msub>
5293<mo stretchy="false">=</mo>
5294<mi mathvariant='italic'>Bdia</mi>
5295<mo stretchy="false">(</mo>
5296<mo stretchy="false">:</mo>
5297<mo stretchy="false">,</mo>
5298<mo stretchy="false">:</mo>
5299<mo stretchy="false">,</mo>
5300<mi mathvariant='italic'>k</mi>
5301<mo stretchy="false">)</mo>
5302</mrow></math>
5303
5304<br/>
5305<b><big><a name="5.1.d" id="5.1.d">5.1.d: B</a></big></b>
5306<br/>
5307The matrix
5308<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
5309<mi mathvariant='italic'>B</mi>
5310</mrow></math>
5311
5312 is defined by
5313
5314<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
5315<mi mathvariant='italic'>B</mi>
5316<mo stretchy="false">=</mo>
5317<mrow><mo stretchy="true">(</mo><mrow><mtable rowalign="center" ><mtr><mtd columnalign="center" >
5318<msub><mi mathvariant='italic'>B</mi>
5319<mn>1</mn>
5320</msub>
5321</mtd><mtd columnalign="center" >
5322<mn>0</mn>
5323</mtd><mtd columnalign="center" >
5324<mn>0</mn>
5325</mtd><mtd columnalign="center" >
5326</mtd></mtr><mtr><mtd columnalign="center" >
5327<mn>0</mn>
5328</mtd><mtd columnalign="center" >
5329<msub><mi mathvariant='italic'>B</mi>
5330<mn>2</mn>
5331</msub>
5332</mtd><mtd columnalign="center" >
5333<mn>0</mn>
5334</mtd><mtd columnalign="center" >
5335<mn>0</mn>
5336</mtd></mtr><mtr><mtd columnalign="center" >
5337<mn>0</mn>
5338</mtd><mtd columnalign="center" >
5339<mn>0</mn>
5340</mtd><mtd columnalign="center" >
5341<mo stretchy="false">&#x022F1;</mo>
5342</mtd><mtd columnalign="center" >
5343<mn>0</mn>
5344</mtd></mtr><mtr><mtd columnalign="center" >
5345</mtd><mtd columnalign="center" >
5346<mn>0</mn>
5347</mtd><mtd columnalign="center" >
5348<mn>0</mn>
5349</mtd><mtd columnalign="center" >
5350<msub><mi mathvariant='italic'>B</mi>
5351<mi mathvariant='italic'>N</mi>
5352</msub>
5353</mtd></mtr></mtable>
5354</mrow><mo stretchy="true">)</mo></mrow>
5355</mrow></math>
5356
5357<br/>
5358<b><big><a name="5.1.e" id="5.1.e">5.1.e: v</a></big></b>
5359<br/>
5360The argument <i>v</i> is a column vector of length
5361<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
5362<mi mathvariant='italic'>n</mi>
5363<mo stretchy="false">*</mo>
5364<mi mathvariant='italic'>N</mi>
5365</mrow></math>
5366
5367.
5368
5369<br/>
5370<br/>
5371<b><big><a name="5.1.f" id="5.1.f">5.1.f: w</a></big></b>
5372<br/>
5373The result <i>w</i> is a column vector of length
5374<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
5375<mi mathvariant='italic'>m</mi>
5376<mo stretchy="false">*</mo>
5377<mi mathvariant='italic'>N</mi>
5378</mrow></math>
5379
5380.
5381
5382
5383
5384
5385<br/>
5386<br/>
5387<b><big><a name="5.1.g" id="5.1.g">5.1.g: Example</a></big></b>
5388<br/>
5389The file <a href="#5.1.1">5.1.1: <span style='white-space: nowrap'>blkdiag_mul_ok.m</span></a>
5390 contains an example and test of
5391<code><font color="blue">ckbs_blkdiag_mul</font></code>.
5392It returns true if <code><font color="blue">ckbs_blkdiag_mul</font></code> passes the test
5393and false otherwise.
5394
5395
5396<hr/>Input File: src/ckbs_blkdiag_mul.m
5397
5398<hr/>
5399 
5400
5401
5402<center><b><big><big><a name="5.1.1" id="5.1.1">5.1.1: blkdiag_mul Example and Test</a>
5403</big></big></b></center>
5404<br/>
5405<b><big><a name="5.1.1.a" id="5.1.1.a">5.1.1.a: Source Code</a></big></b>
5406
5407 <code><font color='blue'><pre style='display:inline'> 
5408function [ok] = blkdiag_mul_ok()
5409ok = true;
5410% -------------------------------------------------------------
5411% You can change these parameters
5412m    = 2;
5413n    = 3;
5414N    = 2;
5415% -------------------------------------------------------------
5416% Define the problem
5417rand('seed', 123);
5418v     = rand(n * N, 1);
5419Bdiag = zeros(m, n, N);
5420B     = zeros(m * N , n * N);
5421blk_m = 1 : m;
5422blk_n = 1 : n;
5423for k = 1 : N
5424        Bdiag(:, :, k)  = rand(m, n);
5425        B(blk_m, blk_n) = Bdiag(:, :, k);
5426        blk_m           = blk_m + m;
5427        blk_n           = blk_n + n;
5428end
5429% -------------------------------------
5430w     = ckbs_blkdiag_mul(Bdiag, v);
5431% -------------------------------------
5432check = B * v;
5433ok    = ok &amp; ( max(abs(w - check)) &lt; 1e-10 );
5434return
5435end
5436</pre></font></code>
5437 
5438
5439<hr/>Input File: test/blkdiag_mul_ok.m
5440
5441<hr/>
5442 
5443
5444
5445<center><b><big><big><a name="5.2" id="5.2">5.2: Transpose of Packed Block Diagonal Matrix Times a Vector</a>
5446</big></big></b></center>
5447<br/>
5448<b><big><a name="5.2.a" id="5.2.a">5.2.a: Syntax</a></big></b>
5449
5450<br/>
5451<code><font color="blue"><span style='white-space: nowrap'>[</span></font></code><i><span style='white-space: nowrap'>w</span></i><code><font color="blue"><span style='white-space: nowrap'>]&#xA0;=&#xA0;ckbs_blkdiag_mul_t(</span></font></code><i><span style='white-space: nowrap'>Bdia</span></i><code><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font></code><i><span style='white-space: nowrap'>v</span></i><code><font color="blue"><span style='white-space: nowrap'>)</span></font></code>
5452
5453<br/>
5454<br/>
5455<b><big><a name="5.2.b" id="5.2.b">5.2.b: Purpose</a></big></b>
5456<br/>
5457This routine enables one to used the packed form of a block diagonal matrix
5458and returns the transpose of the matrix times a vector; i.e.,
5459
5460<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
5461<mi mathvariant='italic'>w</mi>
5462<mo stretchy="false">=</mo>
5463<msup><mi mathvariant='italic'>B</mi>
5464<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>T</mi>
5465</mstyle></mrow>
5466</msup>
5467<mo stretchy="false">*</mo>
5468<mi mathvariant='italic'>v</mi>
5469</mrow></math>
5470
5471<br/>
5472<b><big><a name="5.2.c" id="5.2.c">5.2.c: Bdia</a></big></b>
5473<br/>
5474The argument <i>Bdia</i> is an
5475<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
5476<mi mathvariant='italic'>m</mi>
5477<mo stretchy="false">&#x000D7;</mo>
5478<mi mathvariant='italic'>n</mi>
5479<mo stretchy="false">&#x000D7;</mo>
5480<mi mathvariant='italic'>N</mi>
5481</mrow></math>
5482
5483 array.
5484For
5485<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
5486<mi mathvariant='italic'>k</mi>
5487<mo stretchy="false">=</mo>
5488<mn>1