Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: fmincon sparse constraints question
Replies: 3   Last Post: May 21, 2013 1:22 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Alan Weiss

Posts: 1,262
Registered: 11/27/08
Re: fmincon sparse constraints question
Posted: May 10, 2013 2:28 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 5/10/2013 1:58 PM, Haemish wrote:
> When I code for fmincon, I makes a ctr.m as follows;
>
> ...
> ceq=~~
> cd=[];
> if nargout > 2
> dceq=2178*1090 matrix
> dc=[];
> ...
>
> But dceq above is too large and sparse that the calculation time is so
> long and sometimes the system stops.
>
> I think that to use sparse matrix and coding as follow seem to be the
> solution
>
> ...
> ceq=~~
> cd=[];
> if nargout > 2
> dceq=2178*1090 matrix
> dceq=sparse(dceq);
> dc=[];
> ...
>
> But the calculation is still so slow.
>
> Are there any problems on my soluation
>
> Thank you.


You should be doing sparse internal calculations for your dceq function,
not doing a nonsparse calculation and then returning a sparse solution.
What I mean is, you should not have to call sparse(dceq) because your
constraint gradient should already be sparse. And you should be sure to
set GradObj and GradCon to 'on' in the options.

You can also specify a sparse Hessian multiply function. See
http://www.mathworks.com/help/optim/ug/minimization-with-dense-structured-hessian-equality-constraints.html

Alan Weiss
MATLAB mathematical toolbox documentation



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.