GA Function non linear Constraints decrease Initial Population to 1 ?
Dear Matlab users,
I am currently having a problem to define the nonlinear constraints.
The point of problem is with nonlinear constraints, it doesnt’ keep the number of initial population to fitnessfunction and left even only one individual.
But without nonlinear constraints option it keeps 45 individuals.
Please take a look this codes and may very greatful, when you write me any small tips.
size(InitPop) = 45
Vectorized= ‘on’
1. Starting InitialPopulation [45,9]
options = optimoptions(@ga, ‘PopulationSize’, 45, ‘InitialPopulation’, InitPop, …
‘PopulationType’, ‘doubleVector’, ”MaxStallGenerations’, 10, …
‘FunctionTolerance’, 1e-03, ‘MaxGenerations’, 100, ‘Vectorized’, ‘on’);
2.
[Value, fval, ~, output] = ga(@fitnessfunction, nvars, [], [], [], [], lb,ub, @nonlincon, [], options);
3. Definition of nonlinear constraints
function [c, ceq] = nonlincon(x)
c = 3 – (x(:, 1) + 3 * tan(x(:, 2)));% 3 – (x1 + 3tan(x2)) <= 0
ceq = [];
end
Thank you so much for time
Best regards.Dear Matlab users,
I am currently having a problem to define the nonlinear constraints.
The point of problem is with nonlinear constraints, it doesnt’ keep the number of initial population to fitnessfunction and left even only one individual.
But without nonlinear constraints option it keeps 45 individuals.
Please take a look this codes and may very greatful, when you write me any small tips.
size(InitPop) = 45
Vectorized= ‘on’
1. Starting InitialPopulation [45,9]
options = optimoptions(@ga, ‘PopulationSize’, 45, ‘InitialPopulation’, InitPop, …
‘PopulationType’, ‘doubleVector’, ”MaxStallGenerations’, 10, …
‘FunctionTolerance’, 1e-03, ‘MaxGenerations’, 100, ‘Vectorized’, ‘on’);
2.
[Value, fval, ~, output] = ga(@fitnessfunction, nvars, [], [], [], [], lb,ub, @nonlincon, [], options);
3. Definition of nonlinear constraints
function [c, ceq] = nonlincon(x)
c = 3 – (x(:, 1) + 3 * tan(x(:, 2)));% 3 – (x1 + 3tan(x2)) <= 0
ceq = [];
end
Thank you so much for time
Best regards. Dear Matlab users,
I am currently having a problem to define the nonlinear constraints.
The point of problem is with nonlinear constraints, it doesnt’ keep the number of initial population to fitnessfunction and left even only one individual.
But without nonlinear constraints option it keeps 45 individuals.
Please take a look this codes and may very greatful, when you write me any small tips.
size(InitPop) = 45
Vectorized= ‘on’
1. Starting InitialPopulation [45,9]
options = optimoptions(@ga, ‘PopulationSize’, 45, ‘InitialPopulation’, InitPop, …
‘PopulationType’, ‘doubleVector’, ”MaxStallGenerations’, 10, …
‘FunctionTolerance’, 1e-03, ‘MaxGenerations’, 100, ‘Vectorized’, ‘on’);
2.
[Value, fval, ~, output] = ga(@fitnessfunction, nvars, [], [], [], [], lb,ub, @nonlincon, [], options);
3. Definition of nonlinear constraints
function [c, ceq] = nonlincon(x)
c = 3 – (x(:, 1) + 3 * tan(x(:, 2)));% 3 – (x1 + 3tan(x2)) <= 0
ceq = [];
end
Thank you so much for time
Best regards. ga, genetic algorithm, optimization MATLAB Answers — New Questions