Solves a linear quadratic problem.
xopt = lsqlin(C,d,A,b) 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,options) [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin( ... )
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.
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 matrix of doubles, containing the coefficients of linear inequality constraints of size (m X n) where 'm' is the number of linear inequality constraints.
A vector of doubles, related to 'A' and represents the linear coefficients in the linear inequality constraints of size (m X 1).
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.
A vector of double, vector of doubles, related to 'Aeq' and represents the linear coefficients in the equality constraints of size (m1 X 1).
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.
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.
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.
A list, containing the option for user to specify. See below for details.
A vector of doubles, containing the computed solution of the optimization problem.
A double, containing the objective value returned as a scalar value norm(C⋅x-d)^2.
A vector of doubles, containing the solution residuals, returned as a vector d-C⋅x.
An integer, containing the flag which denotes the reason for termination of algorithm. See below for details.
A structure, containing the information about the optimization. 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.
Search the minimum of a constrained linear least square problem specified by:
lsqlin calls Ipopt, an optimization library written in C++, to solve the linear least squares problem.
The options should be defined as type "list" and consist of the following fields:
options= list("MaxIter", [---], "CpuTime", [---]);
The default values for the various items are given as:
options = list("MaxIter", [3000], "CpuTime", [600]);
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:
For more details on exitflag, see the Ipopt documentation which can be found on http://www.coin-or.org/Ipopt/documentation/
The output data structure contains detailed information about the optimization process. It is of type "struct" and contains the following fields.
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.
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.
We begin with a simple objective function subjected to three inequality constraints.
Here we build up on the previous example by adding equality constraints. We add the following constraint to the problem specified above:
In this example, we proceed to add the upper and lower bounds to the objective function.
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) |
Infeasible Problems: Find x in R^3 such that it minimizes: We add the following constraint to the objective function specified above: