writing lower and upper bound in genetic algorithm
2 次查看(过去 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!