Where I make a mistake with fminimax?

2 ビュー (過去 30 日間)
Boyan
Boyan 2025 年 1 月 18 日
コメント済み: Boyan 2025 年 1 月 21 日
Dear colleagues,
I have problem with optimisation function fminimax, which I use as a variant for regression analyses made by Curve fitter.
In the attached file are the vectors for x, y and z = f(x,y).
My code is, as follow. Sorry, I don't know how to paste it in appropriate format:
"
x=x_vremetraene;
y=y_period_pretovarvane;
z=z_111;
f = @(p) abs(p(1)*(p(2)+y).^p(3)./(x+p(4)).^p(5) - z);
F = @(p) reshape(f(p),[],1);
p0 = [1 1 1 1 1];
F(p0)
ans =
1.0e+02 *
2.314576069270182
2.796122919180851
3.081916551260510
3.284514792242277
3.441464927295814
3.926826269823946
1.650257401771352
.............................
by this point everything is good
format long
[p,fval] = fminimax(F,p0)
Local minimum possible. Constraints satisfied.
fminimax stopped because the size of the current search direction is less than
twice the value of the step size tolerance and constraints are
satisfied to within the value of the constraint tolerance.
<stopping criteria details>
p =
1.0e+03 *
-0.320589519017169 -2.281076321933144 -0.703130918618337 -0.366998883941303 1.591728772382496
fval =
1.0e+02 *
2.317909402603515
2.801122919180851
3.088583217927177
.........
"
The expected values for fval should be about 20. But they are as large as input z data.
Local minimum possible. Constraints satisfied.
I have tried p = lsqnonlin(F,p0) for preestimation of the parameters p
but it also gives me an error message.
Error using lsqncommon (line 38)
Objective function is returning Inf or NaN values at initial point. lsqnonlin cannot continue.
Error in lsqnonlin (line 264)
lsqncommon(funfcn,xCurrent,lb,ub,options,defaultopt,caller,...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  3 件のコメント
Torsten
Torsten 2025 年 1 月 19 日
編集済み: Torsten 2025 年 1 月 19 日
The matrix z_111 you use for fitting contains NaN values.
Boyan
Boyan 2025 年 1 月 21 日
Hi, Walter and Torsten,
Torsten is right. The problem is that fminimax does not work with NaN values, unlike Curve Fitter app, where NaN is not a problem.

サインインしてコメントする。

採用された回答

Matt J
Matt J 2025 年 1 月 18 日
編集済み: Matt J 2025 年 1 月 18 日
Some ideas,
  1. The choice of initial guess p0=[1,1,1,1,1] looks arbitrary. I don't see why that would be a good guess.
  2. You shouldn't be using abs() in the objective function. Possibly, you intended to use the AbsoluteMaxObjectiveCount option.
  3. Once you've removed abs(), you will need something to keep the fresult of F(p) real-valued, which means you probably need to apply constraints and bounds on p. The exponentsp(3) and p(5), for example, probably need to be constrained non-negative.
  1 件のコメント
Boyan
Boyan 2025 年 1 月 21 日
Hi, Matt,
Thank you for your answer. Maybe be your instructions could be usefull at second stage, as far as the problem was, as Torsten said, the NaN values in z matrix.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Least Squares についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by