MATLAB: Not enough input arguments for fmincon in multiobjective optimization problem

fmincongamultiobjMATLABnot enough input arguments

Hello all,
I am having a problem attmepting to get aninital minimum solution for the gamultiobj function using fmincon. I should point out that before attempting to modify the original code to include finding inital minimum points for an improved fgoalattain solution, the code was working and producing paretofronts for F=[f1,f2], both for the basic gamultiobj problem and also for fgoalattain without inital minima starting points.
In the pickindex function I am passing several variables into the optimization problem, and the problem is not solving currently. The error message I am receiving is that there are not enough input arguments; the lack of input arguments is in the decision variables. There are 3 decision variables for the multiobjective optimization problem, and fmincon does not appear to recognize this. I am attaching some pseudocode and the error below to demonstrate what the problem is. Any help or advice would be greatly appreciated.
Thank you,
HK
%% pseudocode
%% Section 0: define necessary vectors
% S0.1 define 1x72 vector Tambeq
% S0.2 define 1x90 vector Ttot
%% Section 1: gamultiobj
% define bound constraints lb, ub
% define function handle for objective functions
fun = @(x)objval(x, Tambeq, Ttot);
% S1.1 define options and gamultiobj parameters (optimoptions, A, etc.)
npts = 100;
opts_ga = optimoptions('gamultiobj','Display','off','PopulationSize',2*npts);
A = []; b = [];
Aeq = []; beq = [];
numberOfVariables = 3;
% fmincon for inital minima as start points
% find optimal points
x0 = zeros(2,3);
x0f = (lb + ub)/2;
opts_fmc = optimoptions('fmincon','Display','off','MaxFunctionEvaluations',1e4);
x0(1,:) = fmincon(@(x)pickindex(x,1,Ttot,Tambeq),x0f,[],[],[],[],lb,ub,[],opts_fmc);
x0(2,:) = fmincon(@(x)pickindex(x,2,Ttot,Tambeq),x0f,[],[],[],[],lb,ub,[],opts_fmc);
% call gamultiobj function
[x_ga,fval_ga,exitflag,gaoutput1] = gamultiobj(fun,numberOfVariables,A,b,Aeq,beq,lb,ub,opts_ga);
%% pickindex function for inital optimal points
function z = pickindex(x,k,Ttot,Tambeq)
z = @(x)objval(x, Tambeq, Ttot); % evaluate both objectives

z = z(k); % return objective k

end
%% Section 2: objective function definition
function F = objval(x, Tambeq, Ttot)
% S2.1 Panel physical parameters
% these use variables x(2) and x(3) (design variables)
% define 1x72 vector of incident angle on panel theta
% this requires design variable x(1)
[theta] = panelincidentangle1(alpha,gamma,n,sigma);
% define energy gain [1x72] and current temprature [1x72]
% return objective function values
F = [effavg, lossavg];
%% functions within objval function go here
function panelincidentangle1 = (variables)
[theta] = 1x72 vector
end
The error returned is:
Index exceeds the number of array elements (1).
Error in CORE_opt_paretosearch>objval (line 153)
Qflow = Vflow*x(3); % flow rate in panel, m^3/sec this is equivalent to
40L/min
Error in CORE_opt_paretosearch>@(x)objval(x,Tambeq,Ttot) (line 138)
z = @(x)objval(x, Tambeq, Ttot); % evaluate both objectives
Error in CORE_opt_paretosearch>pickindex (line 139)
z = z(k); % return objective k
Error in CORE_opt_paretosearch>@(x)pickindex(x,1,Ttot,Tambeq)
Error in fmincon (line 546)
initVals.f = feval(funfcn{3},X,varargin{:});
Error in CORE_opt_paretosearch (line 113)
x0(1,:) =
fmincon(@(x)pickindex(x,1,Ttot,Tambeq),x0f,[],[],[],[],lb,ub,[],opts_fmc);
Caused by:
Failure in initial objective function evaluation. FMINCON cannot
continue.
Of course, this is all in red text in the command window.

Best Answer

your first line of pick index assigns aa function handle to z. The second line invokes the function handle passing in kk which is the scalar 1 or 2.
remove the @(x) from that first line.