Question Regarding MultiObjective Optimization - gamultiobj

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
Alan Weiss 2022 年 1 月 25 日
Sorry, I don't quite understand what you are trying to do. How many variables do you have in your optimization, I mean variables that you can control, not data? Do you have 3 variables? 300? 900? I understand that you have two objective functions, but I cannot easily tell which variables you can control and which are data that you do not control.
Alan Weiss
MATLAB mathematical toolbox documentation
Fatih Yigit
Fatih Yigit 2022 年 1 月 25 日
編集済み: Fatih Yigit 2022 年 1 月 25 日
Thanks for your response. Let me explain this way. I have 300 items.
Each item has a parameter called `LeadTime(:)`.
This parameter will be multiplied with X(:,1) & x(:,2) and (x(:,3) as given in the formula.
++
sum((1-x(:,1)*0.99)+(1-x(:,2)*0.95)+(1-x(:,3)*0.90))
++
So all items will have a single value. The goal is to minimize the sum of the function for 300 items.
In short, I'll have 900 variables. 3 variables will affect a single item with a `LeadTime(n)` . n=1,2,3....300
This part is just the beginnig, but I am even struggling in this part. Hope it is more clear now. Thanks for your time again.
Fatih Yigit
Fatih Yigit 2022 年 1 月 25 日
To be more precise; I attach the script, function, error in the following lines. If I manually assign x e.g [1:301] function works. But not via "gamultiobj".
This is the main script
++
clc;clear all;close all;
global LeadTime; %301 items
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);
result = gamultiobj(globalv6, 903);
++
this is the function
+++
function y = globalv6(x)
global LeadTime
[width, height] = size(LeadTime); %width is 301
j=0;
for i=1:3:(3*width)
j=j+1;
result(j,1) = x(i)+x(i+1)+x(i+2);
result(j,2) = ((1-x(i)*0.99)+(1-x(i+1)*0.95)+(1-x(i+2)*0.90));
end
y(1) = sum(result(:,1));
y(2) = sum(result(:,2));
end
++
error;
Not enough input arguments.
Error in globalv6 (line 8)
result(j,1) = x(i)+x(i+1)+x(i+2);
Error in MCICv3 (line 13)
result = gamultiobj(globalv6, 903);

サインインしてコメントする。

 採用された回答

Alan Weiss
Alan Weiss 2022 年 1 月 26 日

0 投票

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

その他の回答 (1 件)

Fatih Yigit
Fatih Yigit 2022 年 1 月 26 日

0 投票

Thanks for your help. You are right. Items are actually that have values used as parameters.
I now know that the main problem is not using "@".
My model will have multiple constraints but I just want to start understanding the use use of "gamultiobj" first. Now it is clear.
For the time being mty problem is solved. Again thanks for your help.

カテゴリ

質問済み:

2022 年 1 月 25 日

回答済み:

2022 年 1 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by