MATLAB: Do I receive errors when using FMINCON with sparse matrices

fminconOptimization Toolboxsisotool

For example, in some cases, I receive the following error:
Warning: Trust region method does not currently solve this type of problem, switching to line search.
Error in > /R12/toolbox/optim/fmincon.m at line
??? In an assignment A(I) = B, the number of elements in B and I must be the same.
In other cases, I receive the following error:
Warning: Trust region method does not currently solve this type of problem, switching to line search.
??? Error using ==> qr
Too many output arguments.

Best Answer

As of MATLAB 7.0 (R14), the FMINCON function will return an error when given inputs that are anything other than full and double.
If you are using a version prior to MATLAB 7.0 (R14), these warning messages occur because FMINCON in the Optimization Toolbox 2.0 (R12.1) does not have an algorithm for handling the specific class of problem you've specified. FMINCON only has a large-scale algorithm for problems with only bound constraints or only linear inequalities.
The error messages occur because a bug in the code prevents the conversion of sparse input matrices in FMINCON into full ones. Since there are no large-scale methods (indicated by the warning), the inputs should be full.
The conversion from full to sparse matrices isn't occurring properly. In the meantime, since sparse inputs in these cases don't improve algorithm performance, you can convert the sparse inputs into full inputs; this will prevent the warning messages you see.