-
Notifications
You must be signed in to change notification settings - Fork 518
Open
Description
When I am trying to calculate the three objective values using one function, I find 'evalFcn' is a good alternative to 'objFcn', since it get all the three objective values at the same time, and you do not need three separate functions for the three objectives. However, when I tried the template provided from the documentation in Page 8, the error occurred.
This is the code:
clear
clc
platemo('evalFcn',@Eval, 'encoding',[1,1,1,2,2,4],'lower',0,'upper',[1,9,9,9,9,9],'M',2)
function [x,f,g] = Eval(x)
x = [round(x(1)/0.1)*0.1,x(2:end)];
x = max(0,min([1,9,9,9,9,9],x));
f(1) = x(1)+sum(x(2:end));
f(2) = sqrt(1-x(1)^2)+sum(x(2:end));
g = 1-sum(x(2:end));
end
and this is the error information:
Error using assert
the size of its output #2 should be 1*1,
while its current size is 1*2.
Error in UserProblem>CallFcn (line 233)
assert(ismatrix(varargout{i})&&all(size(varargout{i})==varargin{i}),'the size of its output #%d should be %d*%d, while its current size is %d*%d.',i,varargin{i}(1),varargin{i}(2),size(varargout{i},1),size(varargout{i},2));
Error in UserProblem/Evaluation (line 83)
[PopDec(i,:),PopObj(i,:),PopCon(i,:)] = CallFcn(obj.evalFcn,varargin{1}(i,:),obj.data,'evaluation function',[1 obj.D],[1 1],[1 1]);
Error in PROBLEM/Initialization (line 130)
Population = obj.Evaluation(PopDec);
Error in UserProblem/Initialization (line 72)
Population = Initialization@PROBLEM(obj,N);
Error in UserProblem (line 61)
Pop = obj.Initialization(1);
Error in platemo (line 96)
Problem = PRO(input{:});
Error in untitled3 (line 5)
platemo('evalFcn',@Eval, 'encoding',[1,1,1,2,2,4],'lower',0,'upper',[1,9,9,9,9,9],'M',2)
Caused by:
The evaluation function is invalid
Everyone can try this demo easily. If anyone find it is feasible, then it must be my problem. Otherwise, it is an important bug.
Metadata
Metadata
Assignees
Labels
No labels