MATLAB: Controlling accuracy of variables in ga

accuracy of variables in gaGlobal Optimization ToolboxMATLAB

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 ?

Best Answer

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