non linear curve fitting with globaloptimization options

1 vue (au cours des 30 derniers jours)
Daniele Sonaglioni
Daniele Sonaglioni le 10 Déc 2023
Modifié(e) : Saarthak Gupta le 27 Déc 2023
Dear all,
i am struggling with an optimization of a non linear function with upper and lower bounds. I have been using lower and upper bounds but i have noted that the quality of the fit changes by slightly changing the value of the upper bound: in particular, if i increase a bit the upper bound the fit does not work properly, as if it was uncapable of reaching the minimum. Can anyone help me fixing the problem? Below you can find the code and attached all the data and ancillary m-files i am using. I don't understand if the problem is the algorithm itself (i.e. fmincon is not robust enough) or something else.
close all
clear
r=[-13.3001 916.6485 296.6287];
load 'tau_cryst_67_updated.txt'%data at T>Tg
data3=tau_cryst_67_updated;
T_cr=data3(:,1);
tau_67=data3(:,5);
load 'Gibbs_interpolated.txt'
Th=Gibbs_interpolated(:,1);
G=Gibbs_interpolated(:,2);
DG=interp1(Th,G,T_cr);
adjust_S
tau_67_inv=1./tau_67;
B=r(2); T0=r(3);
DH=36.04*1e3; R=8.314; Kb=1.38*1e-23; Vm=281.3/(1.3*1e6);%in m^3/mol
t_ind=@(p,T_cr) (1/p(1)*1./(10^(r(1))*10.^((r(2)/2.303)./(T_cr-r(3)))).^(p(3)).*exp(-p(2).*(T_cr.*DS).^3./(DG.^2*R.*T_cr)));
p0=[10^6,1,.5];
lb=[10^3,0,.4];
ub=[10^7,10,1];
fun_tind=@(p) norm((tau_67_inv)-(t_ind(p,T_cr)));
opts = optimoptions(@fmincon,Algorithm="interior-point");
problem = createOptimProblem('fmincon', 'x0',p0,'objective',fun_tind,'lb',lb,'ub',ub,options=opts);
ms = MultiStart('FunctionTolerance',1e-11,'UseParallel',true)
gs = GlobalSearch(ms,'PlotFcns',@gsplotbestf);
[p] = run(gs,problem)
close
figure(2)
plot(log10(tau_67_inv),T_cr,'o')
hold on
plot(log10(t_ind(p,T_cr)),T_cr)
xlabel('log_{10}(t [sec])','FontSize',12)
ylabel('T (K)','FontSize',12)
legend('exp data','my fit','FontSize',14,'Location','southwest')
legend('boxoff')
title('Analysis of Indoprofen ABOVE Tg')
Thanks to all!

Réponse acceptée

Saarthak Gupta
Saarthak Gupta le 26 Déc 2023
Modifié(e) : Saarthak Gupta le 27 Déc 2023
Hi Daniele,
To effectively diagnose the issue, it would be beneficial to have the "entropy_calculated.txt" file. This file is crucial for reproducing the problem you have encountered.
Premature termination of a solver may occur when it is uncertain about the quality of the solution it has generated. This uncertainty may arise if the solver has converged at a local minimum without being able to confirm it, particularly if the first-order optimality measure hasn't fallen below the predefined optimality tolerance.
To verify the solution obtained, you might consider the following strategies:
1. Evaluate Surrounding Points: If you have a non-smooth objective function or non-smooth constraints, check nearby points to the solution.
2. Restart at the Last Solution: Run the algorithm again, starting from the point where the last solution was found.
3. Try Alternate Algorithms: Different algorithms may navigate the solution space differently and could avoid the pitfalls of the one you're currently using.
4. Adjust Tolerances: Modifying the tolerance settings can influence when the solver perceives convergence, potentially leading to a more accurate solution.
5. Rescale Your Problem: Scaling the problem can sometimes improve the numerical properties and lead to better optimization results.
6. Reexamine Surrounding Points: As mentioned earlier, investigating points near the solution can provide insights into the solution space of the function and the validity of the solution.
7. Modify Finite Difference Settings: If you're using numerical derivatives, changing the finite differencing scheme can affect the solver's trajectory.
8. Supply Analytical Gradients or Jacobian: Providing exact gradients or Jacobian can significantly improve the solver's ability to navigate the solution space.
9. Introduce a Hessian: If applicable, offering the Hessian matrix can enhance the solver's performance, particularly for second-order methods.
Refer to the following MATLAB documentation for further reference:
Hope this helps!
Best regards,
Saarthak

Plus de réponses (0)

Catégories

En savoir plus sur Optimization Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by