Skip to Main Content Skip to Search
Accelerating the pace of engineering and science

How can I perform integer programming using the GA function in the Genetic Algorithm and Direct Search Toolbox?


Date Last Modified: Friday, May 4, 2012
Solution ID:   1-10PDHC
Product:   Global Optimization Toolbox
Reported in Release:   R14SP1
Fixed in Release:   R2011b
Platform:   All Platforms
Operating System:   All OS
 

Subject:

How can I perform integer programming using the GA function in the Genetic Algorithm and Direct Search Toolbox?

Problem Description:

I would like to perform integer programming or mixed integer programming using the GA function by constraining certain parameters to be integers.

Solution:

This enhancement has been incorporated in Release 2011b (R2011b). For previous product releases, read below for any possible workarounds:

To perform integer programming using the GA function, create a custom mutation function and a creation function that generate only integer outputs. Then, use the GAOPTIMSET function to set the "MutationFcn" and "CreationFcn" properties to the custom functions, as shown with the following code:
options = gaoptimset('CreationFcn',@your_creationfcn,'MutationFcn',@your_mutationfcn);

[x,fval] = ga(fitnessFcn,nVars,options);
See the attached example file "gainteger_demo.m".

General idea here is to take an approach based on a continuous parameter space strategy and make it integer based on well placed calls to rounding functions.

 

Related Documents/Files:

Please provide feedback to help us improve this Solution
Contact support