summaryrefslogtreecommitdiff
path: root/help/en_US/lsqlin.xml
diff options
context:
space:
mode:
Diffstat (limited to 'help/en_US/lsqlin.xml')
-rw-r--r--help/en_US/lsqlin.xml335
1 files changed, 269 insertions, 66 deletions
diff --git a/help/en_US/lsqlin.xml b/help/en_US/lsqlin.xml
index 466c1cf..51c1a3a 100644
--- a/help/en_US/lsqlin.xml
+++ b/help/en_US/lsqlin.xml
@@ -28,104 +28,115 @@
xopt = lsqlin(C,d,A,b,Aeq,beq)
xopt = lsqlin(C,d,A,b,Aeq,beq,lb,ub)
xopt = lsqlin(C,d,A,b,Aeq,beq,lb,ub,x0)
- xopt = lsqlin(C,d,A,b,Aeq,beq,lb,ub,x0,param)
+ xopt = lsqlin(C,d,A,b,Aeq,beq,lb,ub,x0,options)
[xopt,resnorm,residual,exitflag,output,lambda] = lsqlin( ... )
</synopsis>
</refsynopsisdiv>
<refsection>
- <title>Parameters</title>
+ <title>Input Parameters</title>
<variablelist>
<varlistentry><term>C :</term>
- <listitem><para> a matrix of double, represents the multiplier of the solution x in the expression C⋅x - d. Number of columns in C is equal to the number of elements in x.</para></listitem></varlistentry>
+ <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 double, represents the additive constant term in the expression C⋅x - d. Number of elements in d is equal to the number of rows in C matrix.</para></listitem></varlistentry>
+ <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>A :</term>
- <listitem><para> a matrix of double, represents the linear coefficients in the inequality constraints A⋅x ≤ b.</para></listitem></varlistentry>
+ <listitem><para> A matrix of doubles, containing the coefficients of linear inequality constraints of size (m X n) where 'm' is the number of linear inequality constraints.</para></listitem></varlistentry>
<varlistentry><term>b :</term>
- <listitem><para> a vector of double, represents the linear coefficients in the inequality constraints A⋅x ≤ b.</para></listitem></varlistentry>
+ <listitem><para> A vector of doubles, related to 'A' and represents the linear coefficients in the linear inequality constraints of size (m X 1).</para></listitem></varlistentry>
<varlistentry><term>Aeq :</term>
- <listitem><para> a matrix of double, represents the linear coefficients in the equality constraints Aeq⋅x = beq.</para></listitem></varlistentry>
+ <listitem><para> A matrix of doubles, containing the coefficients of linear equality constraints of size (m1 X n) where 'm1' is the number of linear equality constraints.</para></listitem></varlistentry>
<varlistentry><term>beq :</term>
- <listitem><para> a vector of double, represents the linear coefficients in the equality constraints Aeq⋅x = beq.</para></listitem></varlistentry>
+ <listitem><para> A vector of double, vector of doubles, related to 'Aeq' and represents the linear coefficients in the equality constraints of size (m1 X 1).</para></listitem></varlistentry>
<varlistentry><term>lb :</term>
- <listitem><para> a vector of double, contains lower bounds of the variables.</para></listitem></varlistentry>
+ <listitem><para> A vector of doubles, containing the lower bounds of the variables of size (1 X n) or (n X 1) where 'n' is the number of variables.</para></listitem></varlistentry>
<varlistentry><term>ub :</term>
- <listitem><para> a vector of double, contains upper bounds of the variables.</para></listitem></varlistentry>
+ <listitem><para> A vector of doubles, containing the upper bounds of the variables of size (1 X n) or (n X 1) where 'n' is the number of variables.</para></listitem></varlistentry>
<varlistentry><term>x0 :</term>
- <listitem><para> a vector of double, contains initial guess of variables.</para></listitem></varlistentry>
- <varlistentry><term>param :</term>
- <listitem><para> a list containing the parameters to be set.</para></listitem></varlistentry>
+ <listitem><para> A vector of doubles, containing the starting values of variables of size (1 X n) or (n X 1) where 'n' is the number of variables.</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 double, the computed solution of the optimization problem.</para></listitem></varlistentry>
+ <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, objective value returned as the scalar value norm(C⋅x-d)^2.</para></listitem></varlistentry>
+ <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 double, solution residuals returned as the vector d-C⋅x.</para></listitem></varlistentry>
+ <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> The exit status. See below for details.</para></listitem></varlistentry>
+ <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> The structure consist of statistics about the optimization. See below for details.</para></listitem></varlistentry>
+ <listitem><para> A structure, containing the information about the optimization. See below for details.</para></listitem></varlistentry>
<varlistentry><term>lambda :</term>
- <listitem><para> The structure consist of the Lagrange multipliers at the solution of problem. See below for details.</para></listitem></varlistentry>
+ <listitem><para> A structure, containing the Lagrange multipliers of the lower bounds, upper bounds and constraints at the optimized point. See below for details.</para></listitem></varlistentry>
</variablelist>
</refsection>
-
<refsection>
<title>Description</title>
<para>
-Search the minimum of a constrained linear least square problem specified by :
+Search the minimum of a constrained linear least square problem specified by:
</para>
<para>
<latex>
\begin{eqnarray}
-&amp;\mbox{min}_{x}
-&amp; 1/2||C⋅x - d||_2^2 \\
-&amp; \text{subject to} &amp; A⋅x \leq b \\
-&amp; &amp; Aeq⋅x = beq \\
-&amp; &amp; lb \leq x \leq ub \\
+\hspace{10pt} &amp;\mbox{min}_{x}
+\hspace{10pt} &amp; 1/2||C⋅x - d||_2^2 \\
+\hspace{10pt} &amp; \text{Subjected to: } &amp; A⋅x \leq b \\
+\hspace{10pt} &amp; &amp; Aeq⋅x = beq \\
+\hspace{10pt} &amp; &amp; lb \leq x \leq ub \\
\end{eqnarray}
</latex>
</para>
<para>
-The routine calls Ipopt for solving the linear least square problem, Ipopt is a library written in C++.
+lsqlin calls Ipopt, an optimization library written in C++, to solve the linear least squares 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>
-The options allows the user to set various parameters of the Optimization problem.
-It should be defined as type "list" and contains the following fields.
<itemizedlist>
-<listitem>Syntax : options= list("MaxIter", [---], "CpuTime", [---]);</listitem>
-<listitem>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</listitem>
-<listitem>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</listitem>
-<listitem>Default Values : options = list("MaxIter", [3000], "CpuTime", [600]);</listitem>
+<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 exitflag allows to know the status of the optimization which is given back by Ipopt.
+ 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>exitflag=0 : Optimal Solution Found </listitem>
-<listitem>exitflag=1 : Maximum Number of Iterations Exceeded. Output may not be optimal.</listitem>
-<listitem>exitflag=2 : Maximum CPU Time exceeded. Output may not be optimal.</listitem>
-<listitem>exitflag=3 : Stop at Tiny Step.</listitem>
-<listitem>exitflag=4 : Solved To Acceptable Level.</listitem>
-<listitem>exitflag=5 : Converged to a point of local infeasibility.</listitem>
+<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, go to http://www.coin-or.org/Ipopt/documentation/
+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 informations about the optimization process.
-It has type "struct" and contains the following fields.
+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 during the search</listitem>
+<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.
+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>
@@ -133,35 +144,133 @@ It has type "struct" and contains the following fields.
<listitem>lambda.eqlin: The Lagrange multipliers for the linear equality constraints.</listitem>
<listitem>lambda.ineqlin: The Lagrange multipliers for the linear inequality constraints.</listitem>
</itemizedlist>
- </para>
+</para>
<para>
</para>
</refsection>
+
+<para>
+A few examples displaying the various functionalities of lsqlin have been provided below. You will find a series of problems and the appropriate code snippets to solve them.
+ </para>
<refsection>
- <title>Examples</title>
+ <title>Example</title>
+ <para>
+ We begin with a simple objective function subjected to three inequality constraints.
+ </para>
+ <para>
+<latex>
+\begin{eqnarray}
+&amp;\mbox{min}_{x} 1/2||C⋅x - d||_2^2 \\
+\end{eqnarray}
+\\
+\text{Where C⋅x - d = }\:\begin{cases}
+\begin{eqnarray}
+\hspace{1pt} &amp;x_{1} + x_{2} + x_{3} - 89\\
+\hspace{1pt} &amp;x_{1} + x_{2} - 67\\
+\hspace{1pt} &amp;x_{2} + x_{3} - 53\\
+\hspace{1pt} &amp;x_{1} - 35\\
+\hspace{1pt} &amp;x_{3} - 20\\
+\end{eqnarray}
+\end{cases}
+\\
+&amp; \text{Subjected to:} \\
+\begin{eqnarray}
+\hspace{70pt} &amp;3x_{1} + 2x_{2} + x_{3}&amp;\leq 191\\
+\hspace{70pt} &amp;2x_{1} + 3x_{2} + 4x_{3}&amp;\leq 209\\
+\hspace{70pt} &amp;x_{1} + 2x_{2} + 3x_{3}&amp;\leq 162\\
+\end{eqnarray}
+</latex>
+ </para>
+ <para>
+ </para>
<programlisting role="example"><![CDATA[
-//A simple linear least square example
-C = [ 2 0;
--1 1;
-0 2]
-d = [1
-0
--1];
-A = [10 -2;
--2 10];
-b = [4
--4];
-[xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,A,b)
-// Press ENTER to continue
+//Example 1:An example with inequality constraints.
+//Initializing C and D.
+C = [1 1 1;
+1 1 0;
+0 1 1;
+1 0 0;
+0 0 1]
+d = [89;
+67;
+53;
+35;
+20];
+//We specify the linear inequality constraints below.
+A = [3 2 1;
+2 3 4;
+1 2 3];
+b = [191
+209
+162];
+//Run lsqlin
+[xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,A,b);
+ ]]></programlisting>
+</refsection>
+<refsection>
+ <title>Example</title>
+ <para>
+ Here we build up on the previous example by adding equality constraints.
+We add the following constraint to the problem specified above:
+ </para>
+ <para>
+<latex>
+\begin{eqnarray}
+x_{1} + 2x_{2} + x_{3}&amp;= 10\\
+\end{eqnarray}
+</latex>
+ </para>
+ <para>
+ </para>
+ <programlisting role="example"><![CDATA[
+//Example 2: Using inequality and equality constraints.
+//Initializing C and D.
+C = [1 1 1;
+1 1 0;
+0 1 1;
+1 0 0;
+0 0 1]
+d = [89;
+67;
+53;
+35;
+20];
+//We specify the linear inequality constraints below.
+A = [3 2 1;
+2 3 4;
+1 2 3];
+b = [191
+209
+162];
+//We specify the linear equality constraints below.
+Aeq = [1 2 1];
+beq = 10;
+//Run lsqlin
+[xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,A,b,Aeq,beq)
]]></programlisting>
</refsection>
<refsection>
- <title>Examples</title>
+ <title>Example</title>
+ <para>
+ In this example, we proceed to add the upper and lower bounds to the objective function.
+ </para>
+ <para>
+<latex>
+\begin{eqnarray}
+0.1 &amp;\leq x_{1} &amp;\leq 4\\
+3 &amp;\leq x_{2} &amp;\leq 5\\
+1 &amp;\leq x_{3} &amp;\leq 1
+\end{eqnarray}
+</latex>
+ </para>
+ <para>
+ </para>
<programlisting role="example"><![CDATA[
-//A basic example for equality, inequality constraints and variable bounds
+//Example 3: Using equality, inequality constraints and variable bounds
+//Initializing C and D.
C = [1 1 1;
1 1 0;
0 1 1;
@@ -171,22 +280,116 @@ d = [89;
67;
53;
35;
-20;]
+20];
+//We specify the linear inequality constraints below.
A = [3 2 1;
2 3 4;
1 2 3];
b = [191
209
162];
+//We specify the linear equality constraints below.
Aeq = [1 2 1];
beq = 10;
-lb = repmat(0.1,3,1);
-ub = repmat(4,3,1);
+//The upper and lower bounds for the objective function are defined in simple vectors as shown below.
+lb = [0.1,3,1];
+ub = [4,5,1];
+//Run lsqlin
[xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,A,b,Aeq,beq,lb,ub)
]]></programlisting>
</refsection>
<refsection>
+ <title>Example</title>
+ <para>
+ In this example, we proceed to provide an initial value for x to facilitate the computation. We also further enhance the functionality of lsqlin 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 4: Using equality, inequality constraints and variable bounds, initializing x and options.
+//Initializing C and D.
+C = [1 1 1;
+1 1 0;
+0 1 1;
+1 0 0;
+0 0 1]
+d = [89;
+67;
+53;
+35;
+20];
+//We specify the linear inequality constraints below.
+A = [3 2 1;
+2 3 4;
+1 2 3];
+b = [191
+209
+162];
+//We specify the linear equality constraints below.
+Aeq = [1 2 1];
+beq = 10;
+//The upper and lower bounds for the objective function are defined in simple vectors as shown below.
+lb = [0.1,3,1];
+ub = [4,5,1];
+//Initializing x.
+x0 = [1,2,3]
+//Setting the options
+options = list("MaxIter", [5000], "CpuTime", [1000]);
+//Run lsqlin
+[xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,A,b,Aeq,beq,lb,ub,x0,options)
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Example</title>
+ <para>
+ Infeasible Problems: Find x in R^3 such that it minimizes:
+We add the following constraint to the objective function specified above:
+ </para>
+ <para>
+<latex>
+ \begin{eqnarray}
+3x_{1} + 2x_{2} + x_{3}&amp;\leq 191\\
+2x_{1} + 3x_{2} + 4x_{3}&amp;\leq 209\\
+x_{1} + 2x_{2} + 3x_{3}&amp;\leq 162\\
+\end{eqnarray}
+\begin{eqnarray}
+x_{1} + 2x_{2} + 3x_{3}&amp;= 200\\
+\end{eqnarray}
+</latex>
+ </para>
+ <para>
+ </para>
+ <programlisting role="example"><![CDATA[
+//Example 5: Infeasible problem
+//Initializing C and D.
+C = [1 1 1;
+1 1 0;
+0 1 1;
+1 0 0;
+0 0 1]
+d = [89;
+67;
+53;
+35;
+20];
+//We specify the linear inequality constraints below.
+A = [3 2 1;
+2 3 4;
+1 2 3];
+b = [191
+209
+162];
+//We specify the linear equality constraints below.
+Aeq = [1 2 3];
+beq = 200;
+//Run lsqlin
+[xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,A,b,Aeq,beq)
+ ]]></programlisting>
+</refsection>
+
+<refsection>
<title>Authors</title>
<simplelist type="vert">
<member>Harpreet Singh</member>