Question Regarding MultiObjective Optimization - gamultiobj
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Alan Weiss
2022년 1월 26일
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
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!