Using Symbolic Toolbox for Optimization Solvers

9 views (last 30 days)
Hi, I have a large system of nonlinear equations from an Economic model (over 500 unknowns) that I want to solve using fsolve or lsqnonlin. Supplying the Jacobian matrix is not feasible, but approximating the Jacobian with finite differences is also not feasible since each function evaluation takes about half an hour and each iteration would need over 500 evaluations. I want to use the symbolic toolbox and am using this helpful example: http://www.mathworks.com/tagteam/62669_91801v00_SymbolicGradient_Hessian_final.pdf.
However my problem is more complicated, as the objective function (of which I want to take the Jacobian) must call other files that use the current guess to solve equations given that guess. Therefore I haven't been able to write the objective function symbolically (as "objfun" is written in the above example), since the objective function needs a guess of the solution. Are there any help files that use more complicated objective functions or does anyone have any suggestions? Should I not try to use the symbolic toolbox for complicated functions? Thanks for the help!
  1 Comment
Matt J
Matt J on 28 Oct 2012
Can we see the equations? Why is it so much harder to supply the non-symbolic Jacobian than to compute the objective function itself?

Sign in to comment.

Answers (2)

Alan Weiss
Alan Weiss on 29 Oct 2012
I'm glad you like the example. There are some other examples on using symbolic math with optimization, but I doubt that any give more information than the one you are using. Nevertheless, here are a couple of pointers to more examples:
Your problem of needing starting guesses for your solution makes it sound as if you don't have an analytic form for your objective function, so I don't see how you can use symblic math in any case, but maybe I just don't understand properly.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

ariel
ariel on 31 Oct 2012
Thank you for the responses. Alan, you are right, my problem is that I don't have this in analytic form. I thought a way that I could have this in analytic form is to have the optimizer (lsqnonlin) call my objective function, and have the Jacobian be written inside this objective function using the current guess (but creating a symbolic variable for the current guess in the objective function). For example, in the bottom of the objective function:
if nargout >1
J= jacobian(fun,x)
end
where fun is the objective function that now has the unknowns as symbolic variables and many parameters that were calculated using the current guess.
This is different than in the above examples where the objective and Jacobian functions are written out analytically and then passed to the optimizer. This has not been working though and I wonder if I am going about it in a very incorrect way. Thanks!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!