Welcome to the world of Optimizations

In this blog concepts of conventional and unconventional optimization techniques are discussed.

Monday, November 8, 2010

Economic Load Dispatch :An Intorduction

Solving Optimization Problems Using MATLAB GA toolbox-Part 2

Now let us learn how to use the GA in command line mode.
the basic syntax to run the GA in command mode is
x = ga(@fitnessfunction,nvar,options)

fitnessfunction:Function file relating the control variables(x) with function value(F).

nvar: no of  control variables

options: Genetic algorithm parameters setting.


GA Options



PopulationType: [ 'bitstring'      | 'custom'    | {'doubleVector'} ]:-Type of the population 'custom' :  :binary,'double vector': real values

PopInitRange: [ matrix           | {[0;1]} ]: Initial value range default is [0 to 1] you can change this by giving two column vectors .For the example problem discussed for the GUI mode the limits can be like this
l=[0 0]'; u=[10 10]';

        
PopulationSize: [ positive scalar  | {20} ]-Size of the population

            
EliteCount: [ positive scalar  | {2} ]:The number best solution in each generation to be saved.

    
CrossoverFraction: [ positive scalar  | {0.8} ]: cross over value between 0 to 1

    
MigrationDirection: [ 'both'           | {'forward'} ]  The solution vector is moved in both direction.(increase or decrease)
    
MigrationInterval: [ positive scalar  | {20} ]
    
MigrationFraction: [ positive scalar  | {0.2} ]

          
Generations: [ positive scalar  | {100} ]: no of iterations
            
TimeLimit: [ positive scalar  | {Inf} ]: Time Limit for the algorithm

          
FitnessLimit: [ scalar           | {-Inf} ]:;Set value or a typical known fitness value

        
 StallGenLimit: [ positive scalar  | {50} ]: If Solution is not changing for certain number of generation stop the algorithm
        
StallTimeLimit: [ positive scalar  | {20} ]: If Solution is not changing for certain time, stop the algorithm
    
 InitialPopulation: [ matrix           | {[]} ]:You can specify initial feasible solution if already known.

  InitialScores: [ column vector    | {[]} ]: Known function values

 CreationFcn: [ function_handle  | {@gacreationuniform} ]; random function for creating initial population

 FitnessScalingFcn: [ function_handle  | @fitscalingshiftlinear  | @fitscalingprop  | :testing the fitness
                             @fitscalingtop   | {@fitscalingrank} ]
SelectionFcn: [ function_handle  | @selectionremainder    | @selectionrandom |
                            @selectionroulette | @selectiontournament   | {@selectionstochunif} ]
          
CrossoverFcn: [ function_handle  | @crossoverheuristic  | @crossoverintermediate |
@crossoversinglepoint | @crossovertwopoint | {@crossoverscattered} ]:Different crossovers
          
MutationFcn: [ function_handle  | @mutationuniform | {@mutationgaussian} ]:  Mutation function
            
HybridFcn: [ @fminsearch | @patternsearch | @fminunc | {[]} ]: After GA run another local minimizing function is run

Display: [ off | iter | diagnose | {final} ]: the results are displayed
            
OutputFcns: [ function_handle  | @gaoutputgen | {[]} ]:the output producing function
            
 PlotFcns: [ function_handle  | @gaplotbestf | @gaplotbestindiv | @gaplotdistance | @gaplotexpectation | @gaplotgeneology | @gaplotselection | @gaplotrange | @gaplotscorediversity  | @gaplotscores | @gaplotstopping  | {[]} ]: Choose the graphs you want
          
PlotInterval: [ positive scalar  | {1} ]: The plotting interval

            
Vectorized: [ 'on'  | {'off'} ]

Program in command mode.


This file  and the function file should be in the same folder which should be default.

the options can be set by the following commands

% setting the genetic algorithm parameters.
options = gaoptimset;
options = gaoptimset('PopulationSize', 50,'Generations', 500,'TimeLimit', 200,'StallTimeLimit',100,
'PlotFcns',  {@gaplotbestf,@gaplotbestindiv});
  [x ff]=ga(@ex1,2,options)

.