Error: NSGA-II algorithm for the cost and satisfaction objectives
7 ビュー (過去 30 日間)
古いコメントを表示
When running the main program main.m in MATLAB 2016a, the following error message keeps appearing. Please modify the code based on the error message below to ensure that the modified code runs smoothly and outputs the correct results.
"Index exceeds matrix dimensions."
Error in CalcCrowdingDistance (line 27):
d(so(i), j) = abs(cj(i+1) - cj(i-1)) / abs(cj(1) - cj(end));
Error in nsga2 (line 95):
pop = CalcCrowdingDistance(pop, F);
0 件のコメント
回答 (1 件)
Arnav
2024 年 11 月 8 日 6:28
The error is due to accessing the matrix cj with an index i exceeding its dimensions in line 27 of CalcCrowdingDistance.m. The index i goes from 2 to n-1.
Replacing line 12
n = numel(F{k});
with
n = numel(Costs);
fixes the error as the length of cj is the length of Costs and not F{k}.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!