optimization using genetic algorithm

1 view (last 30 days)
risky amalia
risky amalia on 20 Jun 2021
Answered: Walter Roberson on 20 Jun 2021
i have 4 variables to optimize in GA which each have Upper Bound 100% and Lower Bound 0%. i need the result didn't exceed 100% when all the variable is summed. how to sum up my 4 variables into 100%??what code i have to write??
%Constrain
UB = [1 1 1 1];
LB = [0 0 0 0];
eBangkit = [];
Individu = [];
eIndividu = [];
david = [];
Dadatfit = [];
Datfit = [];
summary = [];
eDadatfit = [];
efitnessmax = [];
eIndividuMax = [];
Bangkit = round(rand(Npop,Nbit*Nvar));
popsize = size(Bangkit,1);
for i = 1:Nvar
batas(i) = UB(i)-LB(i);
end

Answers (1)

Walter Roberson
Walter Roberson on 20 Jun 2021
If you were using one of the Mathworks optimization functions such as ga() then you would use
A = [1 1 1 1]
b = 1
However you aappear to be writing your own ga code, so write whatever you want.

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!