Skip to Main Content Skip to Search
Product Documentation

Performing a Genetic Algorithm Optimization

Calling the Function ga at the Command Line

To use the genetic algorithm at the command line, call the genetic algorithm function ga with the syntax

[x fval] = ga(@fitnessfun, nvars, options)

where

The results are given by

Using the function ga is convenient if you want to

Using the Genetic Algorithm from the Command Line provides a detailed description of using the function ga and creating the options structure.

Using the Optimization Tool

To open the Optimization Tool, enter

optimtool('ga')

at the command line, or enter optimtool and then choose ga from the Solver menu.

You can also start the tool from the MATLAB Start menu as pictured:

To use the Optimization Tool, you must first enter the following information:

You can enter constraints or a nonlinear constraint function for the problem in the Constraints pane. If the problem is unconstrained, leave these fields blank.

To run the genetic algorithm, click the Start button. The tool displays the results of the optimization in the Run solver and view results pane.

You can change the options for the genetic algorithm in the Options pane. To view the options in one of the categories listed in the pane, click the + sign next to it.

For more information,

  


Free Optimization Interactive Kit

Learn how to use optimization to solve systems of equations, fit models to data, or optimize system performance.

Get free kit

Trials Available

Try the latest version of optimization products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS