nonlinear solver user specified function

Hi,
I would like to use a user specified non-linear solver as a substitute for the fsolve. This function is quite frequent in some Economics applications and it performs better in terms of efficiency and speed than the default options of matlab. Can someone help me on how i should modify my system in order to be able to call that function. I am attaching all the necessary files. The user specified nonlinear solver is the "csolve" file.
fyi, the code with fsolve it took around 30min to implement in my pc.
many thanks

Respuestas (2)

Star Strider
Star Strider el 17 de Nov. de 2014
Put it in your MATLAB user path (on Windows machines, C:\Users\...\Documents\MATLAB\...), then call it in your main script as you would any other function:
[x,rc] = csolve(FUN, x, ...);

5 comentarios

Thank you for your comment. However, my problem is not this. My problem is that I cannot really understand the instructions on how I should modify my function, "function_ssmodel" that takes as inputs the vector "param", which is just a vector of parameters.
For example:
when I call the fsolve, I call it as usual
X1 = fsolve(@(x)function_ssmodel(x, param), x0, options);
where x0, are my initial guesses and options is the predefined vector of my options. My point is that I tried to use the equivalent inputs in "csolve" but failed. The instructions for using csolve are not very clear to me (please open the csolve file for details)
Star Strider
Star Strider el 17 de Nov. de 2014
I agree, it’s not as informative as it might be. I didn’t know it existed until your post.
A quick DuckDuckGo search brought up this link: http://www.dynare.org/dynare-matlab-m2html/matlab/csolve.html. I would look through the ‘This function is called by: ’ section, for hints on how to call it, and probably visit the Princeton University site to see if there is any more documentation or links to it. If all else fails, perhaps contacting Professor Chris Sims would provide some otherwise unavailable documentation.
msh
msh el 18 de Nov. de 2014
Thank you so much for the effort. I should have done this myself. I will try and see what happens.
Star Strider
Star Strider el 18 de Nov. de 2014
My pleasure!
msh
msh el 19 de Nov. de 2014
Star Strider: I manage to work it out, please check my answer. Fyi, to solve my own system I needed 30min with fsolve, but this function does it in 3-4 secs !!! So, I posted a simple example on how someone can use the "csolve".

Iniciar sesión para comentar.

msh
msh el 18 de Nov. de 2014
Editada: msh el 18 de Nov. de 2014

0 votos

Ok, I manage to work that function through this simple example. I am attaching the files of the example for how to construct the non-linear system and how to call the "csolve". The attachments include:
  • calc_ss ==> main program
  • neoclassical_stst.m ==> the function that defines the non-linear system
  • neoclassical_stst_csolve ==> Aux. Function to define parameters
  • csolve ==> the non-linear solver
So, if someone wants to use the "csolve" instead of Matlab's fsolve, by modifying his system according to the example I gave should work.

1 comentario

Star Strider
Star Strider el 20 de Nov. de 2014
I honestly have nothing to contribute at this point. You’ve solved it.
I would encourage you to formalise your functions, document and explain them as elaborately as necessary (think about what you wanted to know when you first wanted to use them), include the appropriate citations, websites, and other references (the ones that I looked up, and others as necessary).
Then contribute the package to the File Exchange under your name. The ‘csolve’ function seems to be valuable, and by documenting them based on your explorations of them, you could make them available to others who are looking for an efficient nonlinear solver. They’re intended to be used with MATLAB, and I doubt the original authors of the routines would object, since the routines are freely available anyway but completely lack the documentation you will provide.

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Preguntada:

msh
el 17 de Nov. de 2014

Comentada:

el 20 de Nov. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by