writing lower and upper bound in genetic algorithm
조회 수: 1 (최근 30일)
이전 댓글 표시
I have 200 number of variables, each having lower and upper bound first 50 variables are for pressure (all having lower and upper bound as 10 and 20 respectively), second 50 are for diameter(all having lower and upper bound as 16 and 30 respectively), next 50 are for flow rate (all having lower and upper bound as 15 and 20 respectively) and finally next 50 are velocity( all having lower and upper bound as 6 and 20 respectively). How to write in Genetic algorithm.
xl=[10 10 10 10 .......10 16........16...........15.....6................]
xu=[20.................20 30 30...........20.....20...............]
is there any way in programming , through which i can state that variables 1 to 50 have lower and upper bound as 10 and 20, and in the same way for all.
댓글 수: 0
채택된 답변
Walter Roberson
2018년 2월 17일
xl = repelem([10 16 15 6], [50 50 50 50]);
xu = repelem([20 30 20 20], [50 50 50 50]);
If your MATLAB is too old for repelem then
xl = kron([10 16 15 6], ones(1,50));
xu = kron([20 30 20 20], ones(1,50));
or
xl = [10 * ones(1,50), 16 * ones(1,50), 15 * ones(1,50), 6 * ones(1,50));
xu = [20 * ones(1,50), 30 * ones(1,50), 20 * ones(1,50), 20 * ones(1,50));
The kron version requires that each item be repeated the same number of times, but the other two versions would allow a different number of repetitions for each value.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!