Fmincon Error: not enough input arguments

4 次查看(过去 30 天)
Hi,
I have to optimize parameters of a system of two ordinary differential equations. Therefore I wrote the following code. If I run the main file, I get the error: "not enough input arguments. Caused by: Failure in initial objective function evaluation. FMINCON cannot continue. " This error occurs in the obj1 function file, in the line, where the ode solver is used. If I uncomment the testparameters in the obj1 function, the error does not occur. Does anyone have an idea how to avoid this error?
p.s.: is this basically the right way to optimize the parameters of a system of ODEs or should it be done in a completely different way?
Main file:
LB = zeros(1,8);
x0 = LB;
UB = [Inf,Inf,Inf,Inf,Inf,Inf,Inf,Inf];
[x,fval] = fmincon(@obj1,x0,[],[],[],[],LB,UB);
Definition of function which I want to optimize
function [flux] = obj1(K_a_F,K_a_T,K_b_F,K_b_T,r_a_F,r_a_T,r_b_F,r_b_T)
k1 = 10^-2; k_1 = 8* 10^-3; k2 = 10^-2; k_2 = 4*10^-3;
%testparameters
%K_a_F = 9.4*10^5; K_a_T = 3.9*10; K_b_F = 1.3*10^4; K_b_T = 1.2*10^-10;
%r_a_F = 4.3*10^7; r_a_T = 4.2*10^9; r_b_F = 6.9*10^-7; r_b_T = 6.2*10^-9;
a = 10^5;
T0 = 27; T1 = 33;
tscale = 1:3000;
T = importdata('KursAT');
F = importdata('kursAF');
chiT = @(T) (-1/pi * (atan(a*(T-T1)) + atan(a*(T-T0))));
Ft = @(x)interp1(tscale,F,x,'spline');
Tt = @(x)interp1(tscale,T,x,'spline');
[t,sol] = ode45(@(t,dyn) dynamics(t,dyn,Ft,Tt,K_a_F,K_a_T,K_b_F,K_b_T,r_a_F,r_a_T,r_b_F,r_b_T), [1,3000] , [60 30]);
A = @(x)interp1(t,sol(:,1),x,'spline');
B = @(x)interp1(t,sol(:,2),x,'spline');
f = @(x,T,F,A,B) (chiT(T(x)).*(k2 *B(x)-k_2*T(x)) + chi_F(F(x),chiT,T(x)).*(k_1*A(x)-k1*F(x)));
tau = 3000;
flux = integral(@(x)f(x,Tt,Ft,A,B),0,tau);
Definition of ordinary differential equations
function [ddyn] = dynamics(t,dyn,F,T,K_a_F,K_a_T,K_b_F,K_b_T,r_a_F,r_a_T,r_b_F,r_b_T)
%kinetic parameters, unit: 1/s
k1 = 10^-2; k_1 = 8* 10^-3; k2 = 10^-2; k_2 = 4*10^-3;
%Vmax for enzymes alpha and beta, unit: mM/s
V_max_a = 1.6; V_max_b = 3.5;
%Michaelis-Menten constants for enzymes alpha and beta, unit: mM
K_M_a = 1.5*10^-3; K_M_b = 2*10^-3;
ddyn = zeros(2,1);
R_a_F = (K_a_F + r_a_F* F(t))./(K_a_F + r_a_F);
R_a_T = (K_a_T + r_a_T* T(t))./(K_a_T + r_a_T);
R_b_F = (K_b_F + r_b_F* F(t))./(K_b_F + r_b_F);
R_b_T = (K_b_T + r_b_T* T(t))./(K_b_T + r_b_T);
v_a = (V_max_a*dyn(1))./(K_M_a + dyn(1))*R_a_F *R_a_T;
v_b = (V_max_b*dyn(2))./(K_M_b + dyn(2))*R_b_F *R_b_T;
ddyn(1) = k1*F(t) + v_b - k_1*dyn(1) - v_a;
ddyn(2) = k2*T(t) + v_a - k_2*dyn(2) - v_b;

采纳的回答

Matt J
Matt J 2016-6-23
编辑:Matt J 2016-6-23
The objective obj1 that you've shown is a function of 8 separate scalar arguments. However, fmincon expects it to be a function of a single 1x8 vector argument. Re-write your input syntax for obj1 to give fmincon what it expects.
  4 个评论
Maximilian Ernst
Maximilian Ernst 2016-6-23
ah ok thank you! I accidently deleted the arguments Ft and Tt , in dynamics

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by