Question Regarding MultiObjective Optimization - gamultiobj
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Fatih Yigit
am 25 Jan. 2022
Beantwortet: Fatih Yigit
am 26 Jan. 2022
Hi. I want to create a model for multi objective optimization.
I have 300 items and three variables for each. Objective is the a function of using 300 items * 3 variables. So I don't want to write 900 seperate variables in the function, if possible. Thanks a lot in advance.
My code is as follows. Also I receive the following error.
error message
++
Not enough input arguments.
Error in globalfun (line 6)
y(1) = sum((1-x(1,1)*0.99)+(1-x(1,2)*0.95)+(1-x(1,3)*0.90));
Error in MCICv2 (line 26)
[x,fval] = gamultiobj(globalfun,numberOfVariables);
++
Script part
++
clc;clear all;close all;
global leadtime
data = readmatrix('Data.xlsx');
data(:,1) = [1:301];
ProductCodes = data(:,1);
LeadTime = data(:,4); %This is the value I use for Multi-Objective Optimization
[widthdata, heightdata]= size(data);
numberOfVariables = i*3;
[x,fval] = gamultiobj(globalfun,numberOfVariables);
++
Function Part
+++
function y = globalfun(x)
global LeadTime
y(1) = sum((1-x(:,1)*0.99)+(1-x(:,2)*0.95)+(1-x(:,3)*0.90)); %minimize the sum of all 301 items
y(2) = (x(:,1)*norminv(0.99))+(x(:,2)*norminv(0.95))+(x(:,3)*norminv(0.90))*sqrt(LeadTime(:)); %minimize the sum of this function for 301 items
end
+++
3 Kommentare
Akzeptierte Antwort
Alan Weiss
am 26 Jan. 2022
I have a hard time understanding you because you use vocabulary that is not standard. You say that you have items. I ask about control variables and data. Is an item a control variable or data?
data(:,1) = [1:301];
I wonder whether this should be transposed:
data(:,1) = [1:301]';
You show your function call as
result = gamultiobj(globalv6, 903);
Is globalv6 a function handle? I mean, I would expect the function call to be
result = gamultiobj(@globalv6, 903); % Note the @ sign
But the more important question is, do you have no constraints on x, not even bounds? For example, should your x variables be positive? Less than 1? I think so, so you would want to incorporate bounds
lb = zeros(1,903);
ub = ones(1,903);
result = gamultiobj(@globalv6, 903,[],[],[],[],lb,ub);
Alan Weiss
MATLAB mathematical toolbox documentation
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Genetic Algorithm finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!