writing lower and upper bound in genetic algorithm

1 vue (au cours des 30 derniers jours)
adarsh
adarsh le 17 Fév 2018
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.

Réponse acceptée

Walter Roberson
Walter Roberson le 17 Fév 2018
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.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by