From 6aa3bf99dbd4187c83167dec18ebe974421d57bc Mon Sep 17 00:00:00 2001 From: Georgey Date: Wed, 5 Jul 2017 11:44:38 +0530 Subject: Updated help folder --- help/en_US/scilab_en_US_help/lsqlin.html | 247 ++++++++++++++++++++++--------- 1 file changed, 181 insertions(+), 66 deletions(-) (limited to 'help/en_US/scilab_en_US_help/lsqlin.html') diff --git a/help/en_US/scilab_en_US_help/lsqlin.html b/help/en_US/scilab_en_US_help/lsqlin.html index 5a26c54..07a5369 100644 --- a/help/en_US/scilab_en_US_help/lsqlin.html +++ b/help/en_US/scilab_en_US_help/lsqlin.html @@ -16,7 +16,7 @@ - FOSSEE Optimization Toolbox + FOSSEE Optimization Toolbox @@ -29,7 +29,7 @@ - FOSSEE Optimization Toolbox >> FOSSEE Optimization Toolbox > lsqlin + FOSSEE Optimization Toolbox >> FOSSEE Optimization Toolbox > lsqlin

lsqlin

@@ -41,67 +41,66 @@ 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( ... )
-

Parameters

+

Input Parameters

C : -

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.

+

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.

d : -

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.

+

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.

A : -

a matrix of double, represents the linear coefficients in the inequality constraints A⋅x ≤ b.

+

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.

b : -

a vector of double, represents the linear coefficients in the inequality constraints A⋅x ≤ b.

+

A vector of doubles, related to 'A' and represents the linear coefficients in the linear inequality constraints of size (m X 1).

Aeq : -

a matrix of double, represents the linear coefficients in the equality constraints Aeq⋅x = beq.

+

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.

beq : -

a vector of double, represents the linear coefficients in the equality constraints Aeq⋅x = beq.

+

A vector of double, vector of doubles, related to 'Aeq' and represents the linear coefficients in the equality constraints of size (m1 X 1).

lb : -

a vector of double, contains lower bounds of the variables.

+

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.

ub : -

a vector of double, contains upper bounds of the variables.

+

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.

x0 : -

a vector of double, contains initial guess of variables.

-
param : -

a list containing the parameters to be set.

-
xopt : -

a vector of double, the computed solution of the optimization problem.

+

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.

+
options : +

A list, containing the option for user to specify. See below for details.

+

Outputs

+
xopt : +

A vector of doubles, containing the computed solution of the optimization problem.

resnorm : -

a double, objective value returned as the scalar value norm(C⋅x-d)^2.

+

A double, containing the objective value returned as a scalar value norm(C⋅x-d)^2.

residual : -

a vector of double, solution residuals returned as the vector d-C⋅x.

+

A vector of doubles, containing the solution residuals, returned as a vector d-C⋅x.

exitflag : -

The exit status. See below for details.

+

An integer, containing the flag which denotes the reason for termination of algorithm. See below for details.

output : -

The structure consist of statistics about the optimization. See below for details.

+

A structure, containing the information about the optimization. See below for details.

lambda : -

The structure consist of the Lagrange multipliers at the solution of problem. See below for details.

- +

A structure, containing the Lagrange multipliers of the lower bounds, upper bounds and constraints at the optimized point. See below for details.

Description

-

Search the minimum of a constrained linear least square problem specified by :

-

-

The routine calls Ipopt for solving the linear least square problem, Ipopt is a library written in C++.

-

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. -

-

The exitflag allows to know the status of the optimization which is given back by Ipopt. -

-

For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/

-

The output data structure contains detailed informations about the optimization process. -It has type "struct" and contains the following fields. -

-

Examples

-
//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
- -

Examples

-
//A basic example for equality, inequality constraints and variable bounds
+
+

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.

+

Example

+

We begin with a simple objective function subjected to three inequality constraints.

+

+

+
//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);
+ +

Example

+

Here we build up on the previous example by adding equality constraints. +We add the following constraint to the problem specified above:

+

+

+
//Example 2: Using  inequality and equality constraints.
+//Initializing C and D.
 C = [1 1 1;
 1 1 0;
 0 1 1;
@@ -135,19 +152,117 @@ It has type "struct" and contains the following fields.
 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);
+//Run lsqlin
+[xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,A,b,Aeq,beq)
+ +

Example

+

In this example, we proceed to add the upper and lower bounds to the objective function.

+

+

+
//Example 3: Using equality, inequality constraints and variable bounds
+//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];
+//Run lsqlin
 [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,A,b,Aeq,beq,lb,ub)
+

Example

+

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.

+

+
//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)
+ +

Example

+

Infeasible Problems: Find x in R^3 such that it minimizes: +We add the following constraint to the objective function specified above:

+

+

+
//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)
+

Authors

  • Harpreet Singh

@@ -161,7 +276,7 @@ It has type "struct" and contains the following fields.
- FOSSEE Optimization Toolbox + FOSSEE Optimization Toolbox -- cgit