1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
<?xml version="1.0" encoding="UTF-8"?>
<!--
*
* This help file was generated from lsqnonneg.sci using help_from_sci().
*
-->
<refentry version="5.0-subset Scilab" xml:id="lsqnonneg" xml:lang="en"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:ns3="http://www.w3.org/1999/xhtml"
xmlns:mml="http://www.w3.org/1998/Math/MathML"
xmlns:scilab="http://www.scilab.org"
xmlns:db="http://docbook.org/ns/docbook">
<refnamediv>
<refname>lsqnonneg</refname>
<refpurpose>Solves nonnegative least-squares curve fitting problems.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Calling Sequence</title>
<synopsis>
xopt = lsqnonneg(C,d)
xopt = lsqnonneg(C,d,options)
[xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg( ... )
</synopsis>
</refsynopsisdiv>
<refsection>
<title>Input Parameters</title>
<variablelist>
<varlistentry><term>C :</term>
<listitem><para>A matrix of doubles, representing the multiplier of x in the expression C⋅x - d. The number of columns in C is equal to the number of elements in x.</para></listitem></varlistentry>
<varlistentry><term>d :</term>
<listitem><para> A vector of doubles, representing the additive constant term in the expression C⋅x - d. The number of elements in d is equal to the number of rows in C matrix.</para></listitem></varlistentry>
<varlistentry><term>options:</term>
<listitem><para> A list, containing the option for user to specify. See below for details.</para></listitem></varlistentry>
</variablelist>
</refsection>
<refsection>
<title> Outputs</title>
<variablelist>
<varlistentry><term>xopt :</term>
<listitem><para> A vector of doubles, containing the computed solution of the optimization problem.</para></listitem></varlistentry>
<varlistentry><term>resnorm :</term>
<listitem><para> A double, containing the objective value returned as a scalar value norm(C⋅x-d)^2.</para></listitem></varlistentry>
<varlistentry><term>residual :</term>
<listitem><para> A vector of doubles, containing the solution residuals, returned as a vector d-C⋅x.</para></listitem></varlistentry>
<varlistentry><term>exitflag :</term>
<listitem><para> An integer, containing the flag which denotes the reason for termination of algorithm. See below for details.</para></listitem></varlistentry>
<varlistentry><term>output :</term>
<listitem><para> A structure, containing the information about the optimization. See below for details.</para></listitem></varlistentry>
<varlistentry><term>lambda :</term>
<listitem><para> A structure, containing the Lagrange multipliers at the optimized point. See below for details.</para></listitem></varlistentry>
</variablelist>
</refsection>
<refsection>
<title>Description</title>
<para>
Solves nonnegative least-squares curve fitting problems specified by :
</para>
<para>
<latex>
\begin{eqnarray}
\hspace{1pt} &\mbox{min}_{x}
\hspace{1pt} & 1/2||C⋅x - d||_2^2 \\
\hspace{1pt} & & x \geq 0 \\
\end{eqnarray}
</latex>
</para>
<para>
lsqlin calls Ipopt, an optimization library written in C++, to solve the nonnegative least-squares curve fitting problem.
</para>
<para>
The options should be defined as type "list" and consist of the following fields:
</para>
<para>
options= list("MaxIter", [---], "CpuTime", [---]);
</para>
<para>
<itemizedlist>
<listitem>MaxIter : A Scalar, specifying the maximum number of iterations that the solver should take.</listitem>
<listitem>CpuTime : A Scalar, specifying the maximum amount of CPU time in seconds that the solver should take.</listitem>
</itemizedlist>
</para>
<para>
The default values for the various items are given as:
</para>
<para>
options = list("MaxIter", [3000], "CpuTime", [600]);
</para>
<para>
The exitflag allows the user to know the status of the optimization which is returned by Ipopt. The values it can take and what they indicate is described below:
<itemizedlist>
<listitem> 0 : Optimal Solution Found </listitem>
<listitem> 1 : Maximum Number of Iterations Exceeded. Output may not be optimal.</listitem>
<listitem> 2 : Maximum amount of CPU Time exceeded. Output may not be optimal.</listitem>
<listitem> 3 : Stop at Tiny Step.</listitem>
<listitem> 4 : Solved To Acceptable Level.</listitem>
<listitem> 5 : Converged to a point of local infeasibility.</listitem>
</itemizedlist>
</para>
<para>
For more details on exitflag, see the Ipopt documentation which can be found on http://www.coin-or.org/Ipopt/documentation/
</para>
<para>
The output data structure contains detailed information about the optimization process.
It is of type "struct" and contains the following fields.
<itemizedlist>
<listitem>output.iterations: The number of iterations performed.</listitem>
<listitem>output.constrviolation: The max-norm of the constraint violation.</listitem>
</itemizedlist>
</para>
<para>
The lambda data structure contains the Lagrange multipliers at the end of optimization. In the current version, the values are returned only when the the solution is optimal.
It has type "struct" and contains the following fields.
<itemizedlist>
<listitem>lambda.lower: The Lagrange multipliers for the lower bound constraints.</listitem>
<listitem>lambda.upper: The Lagrange multipliers for the upper bound constraints.</listitem>
</itemizedlist>
</para>
<para>
</para>
</refsection>
<para>
A few examples displaying the various functionalities of lsqnonneg have been provided below. You will find a series of problems and the appropriate code snippets to solve them.
</para>
<refsection>
<title>Example</title>
<para>
We begin with a simple objective function.
</para>
<para>
<latex>
\begin{eqnarray}
\mbox{min}_{x} 1/2||C⋅x - d||_2^2 \\
\end{eqnarray}
\\
\text{Where C⋅x - d = }\:\begin{cases}
\begin{eqnarray}
x_{1} + x_{2} + x_{3} - 89\\
x_{1} + x_{2} - 67\\
x_{2} + x_{3} - 53\\
x_{1} - 35\\
x_{3} - 20
\end{eqnarray}
\end{cases}
</latex>
</para>
<para>
</para>
<programlisting role="example"><![CDATA[
// Example 1: A basic lsqnonneg problem
C = [1 1 1;
1 1 0;
0 1 1;
1 0 0;
0 0 1]
d = [89;
67;
53;
35;
20;]
[xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg(C,d)
]]></programlisting>
</refsection>
<refsection>
<title>Example</title>
<para>
In this example, we further enhance the functionality of qpipopt by setting input options. This provides us with the ability to control the solver parameters such as the maximum number of solver iterations and the max. CPU time allowed for the computation.
</para>
<para>
</para>
<programlisting role="example"><![CDATA[
// Example 2: A basic lsqnonneg problem with solver options.
C = [1 1 1;
1 1 0;
0 1 1;
1 0 0;
0 0 1]
d = [89;
67;
53;
35;
20;]
options = list("MaxIter", [5000], "CpuTime", [1000]);
[xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg(C,d,options)
]]></programlisting>
</refsection>
<refsection>
<title>Authors</title>
<simplelist type="vert">
<member>Harpreet Singh</member>
</simplelist>
</refsection>
</refentry>
|