Not enough input arguments when doing global optinisation

2 Ansichten (letzte 30 Tage)
Matthew Hunt
Matthew Hunt am 21 Feb. 2019
Beantwortet: Matthew Hunt am 21 Feb. 2019
I am trying to use the global optimisation toolbox to find some parameters which will make a computed curve overlay some experimental data. So I have two pieces of experimental data, t_data and V_data which I want to fit to and I have other sources of experimental data which I use in my function: I_app,SOC_a,SOC_c,OCV_c,OCV_a. I store the parameters I want to find in a colum vector, X. I define the function as follows:
fun = @(X,t_data)terminal_voltage(V_data,I_app,mu_n,t_data,X,SOC_a,SOC_c,OCV_c,OCV_a)';
I define a starting position X_0, and upper and lower bounds UB & LB. The mu_n is just some points I calculate offline. I ran the following code:
rng default % For reproducibility
gs = GlobalSearch;
problem = createOptimProblem('fmincon','x0',X_0,...
'objective',fun,'lb',LB,'ub',UB);
>> x = run(gs,problem);
and I received the following error:
Not enough input arguments.
Error in @(X,t_data)terminal_voltage(V_data,I_app,mu_n,t_data,X,SOC_a,SOC_c,OCV_c,OCV_a)'
Error in fmincon (line 546)
initVals.f = feval(funfcn{3},X,varargin{:});
Error in globalsearchnlp
Error in GlobalSearch/run (line 340)
globalsearchnlp(FUN,X0,A,B,Aeq,Beq,LB,UB,NONLCON,options,localOptions);
Caused by:
Failure in initial objective function evaluation. FMINCON cannot continue.
Failure in initial call to fmincon with user-supplied problem structure.
Any idea what's going on?

Antworten (1)

Matthew Hunt
Matthew Hunt am 21 Feb. 2019
I've seen what I need to do. The set up of the function is different to lsqcurvefit: I had to define the function as:
fun = @(X,t_data)terminal_voltage(V_data,I_app,mu_n,t_data,X,SOC_a,SOC_c,OCV_c,OCV_a)';
and I had to make my subjective function spit out a scalar rather than a vector so I had to make the function a norm.
It's running now. I have 10 parameters to find, any idea how long it will take?

Community Treasure Hunt

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

Start Hunting!

Translated by