The documentation for the GA function in the Genetics Algorithm and Direct Search toolbox version R14 and above discusses different methods for passing additional arguments to the objective function. This documentation can be accessed by executing the following at the MATLAB prompt:
The online documentation for the GA function is available at,
This documentation gives a link to the section on Passing Extra Parameters in the Optimization Toolbox User's Guide. The online documentation on Passing Extra Parameters is available at,
For previous releases, please read below for any possible workarounds:
Passing additional parameters to the GA or PATTERNSEARCH functions is performed differently than for other functions within MATLAB (e.g., the ODE45 or QUAD functions). For GA or PATTERNSEARCH, the first input argument can be a cell array whose first element is the objective function handle, and each subsequent element is an additional parameter.
[x f] = ga({@objfcn, P1, P2}, 2);
The reason for the change in syntax is that there are different function that can be specified for use within the GA or PATTERNSEARCH functions (e.g., "MutationFcn" and "CrossoverFcn"). Each of these functions can take different input parameters. In the Optimization Toolbox syntax, each function must take the same input parameters. However, in the Genetic Algorithm and Direct Search Toolbox, you can specify different parameters for each function.
options = gaoptimset('MutationFcn', {@mutate, P1}, 'CrossoverFcn', {@cross, P2})
An example of this can be seen in the "Minimizing using additional arguments" example at the following URL: