For LSQNONLIN is it okay if the number of elements in the vector-valued function varies per iteration?

3 次查看(过去 30 天)
For LSQNONLIN is it okay if the number of elements in the vector-valued function varies per iteration?
I have a vector-valued optimisation function producing say the variable Fopt. However for some parameter combinations some of the entries in the vector Fopt may yield NaN. At present I have this in the optimisation function:
Fopt=Fopt(~isnan(Fopt));
However that will result in the number of elements varying with iterations. Alternatively I can keep the same vector length but allow for NaN entries.
Which is the better approach?
Kevin
  1 个评论
Kevin Moerman
Kevin Moerman 2012-3-1
Actually lets expand the question a bit. How "intelligent" is LSQNONLIN with respect to the vector-values function? Does it compare say entry 10 from iteration 1 with entry 10 from iteration 2? In that case the length would be important but also the 1-to-1 mapping is important.

请先登录,再进行评论。

采纳的回答

Seth DeLand
Seth DeLand 2012-3-1
Hi Kevin,
LSQNONLIN is using the values in the Fopt vector to determine the gradient, and it does this by calculating Fopt at different points. For example, it might take the difference of entry 10 from iteration 1 and entry 10 from iteration 2 and then use that to determine which way is downhill.
So you don't want to change the position of the values that the function is returning, as this could mess up the gradient calculation.
If LSQNONLIN encounters a NaN in Fopt, it is treated similarly to an Inf. Since we're trying to minimize, this point will most likely get rejected and LSQNONLIN will try to move back to a solution space where all of the values in Fopt were finite.
So the questions you need to ask yourself is: How do I want NaN's in Fopt to be interpreted? If having NaN's in Fopt is a bad solution for your problem, then it's fine for the Fopt vector to return NaN's since LSQNONLIN will treat those as really bad values of your objective function. If NaN has some other meaning, you may need to change your objective function to quantify what it means to have a NaN (i.e. if NaN is a good thing, then you would want to replace the NaN's in Fopt with something with a low penalty value).

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by