Global optimization using genetic algorithm
显示 更早的评论
I use ff2n function to generate the input for my function. For the example of ff2n(4), some sample input rows are:
1 0 1 0
1 1 0 0
0 0 1 1
...
...
Based on the input from ff2n(4), a total of 16 scalar values will be generated for my function. If I sorted the 16 scalar values generated, I will be able to find the minimum value.
Can I use GA to find the minimum value for my function based on the following commands?
>> [x fval exitflag] = ga(@my_fun, 2)
My input values are fixed, which are 0 and 1. Can I consider the total number of variables as 2? Is it possible for me to get the following sample output:
x = 1 1 0 0
fval = 0.12345
exitflag = 1
If this GA command is inapplicable, please give me some suggestions how can I use GA to solve my problem.
Alternatively, in order to get the x and fval values, can I use the optimization toolbox by choosing GA solver, enter my fitness function, put 2 as number of variables and run it?
回答(1 个)
Alan Weiss
2012-10-23
0 个投票
You might do well to read the documentation on ga with integer constraints. If I understand you, for this case you have n = 4 dimensions, not 2, because there are 4 design variables. Each design variable is binary, so is integer valued with a lower bound of 0 and an upper bound of 1.
Alan Weiss
MATLAB mathematical toolbox documentation
4 个评论
Alan Weiss
2012-10-29
Your population looks 4-dimensional to me, with each component given as one of two different values. This can be mapped to integer (binary) variables, as in the example. To get those two values, set the x components as integers with lower bounds of 0 and upper bounds of 1, and map
y = x0 + (x1 - x0)*x
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
where x0 is your lower number 3.98765 and x1 is your upper number 4.98765.
Sata
2012-11-6
类别
在 帮助中心 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!