Controlling accuracy of variables in ga
3 次查看(过去 30 天)
显示 更早的评论
I have a problem where I am trying to use GA with some constraints. If the objective function = f(X) and constraints are AX <= B, where X is single dimension vector; is there a way I can control the accuracy of x1, x2 etc. I want them to be correct to 2 decimal places only. I tried scaling the problem by 100 and then setting integer constraints, but then, GA ignores the creationFcn option (where I want it to create only feasible population). Is there an alternate method to this ?
0 个评论
采纳的回答
Alan Weiss
2016-6-7
编辑:Alan Weiss
2016-6-7
You should definitely not use integer constraints when you don't need them.
The real question is, do you need to use ga? Think carefully about your problem. If it is smooth with smooth constraints (such as the one you mentioned), then use an Optimization Toolbox™ solver such as fmincon for speed and robustness. If your problem is not smooth, try patternsearch for speed and robustness.
It sounds like you don't need high accuracy for your solution. It is much easier to tune patternsearch than ga; for example, for two decimals of accuracy, set MeshTolerance to 3e-3 or something similar.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
2 个评论
Alan Weiss
2016-6-8
编辑:Alan Weiss
2016-6-8
If you have finite bounds on all variables, then I strongly suggest that you use patternsearch with a variety of initial points, perhaps
x0 = lb + rand(size(lb)).*(ub-lb);
You can create points and discard them if they are not feasible, meaning check whether
A*x0(:) <= b(:)
where A and b are your linear inequality constraints.
And if you don't have finite bounds on all variables, then you are not likely to get satisfaction from ga, because it has implicit bounds on its initial population anyway.
There is nothing magic in ga in terms of creating initial points. It uses linprog to generate feasible points that satisfy linear constraints and bounds (you could do that, too, for patternsearch). And patternsearch is so much faster, more robust, and easier to tune, that I believe you will be much more satisfied if you give it another try.
Alan Weiss
MATLAB mathematical toolbox documentation
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Direct Search 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!