source: html/ckbs/_printable.xml @ 68

Last change on this file since 68 was 68, checked in by bradbell, 11 years ago

[html/ckbs] bring documentation up to date before creating stable version

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