Ho to Constraint GA to Generate Population Within Design Space
5 views (last 30 days)
Show older comments
Dear all,
I’m currently working on a genetic algorithm-based optimization and would like to constrain the GA to select design variables strictly within a predefined design space.
While I can set upper and lower bounds for the variables, my design space is more complex, and I’m working with a large population. I’m wondering if there’s a way to configure the GA so that it generates the populations entirely within the valid design space, rather than just filtering or penalizing out-of-bounds individuals afterward.
Attached is a simple sketch illustrating the shape of my design space.
Thanks in advance for your guidance!
Best regards,
Mirhan

0 Comments
Accepted Answer
Matt J
on 10 Apr 2025
Edited: Matt J
on 10 Apr 2025
Yes, you can reparametrize the design vector x as,
x=t1*v1+t2*v2
where v1 and v2 are the direction vectors of the two rays bounding your cone,
v1=[cosd(150),sind(150)]
v2=[cosd(30), sind(30)]
The new design variables are t=[t1,t2], which only need simple positivity constraints to confine x to the cone.
2 Comments
Matt J
on 10 Apr 2025
Edited: Matt J
on 10 Apr 2025
The code from your last comment is for a 3D problem, whereas your diagram was for a 2D problem. I will continue to assume the 2D problem whose design space is a cone at 30 degrees to the x-axis.
You need to reparametrize your fitness function in terms of t,
xoft=@(t) t(1)*v(1)+t(2)*v(2);
ObjectiveFunction = @(t) simple_objective( xoft(t));
% Run Genetic Algorithm
[t_opt, fval_opt] = ga(ObjectiveFunction, 2, [], [], [], [], [0,0], [], [], options);
x_opt = xoft(t_opt)
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!