using gamultiobj with 24 variables
이전 댓글 표시
My fitness function (fit_KotPol) calculate two values for 24 variables. I want to define the inti
fitnessfcn = @fit_KotPol;
nvars = 24;
lb=[22.2 22.2 22.2 22.2 22.2 22.2 22.2 22.2 22.2 22.2 22.2 22.2 0 0 0 0 0 0 0 0 0 0 0 0];
ub=[172.9 172.9 172.9 172.9 172.9 172.9 172.9 172.9 172.9 172.9 172.9 172.9 140 140 140 140 140 140 140 140 140 140 140 140];
A = [ ]; b = [ ]; Aeq = [ ]; beq = [ ];
startTime = tic;
options = optimoptions('gamultiobj','UseParallel',true,'PlotFcn',{@gaplotpareto,@gaplotscorediversity});
[x,fval,exitflag,output] = gamultiobj(fitnessfcn,nvars,lb,ub,options);
stopTime = toc(startTime);
I got the error
Error using gamultiobj (line 281)
GAMULTIOBJ requires the following inputs to be of data type double: 'Aeq'.
Help me to use the gamultiobj
답변 (2개)
Hi,
the input syntax for gamultiobj has no option for passing lb and ub to gamultiobj without also passing A,b Aeq, beq. You defined them all, but you dont use them in your function call.
Use:
[x,fval,exitflag,output] = gamultiobj(fitnessfcn,nvars,A,b,Aeq,beq,lb,ub,options);
Best regards
Stephan
댓글 수: 16
Thushara De Silva
2018년 9월 24일
I would expect this to work:
options = optimoptions(@gamultiobj,'UseParallel',true,'PlotFcn',{@gaplotpareto,@gaplotscorediversity});
Thushara De Silva
2018년 9월 27일
Stephan
2018년 9월 27일
Can you attach the code you have tried so far?
Thushara De Silva
2018년 9월 27일
편집: Walter Roberson
2018년 9월 28일
You could try:
function A = fit_KotPol(x)
...several calculations
A(1) = A;
A(2) = B;
end
Since this is a difference to the examples given in the documentation. The objectives in documentation are stored in one vector. I could imagine that this is the problem.
Thushara De Silva
2018년 9월 27일
Stephan
2018년 9월 28일
parallel does not have to be fast. I recommend you to vectorize the function. then you can choose the option
'UseVectorized',true
instead of parallel.
Thushara De Silva
2018년 9월 28일
Stephan
2018년 9월 28일
Can you attach the code of your function?
Thushara De Silva
2018년 9월 28일
편집: Walter Roberson
2018년 9월 28일
Thushara De Silva
2018년 9월 28일
편집: Walter Roberson
2018년 9월 28일
Stephan
2018년 9월 28일
How often does your code run? Is it worth revising the code, or is it better to wait 3 days for the calculation to finish, because the code is only used a few times?
Thushara De Silva
2018년 9월 28일
편집: Walter Roberson
2018년 9월 28일
Walter Roberson
2018년 9월 28일
The number of pareto points returned by gamultiobj is not known in advance.
x will be m by nvars, so something by 24 in your case, where m is however many pareto points the function detected during the limits it was given on execution.
Thushara De Silva
2018년 9월 28일
Thushara De Silva
2018년 9월 27일
편집: Walter Roberson
2018년 9월 28일
0 개 추천
댓글 수: 1
Walter Roberson
2018년 9월 28일
When you supply a population matrix in the options, if the number of rows you provide is less than the population size, then it will initialize the remaining rows randomly.
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!