Documentation of demomop

Global Index (all files) (short | long) | Local contents | Local Index (files in subdir) (short | long)

Function Synopsis

[xnew, GeaOpt] = demomop(OptVariant, FunVariant)

Help text

 DEMO for testing multiobjective optimization

 This function provides an example for using the GEATbx for 
 multiobjective optimization.
 The options are defined by the structure method providing a 
 higher flexibility.
 
 Syntax:  demomop(OptVariant, FunVariant)

 Input parameter:
    OptVariant - Scalar indicating the used optimization method
                  1: globally oriented optimization with multiple subpops
                  2: globally oriented optimization with 1 subpop (panmictic)
                  3: locally oriented optimization
                  if omitted or NaN, a menu will be shown with the 
                  possible options

    FunVariant - String indicating the used MO-function
                  if omitted or NaN, a menu will be shown with the 
                  possible options

 Output parameter:
    no output parameter

 See also: geaoptset, geamain2, mobj*

Cross-Reference Information

This function calls

Listing of function demomop



% Author:   Hartmut Pohlheim
% History:  18.05.1999  file created
%           05.05.2002  options reworked
%                       inclusion of further MO functions
%                       selection of objfun from menu


function [xnew, GeaOpt] = demomop(OptVariant, FunVariant)

   % Check input
   if nargin < 1, OptVariant = []; end
   if isnan(OptVariant), OptVariant = []; end

   if nargin < 2, FunVariant = []; end
   if isnan(FunVariant), FunVariant = ''; end

   % Check value of OptVariant
   if isempty(OptVariant), OptVariant = 1; end
   if ~(any(OptVariant == (1:3))), OptVariant = 1; end
   % Get parameters for different optimization variants
   if OptVariant == 1,
      % Get default parameters for real variables (globally oriented)
      GeaOpt = tbx3real;    % mutation, recombination, variable format
      % Define special parameters
      GeaOpt = geaoptset( GeaOpt ...
                         , 'NumberSubpopulation',        5 ...           % Number of subpopulation
                         , 'NumberIndividuals',         [50, 30, 30, 40, 50] ...     % Number of individuals per subpopulation
                        );
   elseif OptVariant == 2,
      % Get default parameters for real variables (globally oriented)
      GeaOpt = tbx3real;    % mutation, recombination, variable format
      % Define special parameters
      GeaOpt = geaoptset( GeaOpt ...
                         , 'NumberSubpopulation',        1 ...        % Number of subpopulation
                         , 'NumberIndividuals',         [200] ...     % Number of individuals per subpopulation
                         , 'Mutation.Range',            [1e-2] ...    % mutation range
                         , 'Mutation.Precision',        [24] ...      % mutation precision
                        );
   elseif OptVariant == 3,
      % Get default parameters for real variables (locally oriented)
      GeaOpt = tbx3es1;    % mutation, recombination, variable format, selection
   end


   % Define objective function to use and the respective parameters
   %#function mobjfonseca1 mobjfonseca2
   % name of objfun, number of variables, number of objectives, goals
   ObjFunStrings = { 'mobjfonseca1',   2,  NaN,  [.97, .7]   ...
                   ; 'mobjfonseca2',   3,  NaN,  [.23, .92]  ...
                   ; 'mobjsoland',     2,    2,  [Inf, 0.01] ...
                   };

   % Check for input parameter defining number of function to use, otherwise present menu
   if isempty(FunVariant),
      ObjFunNames = {};
      % Menu text of function names can be created automatically (the objective functions know their descriptive name)
      for iname = 1:size(ObjFunStrings,1),
         CurObjFunName = geaobjpara(ObjFunStrings{iname,1}, [2, ObjFunStrings{iname,2}]);
         if isnan(ObjFunStrings{iname,4}), CurGoals = ''; 
         else CurGoals = sprintf(',   goals: %s', prprintf(ObjFunStrings{iname,4})); end
         ObjFunNames = [ObjFunNames; {sprintf(' %s   (%s, %3d var%s)', CurObjFunName, ...
                                               ObjFunStrings{iname,1}, ObjFunStrings{iname,2}, CurGoals)}];
      end
      HeaderFunString = 'Please select an objective function'
      FunVariant = menutext(HeaderFunString, ObjFunNames);
   end;
   objfun = ObjFunStrings{FunVariant,1};

   % Get variable boundaries from objective function
   VLUB = geaobjpara(objfun, [1 ObjFunStrings{FunVariant,2}]);
   
   % Switch on the multi-objective ranking and the plotmop visualization (para is > 10)
   GeaOpt = geaoptset( GeaOpt , 'Selection.RankingMultiobj', 15 ...
                              , 'System.ObjFunGoals',  ObjFunStrings{FunVariant,4} ...
                     );

   % Define the output options, path and name of result data files
   GeaOpt = geaoptset( GeaOpt, tbx3output ...
                      , 'Output.TextInterval',        5 ...           % Text output every xx generations
                      , 'Output.GrafikInterval',      10 ...          % Grafic results every 10 generations
                      ... % , 'Output.GrafikMethod',        111    ...      % Grafic method to use
                      ... % , 'Output.GrafikStyle',         614144 ...      % Grafic styles for specified methods
                     );

% termination criteria with their options
   GeaOpt = geaoptset( GeaOpt ...
                      , 'Termination.Method',         [1 ] ...   % Termination method: use max gen and max time
                      , 'Termination.MaxGenerations', 300   ...   % Terminate after xx generations
                     );

% Call main function for optimization
   PopInit = [];
   [xnew, GeaOpt] = geamain2(objfun, GeaOpt, VLUB, PopInit);


% End of script
GEATbx: Main page  Tutorial  Algorithms  M-functions  Parameter/Options  Example functions  www.geatbx.com 

This document is part of version 3.7 of the GEATbx: Genetic and Evolutionary Algorithm Toolbox for use with Matlab - www.geatbx.com.
The Genetic and Evolutionary Algorithm Toolbox is not public domain.
© 1994-2005 Hartmut Pohlheim, All Rights Reserved, (support@geatbx.com).