MATLAB: Loosely Constrained Least Squares Solution

least squares solutionlsqlinMATLABnon-linearoptimizationOptimization Toolbox

Thanks in advance!
I am attempting to find the least squares solution to the matrix equation Ax=b. A, n x m, is a thin matrix, where n>>m, leading to an overdetermined system. Additionally, the system is constrained loosely by the equation Cx=d, where C is a 4×21 matrix and d is a 4×1 vector. Finally, the solutions should fall within the range [-1 1].
For context, I am attempting to optimize a set of Chebyshev polynomial coefficients (hence the solution limit of [-1 1]) defined over the interval [-1 1], expanded to the 20th order, where the polynomial and polynomial first derivative endpoints are pinned to known values (Cx=d). A (n x m) here represents m nominal Chebyshev terms of the first kind (1, x, 2x^2-1, etc.) evaluated at n points between -1 and 1. b represents the value of the original polynomial evaluated at the same n points between -1 and 1, leaving the solution x to be the optimized Chebyshev coefficients.
As such, I applied the following options to lsqlin:
options = optimset('MaxIterations', 1000000, 'TolFun', 1e-5, 'TolCon', 1-e3)
And called lsqlin for each set of coefficients to optimize:
x = lsqlin(C,d,A,b,[],[],-1,1,[],options)
As previously stated, the constraint tolerance is loose, and error on the range of e-3 is acceptable. However, this method of calling lsqlin does not seem to allow for the constraints to have any tolerance. The first derivative endpoints of the resulting polynomials are pinned to the constraint values as desired, but to numerical precision, without any error allowance. This results in lsqlin being unable to find a solution to the problem within the allowed iterations (or even test runs two orders of magnitude higher), and unreasonable results output where coefficients are found to be on the order of e3, not within [-1 1].
Is there something I am missing with the application of constraint tolerances here? Or, is there a way to place a hierarcy on constraints, such that one will be met (coefficients within [-1 1]) at the expense of the other constraints?
Thanks again!
-CH

Best Answer

Your concept of what a constraint tolerance means is wrong. and loose equality constraints are not something you can set.
Instead, you want to set inequality constraints. That is, if you are willing to have these loose constraints, do this:
LooseTol = 1e-3;
CC = [C;-C];
dd = [d + LooseTol ; -d + LooseTol];
lb = -ones(1,size(A,2));
ub = ones(1,size(A,2));
x = lsqlin(A,b,CC,dd,[],[],lb,ub);
Effectively, I have constrained
C*x <= d + LooseTol
C*x >= d - LooseTol
By use of general linear inequality constraints.
Related Question