Initial point is a local minimum when estimation parameters for differential equations
17 views (last 30 days)
Show older comments
Dear all,
I'm trying to fit my data to a group of differential equations and I always get the message "Initial point is a local minimum" no matter how I change the initial values.
The detailed information is like this '
Initial point is a local minimum.Optimization completed because the size of the gradient at the initial point is less than the value of the optimality tolerance.
<stopping criteria details>Optimization completed: The final point is the initial point.
The first-order optimality measure, 0.000000e+00, is less than
options.OptimalityTolerance = 1.000000e-16.
I will put my code below and please tell me how to fix this problem, thanks a lot!
function Parameterfitting
function C=kinetics(a,t)
c0=[0;0;0];
[T,Cv]=ode45(@DifEq,t,c0);
%
function dC=DifEq(t,c)
dcdt=zeros(3,1);
dcdt(1) = a(1)*c(1)+a(2)*c(2)+a(3)*c(3)+a(4)*c(1)*c(2)+a(5)*c(1)* c(3)+a(6)*c(2)* c(3)+a(7)*c(1)^2+a(8)* c(2)^2+a(9)*c(3)^2; %x=c(1), y=c(2), z=c(3)
dcdt(2) =a(10)*c(1)+a(11)*c(2)+a(12)*c(3)+a(13)*c(1)*c(2)+a(14)*c(1)*c(3)+a(15)*c(2)* c(3)+a(16)* c(1)^2+a(17)* c(2)^2+a(18)* c(3)^2; % a(10-18)=b1-b9
dcdt(3) =a(19)* c(1)+a(20)* c(2)+a(21)* c(3)+a(22)* c(1)* c(2)+a(23)* c(1)* c(3)+a(24)* c(2)* c(3)+a(25)* c(1)^2+a(26)* c(2)^2+a(27)* c(3)^2; % a(19-27)=c1-c9;
dC=dcdt;
end
C=Cv;
end
t=[1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92]; %Date has been changed as the number of days
c=[1.000 7.000 3213.600
0.000 4.000 801.600
5.000 9.000 7318.000
4.000 10.000 7484.800
1.000 9.000 6278.800
0.000 2.000 3627.000
9.000 14.000 11428.200
8.000 14.000 28964.400
3.000 12.000 17105.400
8.000 18.000 25014.400
2.000 7.000 11804.800
7.000 8.000 10900.200
2.000 11.000 12777.800
7.000 23.000 40046.000
5.000 8.000 12392.800
5.000 13.000 16536.200
4.000 11.000 13109.000
6.000 14.000 16646.200
8.000 25.000 27423.600
5.000 15.000 12499.000
1.000 8.000 4425.000
1.000 19.000 14349.800
4.000 8.000 11318.200
2.000 12.000 7484.000
1.000 5.000 8471.400
8.000 14.000 9131.600
4.000 7.000 10950.800
2.000 6.000 10974.600
1.000 4.000 1857.000
4.000 7.000 7062.400
1.000 8.000 16043.800
3.000 9.000 6595.800
5.000 13.000 13257.400
6.000 12.000 9779.800
11.000 35.000 15627.600
7.000 14.000 12987.400
5.000 15.000 19456.000
7.000 14.000 9041.000
14.000 28.000 27113.200
7.000 14.000 12796.600
3.000 9.000 8561.600
4.000 8.000 4341.200
5.000 15.000 11658.200
5.000 11.000 8380.600
10.000 26.000 15834.400
3.000 3.000 2738.200
10.000 19.000 18076.400
12.000 20.000 14008.000
5.000 9.000 5110.400
17.000 118.000 86777.400
7.000 67.000 51209.600
5.000 49.000 41304.400
1.000 3.000 3146.400
1.000 2.000 4092.800
8.000 18.000 23734.400
7.000 10.000 8169.200
5.000 8.000 8512.800
3.000 10.000 10953.200
4.000 5.000 6581.000
6.000 8.000 13055.800
1.000 9.000 9246.400
0.000 3.000 8936.200
0.000 1.000 3562.800
0.000 5.000 6120.600
1.000 8.000 5508.000
0.000 26.000 11413.400
0.000 10.000 7218.400
0.000 7.000 2654.200
0.000 4.000 6285.600
2.000 3.000 2991.400
0.000 2.000 5866.000
0.000 1.000 3023.400
0.000 6.000 4950.000
0.000 11.000 4568.400
0.000 2.000 5965.600
0.000 10.000 7409.000
0.000 7.000 5649.200
0.000 16.000 10562.400
0.000 3.000 1056.600
0.000 9.000 4186.300
4.000 27.000 4884.800
3.000 76.000 18786.200
0.000 72.000 1125.400
1.000 14.000 5084.800
1.000 18.000 8012.000
2.000 23.000 9884.000
0.000 6.000 1650.000
9.000 25.000 3276.400
9.000 21.000 10790.000
3.000 5.000 9129.600
0.000 8.000 8873.600
5.000 15.000 9368.200];
a0=[0.1;0.2;0.1;0.4;0.1;0.1;0.15;0.1;0.2;0.1;0.2;0.4;0.8;0.55;0.5;0.1;0.1;0.1;0.9;0.1;0.1;0.8;0.1;0.1;0.9;0.1;0.1];
options = optimoptions('lsqcurvefit','OptimalityTolerance', 1e-16,'FunctionTolerance', 1e-16,'FiniteDifferenceStepSize',1e-3);
[a,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat]=lsqcurvefit(@kinetics,a0,t,c,[],[],options)
fprintf(1,'\tRate Constants:\n')
for k1 = 1:length(a)
fprintf(1, '\t\ta(%d) = %8.5f\n', k1, a(k1))
end
tv = linspace(min(t), max(t));
Cfit = kinetics(a, tv);
figure(1)
plot(t, c, 'p')
hold on
hlp = plot(tv, Cfit);
hold off
grid
xlabel('Time')
ylabel('Concentration')
legend(hlp, 'C_1(t)', 'C_2(t)', 'C_3(t)', 'Location','N')
end
1 Comment
Torsten
on 20 Feb 2022
Edited: Torsten
on 20 Feb 2022
If you start with c0=[0 0 0], then - no matter what your parameters are - you will end up with c=[0 0 0] for all times t>0.
You will have to start with c at the initial time.
Are you sure that c(i,:) are the concentrations of the three substances at time t(i) ? In my opinion, there are too big jumps in the values for a continuous reaction.
Answers (1)
Nipun
on 24 Jan 2024
Hi Yi,
I understand that you are trying to fit the data in a given system of equations but are facing an error involving "local optimum".
This error indicates that the initial guess set for the system is already at the local mimum with respect to the objective function. Therefore, the gradient of the objective function with respect to the parameters is very small and the algorithm runs to completion as no other solution can yield a better objective value.
I suggest altering the initial guess for the system. As per the shared code, "c0 = [0 0 0]" does not seem to change it's value when the optimizer runs. Consider passing another parameter or change the value of "c0" for the optimizer to run to completion and not stall the initial guess.
Hope this helps.
Regards,
Nipun
0 Comments
See Also
Categories
Find more on Nonlinear Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!