6

Is there a way to write custom methods for NonLinearModelFit or NMinimize?

To give background, I currently have a batch of code that uses NonLinearModelFit with NMinimize as the method to do constrained optimization. The interface I developed exposes all the method options and suboptions for NMinimize for user selection.

Since writing that code I've been writing my own algorithms for multi-objective optimization (MOO) which I think would perform quite well. However, with the old code being built around the structure of the FittedModel construct that NonLinearModelFit returns, I would need to wrap my algorithms in code that produces the same structured output. Not impossible, but really annoying.

So my hope is that maybe there is a way that I can create custom methods for either NMinimize or NonLinearModelFit so that Mathematica can pass along the FittedModel and reduce development time.

dr.blochwave
  • 8,768
  • 3
  • 42
  • 76
Guyondowy
  • 61
  • 3
  • I wonder if you would be willing to share some more details of your implementation. I have been developing a fitting routine for experimental data that must be deconvoluted from a known instrumental response function. I ended up having to write my own objective function, and NMinimize's Nelder-Mead algorithm. It works, but it's very sensitive to starting values, and it is sluggish even in the simplest of cases. I'd love to be able to still use NonlinearModelFit for its rich statistical output, but I couldn't make it work. I'd very much appreciate knowing more about your approach! – MarcoB May 07 '15 at 01:47
  • @MarcoB Honestly,there wasn't a whole lot of messing around that was needed to get it to work. I used the following option: Method -> {"NMinimize", StepMonitor :> steps++, EvaluationMonitor :> evals++, Method -> CurrentValue[EvaluationNotebook[], {TaggingRules, "method"}]} and that took care of it. I used TaggingRules because the code produces a pallet that can be used independent of the underlying notebook being saved. Most of the code is preparing the data and constraints to be inserted into NonLinearModelFit. We've always had very consistent results with the NelderMead method. – Guyondowy May 09 '15 at 06:06
  • That is very interesting, thank you! I'll wade through the method parameters you shared and see what I can make of those... In the meantime, I hope that your question might pique the fancy of somebody more knowledgeable. – MarcoB May 09 '15 at 06:16
  • @MarcoB I guess to make it a little clearer, these are the parameters fed into method: "method" -> {"NelderMead", "ContractRatio" -> 0.5, "ExpandRatio" -> 2.0, "InitialPoints" -> Automatic, "PenaltyFunction" -> Automatic, "PostProcess" -> Automatic, "RandomSeed" -> 0, "ReflectRatio" -> 1.0, "ShrinkRatio" -> 0.5, "Tolerance" -> 0.001, but these are the default values for the NelderMead algorithm so nothing revelatory. At least this way you know what the "method" TaggingRules is referencing. As I hinted to earlier, all these are exposed through a custom UI – Guyondowy May 09 '15 at 07:21

0 Answers0