Genetic algorithm- error when providing constraints in a loop
이전 댓글 표시
Hi. I am using ga for a problem with multiple constraints. I provide constraints in a for loop using the comand "vercat" and I get the following error on execution
Not enough input arguments.
Error in simple_constraint (line 13)
c=vertcat(c,(sum(x(cin)))-1);
Does GA allow this? or I will have to hardcode each constraint? Please guide.
댓글 수: 9
Walter Roberson
2019년 4월 2일
Please show your code.
Umber Saleem
2019년 4월 2일
Walter Roberson
2019년 4월 2일
Please show all of your code.
Note: we recommend against using global variables. http://www.mathworks.com/help/matlab/math/parameterizing-functions.html
Umber Saleem
2019년 4월 2일
편집: Umber Saleem
2019년 4월 2일
Umber Saleem
2019년 4월 2일
Walter Roberson
2019년 4월 2일
The portion starting from the %%%% appears to belong to a separate file. However if that code is moved to a separate file, then x and inea are not defined.
Your code uses K, M, N as sizes for reshape() purposes, but never assigns values to them. As they are global variables, they will be initialized to [] (the empty array), which is going to lead to problems in execution.
Umber Saleem
2019년 4월 2일
Umber Saleem
2019년 4월 2일
Walter Roberson
2019년 4월 2일
We can make guesses, but it is difficult to reproduce that behaviour without the actual code.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!