Hi,
Could I use a LeastSquareProblem if I don't know the gradient of my cost function? I have a calibration problem to solve, but I don't know what the derivatives of my problem are. If we can not use the LeastSquareProblem (an overloaded one in fact), which method is recommended? Cheers |
On Mon, 2008-04-14 at 07:01 -0700, Yomi wrote:
> Hi, > > Could I use a LeastSquareProblem if I don't know the gradient of my cost > function? > I have a calibration problem to solve, but I don't know what the derivatives > of my problem are. You might calculate them numerically, but I don't know how effective this would be. > If we can not use the LeastSquareProblem (an overloaded one in fact), which > method is recommended? You can use one of the other optimizers (LevenbergMarquardt, Simplex...) Luigi -- So little done, so much to do. -- Cecil Rhodes ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Luigi,
Here is what I did: 1. I have create a new LeastSquare pb class ParametricLocalVolFitting: public LeastSquareProblem I am able to calculate the values I wish but I am not able to calculate the gradient (the solution is calculated on a PDE and since it ifor calibration, I don't wish to go numerically since it will increase my number of loops) For the moment I pass the grad2fit[.]=0, but I have a crash. 2. In my resolution method, I use LevenbergMarquardt as optimization method. boost::shared_ptr<OptimizationMethod> om(new LevenbergMarquardt(accuracy, accuracy, accuracy)); NonLinearLeastSquare lsLocal( con, accuracy, maxiter ); I apply the LeastSquare problem to my optimizer: ParametricLocalVolFitting local(...); lsLocal.setInitialValue(initialValue); Array solution = lsLocal.perform(local); The first loop is calculated as expected but since I don't have gradient there is a crash during the gradient calculation: // compute derivative grad_f = -2.0*(transpose(grad_fct2fit)*diff); How could I do to make it work properly? The best would be to use the targetAndValue function from the pb instead of the targetValueAndGradient function. You have suggested to use different optimizer, but I already use LevenbergMarquardt. Would it work better with Simplex? if yes, do you have a sample of its use? Regards
|
On Fri, 2008-06-06 at 06:27 -0700, Yomi wrote:
> 1. I have create a new LeastSquare pb > > class ParametricLocalVolFitting: public LeastSquareProblem > > I am able to calculate the values I wish but I am not able to calculate the > gradient (the solution is calculated on a PDE and since it ifor calibration, > I don't wish to go numerically since it will increase my number of loops) Yomi, I would drop the LeastSquareProblem and go for a more generic one (such as Problem in <ql/math/optimization/problem.hpp>.) You can use it with LevenbergMarquardt or other optimizers. An example of its use is in the CalibratedModel::calibrate() method (see <ql/models/model.cpp>.) Luigi -- Vin: It's like this fellow I knew in El Paso. One day, he just took all his clothes off and jumped in a mess of cactus. I asked him that same question, "Why?" Calvera: And? Vin: He said, "It seemed like a good idea at the time." -- The Magnificent Seven ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |