Ho to Constraint GA to Generate Population Within Design Space
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Matt J
2025-4-10
编辑:Matt J
2025-4-10
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 个评论
Matt J
2025-4-10
编辑:Matt J
2025-4-10
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)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!