How do I pass non-decision variables into gamultiobj?

4 Ansichten (letzte 30 Tage)
henry kagey
henry kagey am 26 Nov. 2018
Beantwortet: Alan Weiss am 27 Nov. 2018
I hope I have formulated this question corectly:
I am attempting to use gamultiobj to find a pareto solution for a design problem and I am having some difficulty with the objective function call. I have searched around, gone over/written some test scripts, and have some idea of how to use the function, but I am doing something incorrectly and would like to understand how to use matlab built in functions to solve this. I have pasted a pseudocode and error message below. Any help or advice would be appreciated.
I have an multi-objective optimization problem I am attempting to solve. The problem itself is a maximization problem where the only constraints are the lower and upper bounds on the decision variables. In the objective function definition I am attempting to pass in vectors that have been previously defined. It is causing problems and I am not sure why. Further, I have functions embedded inside the objective function definition. I am not sure if this is also causing problems, but I do not see why it would. Finally, the objective functiosn themselves are not written in terms of 'x' (the vector of decision variables), but the way in which they are defined requires their previous use. Again, I am not sure if this would cause a problem, but I don't see why it would.
If anyone has any ideas or guidance about how I am misusing Matlab's built ins for gamultiobj here, please let me know where I am attmepting to write this code without understanding.
Thank you,
HK
I have written out a mock up of the code in order to better describe/demonstrate what I am attempting to do:
%% 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 = @objval;
% 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;
% call gamultiobj function
[x_ga,fval_ga,exitflag,gaoutput1] = gamultiobj(fun,numberOfVariables,A,b,Aeq,beq,lb,ub,opts_ga);
%% Section 2: objective function definition
function F = objval(x, Tambeq, Ttot)
% NOTE: Tambeq and Ttot passed along with x
% S2.1 Panel physical parameters
% these use variables x(2) and x(3) (design variables)
% S2.2 Solar data to vector functions
% these function calls happen inside the function objval
% define ele and azi from raw data
[ele,azi] = solardata1(elez,aziz);
% define alpha and gamma from ele, azi, n, and delta
[alpha,gamma] = solardatatovector1(ele,azi,n,delta);
% define 1x72 vector of incident angle on panel theta
% this requires design variable x(1)
[theta] = panelincidentangle1(alpha,gamma,n,sigma);
% S2.3 Get heat source vector
% define 1x72 vector Stot from [theta]
% S2.4 Heat loss definitions
% define parameters of heat loss
% S2.5 Heat loss and temperature gain calculations
% iteratation loop to get accurate radiation loss coefficients
% define heat loss coefficents
% define energy gain [1x72] and current temprature [1x72]
% define objective functions effavg and lossavg, these are single values
% for example: effavg(energygain(x(1),x(2),x(3),t))
% return objective function values
F = [effavg, lossavg];
This is the error message I am receiving:
Not enough input arguments.
Error in heatgamulti_bugfix>objval (line 214)
ta = Ttot(ang); % (defined in 0.2)
Error in createAnonymousFcn>@(x)fcn(x,FcnArgs{:}) (line 11)
fcn_handle = @(x) fcn(x,FcnArgs{:});
Error in gamultiobjMakeState (line 28)
Score = FitnessFcn(state.Population(1,:));
Error in gamultiobjsolve (line 8)
state =
gamultiobjMakeState(GenomeLength,FitnessFcn,ConstrFcn,output.problemtype,options);
Error in gamultiobj (line 303)
[x,fval,exitFlag,output,population,scores] =
gamultiobjsolve(FitnessFcn,nvars, ...
Error in heatgamulti_bugfix (line 135)
[x_ga,fval_ga,exitflag,gaoutput1] =
gamultiobj(fun,numberOfVariables,A,b,Aeq,beq,lb,ub,opts_ga);
Caused by:
Failure in initial fitness function evaluation. GAMULTIOBJ
cannot continue.

Antworten (1)

Alan Weiss
Alan Weiss am 27 Nov. 2018
The way of including extra parameters is described in Passing Extra Parameters. So in your case, instead of
fun = @objval;
you should write (after getting Tambeq and Ttot into the workspace)
fun = @(x)objval(x, Tambeq, Ttot)
Alan Weiss
MATLAB mathematical toolbox documentation

Kategorien

Mehr zu Graphics Object Properties finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by