Using Multistart in an unconstrained optimization
Ältere Kommentare anzeigen
Hello, suprisingly working with this model I have imposed nonlinear and upper/lower bounds in a separate script and have come up with a better fit. I am surprised to find that the unconstrained case, the code I have here, is not giving me correct solutions. I tried messing with ms.XTolerance and the functionTolerance but nothing helped (since I have only seen an exit flag of 2). It does not seem like multistart is minimizing my objective function, as the error for a solution is a massive number.
Is there anything you all see wrong, or an explanation as to why this is happening? (I would preferably use lsqnonlin, not lsqcurvefit just to stay consistent)

D = readmatrix('Treloar_Data.xlsx');
x = D(:,1);
y = D(:,2);
% Define Ogden Function
ogden_funct1 = @(c) (c(1).*(x.^(c(4)-1)-x.^(-1/2*c(4)-1)) + ...
c(2).*(x.^(c(5)-1)-x.^(-1/2*c(5)-1)) + ...
c(3).*(x.^(c(6)-1)-x.^(-1/2*c(6)-1))) - y;
% Initial_Guess
Initial_Guess1 = [1 1 1 1 1 1];
lb =[];
ub=[];
%Run multistart
problem1 = createOptimProblem('lsqnonlin', 'objective', ogden_funct1, 'x0', Initial_Guess1, 'lb', lb ,'ub', ub);
ms = MultiStart; ms.XTolerance =1*10.^(-13); ms.FunctionTolerance =1*10.^(-13);
[xmultinonlin,errormultinonlin] =run(ms,problem1, 1000)
% Plot Our Data
ogden_plot_func =@(c) c(1).*(x.^(c(4)-1)-x.^((-1)/2*c(4)-1)) + ...
c(2).*(x.^(c(5)-1)-x.^(-1/2*c(5)-1)) + ...
c(3).*(x.^(c(6)-1)-x.^((-1)/2*c(6)-1));
plot(x, y, 'ko', x, ...
ogden_plot_func(xmultinonlin), '-b')
legend('Data', 'lsqnonlin-Unconstrained')
title('Ogden Model Unconstrained')
xlabel('Stretch')
ylabel('Stress')
Akzeptierte Antwort
Weitere Antworten (1)
D = [1.00 0.00
1.01 0.03
1.12 0.14
1.24 0.23
1.39 0.32
1.61 0.41
1.89 0.50
2.17 0.58
2.42 0.67
3.01 0.85
3.58 1.04
4.03 1.21
4.76 1.58
5.36 1.94
5.76 2.29
6.16 2.67
6.40 3.02
6.62 3.39
6.87 3.75
7.05 4.12
7.16 4.47
7.27 4.85
7.43 5.21
7.50 5.57
7.61 6.30];
x = D(:,1);
y = D(:,2);
% Define Ogden Function
ogden_funct1 = @(c) (c(1).*(x.^(c(4)-1)-x.^(-1/2*c(4)-1)) + ...
c(2).*(x.^(c(5)-1)-x.^(-1/2*c(5)-1)) + ...
c(3).*(x.^(c(6)-1)-x.^(-1/2*c(6)-1))) - y;
% Initial_Guess
Initial_Guess1 = [-1.7720e+01 4.7842e-02 6.7178e-01 -1.7202e-01 3.5402e+00 -3.7330e+00];
lb =[];
ub=[];
options = optimset('MaxFunEvals',10000);
c = lsqnonlin(ogden_funct1,Initial_Guess1,lb,ub,options)
plot(x, y, 'ko', x, ...
ogden_funct1(c)+y, '-b')
7 Kommentare
Reed
am 19 Jul. 2022
The crucial point is to give good initial values for the parameters. Even MultiStart cannot ensure that some of the chosen parameter vectors yield convergence.
To choose c(4) - c(6) as 1, e.g., is a bad idea since important parts of your equation cancel out right at the beginning.
Further I would guess that your problem is overfitted with 6 parameters.
Restricting parameters to reasonable ranges often eases convergence. That's how I would interpret that setting a lower bound yields better results.
The results given above by Torsten is actually a local solution, not the optimal one; The global solution is hard to be obtained, but should be like below:
Sum Squared Error (SSE): 0.0263802341297132
Root of Mean Square Error (RMSE): 0.0324839862884549
Correlation Coef. (R): 0.999860924905598
R-Square: 0.999721869153078
Parameter Best Estimate
--------- -------------
c1 -1.91181986182648E-6
c2 1.55279012410112E-82
c3 -0.240651398862925
c4 -16.1524712665223
c5 93.4941437734185
c6 -4.3004835501308
or
Sum Squared Error (SSE): 0.0263802481671276
Root of Mean Square Error (RMSE): 0.0324839949311212
Correlation Coef. (R): 0.999860924854578
R-Square: 0.999721869051053
Parameter Best Estimate
--------- -------------
c1 -0.240651587389618
c2 1.55282658451632E-82
c3 1.91182680758376E-6
c4 -4.30048241101075
c5 93.4941322424665
c6 8.07623397445497

Alex Sha
am 20 Jul. 2022
One more solution (different order of parameters):
Sum Squared Error (SSE): 0.0263802481671275
Root of Mean Square Error (RMSE): 0.0324839949311211
Correlation Coef. (R): 0.999860924854462
R-Square: 0.99972186905082
Parameter Best Estimate
--------- -------------
c1 -0.240651586280672
c2 1.91182678462031E-6
c3 1.55282423193542E-82
c4 -4.30048242034866
c5 8.07623397801575
c6 93.4941329971174
Reed
am 20 Jul. 2022
Alex Sha
am 21 Jul. 2022
Hi, Reed, it is ture that the results provided above are not from Matlab.
Matlab is a great and popular math software product, including me, widely used around the world. However, in some areas, for example, the global optimization algorithms or the tool of global optimization, the improvements are relatively minor and no longer have an advantage over some other products, this makes some of Matlab function or toolboxes (lsqcurvefit, gatool, fsolve, vpasolve, cftool...) to be difficult to get optimal results for some problems, for example, the curve fitting problem in this topic, even the result given by Alan Weiss is not correct.
Because of forum rules, it is not appropriate to discuss software other than matlab here, so only giving the right answer, and hope Mathworks will keep to improve Matlab more powerful.
Reed
am 27 Nov. 2022
Kategorien
Mehr zu Get Started with Optimization Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

