Question regarding Genetic Algorithm
显示 更早的评论
Hi,
I would like to maximize a function with a constraint using the genetic algorithm. The problem is that for the 'x' vector I would like only values like those 0,[min,max]. So I can't use the boundary condition because it will exclude zero.
Thank you for your ideas.
regards.
回答(1 个)
Alan Weiss
2013-12-2
0 个投票
Perhaps you can encode your problem as integer. Set lb = zeros(1,N), ub = 2+lb. When x = 0, you are set. When x = 1, map it to [min]. When x = 2, map it to [max].
But perhaps what you mean is your x variables are either 0 or are continuous between min and max. In that case, I suggest you make two variables for each component, one binary (I mean 0 or 1). The other should be continuous between min and max. Set the final variable to be binary*continuous.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
2 个评论
Guillaume
2013-12-3
Alan Weiss
2013-12-3
Suppose your x is two-dimensional, x(1) and x(2). Create x(3) and x(4) as binary variables, and let x(1) and x(2) vary between min and max. Set z(1) = x(1)*x(3) and z(2) = x(2)*x(4). Then the variable z has the properties you want. Do all your calculations with input variables x(1)...x(4) and output variables z.
Alan Weiss
MATLAB mathematical toolbox documentation
类别
在 帮助中心 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!