source: html/ckbs/_printable.xml @ 81

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

[html/ckbs] fix one yyyymmdd reference that was in code font (now italic)

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