writing lower and upper bound in genetic algorithm
1 view (last 30 days)
Show older comments
adarsh
on 17 Feb 2018
Answered: Walter Roberson
on 17 Feb 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.
0 Comments
Accepted Answer
Walter Roberson
on 17 Feb 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.
0 Comments
More Answers (0)
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!