⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sga_fitness_mo_function.m

📁 一个matlab环境下编制的使用很方便的多目标程序
💻 M
字号:
function [ MO_fitness_array ] = SGA_FITNESS_MO_function( x )

% /*M-FILE FUNCTION SGA_FITNESS_MO_function MMM SGALAB */ %
% /*==================================================================================================
%  Simple Genetic Algorithm Laboratory Toolbox for Matlab 7.x
%
%  Copyright 2007 The SxLAB Family - Yi Chen - chenyi2005@gmail.com
% ====================================================================================================
%
%File description:
%
%       SGA_FITNESS_MO_function Function is an example fitness function
%       Of Simple Genetic Algorithm Program (Version 1.0.0.3 )
%       Support multi-dimesion parameters
%
%Input:
%          User define      -- in the format ( x1, x2, x3,... )
%Output:
%          MO_fitness_array -- is the fitness value
% 
%Appendix comments:
% 
% pay attention to the format of this function
% 
%Usage:
% [ MO_fitness_array ] = SGA_FITNESS_MO_function( x1 , x2, x3 )
%                or
% [ MO_fitness_array ] = SGA_FITNESS_MO_function( X , A )
%===================================================================================================
%  See Also:        SGA_FITNESS_function
%
%===================================================================================================
%
%===================================================================================================
%Revision -
%Date        Name    Description of Change email                 Location
%20-Dec-2006 Chen Yi update 1003           chenyi2005@gmail.com  Glasgow
%HISTORY$
%==================================================================================================*/

%SGA_FITNESS_MO_function begin

%Pay Attention: SGALAB is to get MAX fitness value,

% check input number
 
if( nargin == 0 )
    error ('SGA_FITNESS_MO_function() Error: Input Parameters...');
end 

  input_exist = exist('INPUT_MATRIX_A.txt');
  
if( nargin == 2 &...
    input_exist == 2 &...
    size( x , 1 ) ~= 1 )
    % fitness need to be in format of AX = fitness
    % A - m*n
    % X - n*1
     [ AMM , ANN ] = size( Matrix_A );
    %check matrix size
      [ XNN , XONE ] = size( x );
       
            
      if( ANN  == XNN &...
          XONE == 1 & ...
          input_exist == 2 )% check exist() 2 - exist in current folder
      
        MO_fitness_array = A*X;

    else
        error ('SGA_FITNESS_MO_function() Error: Input Matrix size ...');
    end

else
    
    %User Define - Fitness Function Number
    Fitness_Num = 2 ;

    %initialization
    MO_fitness_array = NaN*zeros( 1,Fitness_Num );

    %User Define - fitness function 1 :
    fitness1 = x^2;
    %
    %User Define - fitness function 1 :
    fitness2 = (x-2)^2;

    %set output
    MO_fitness_array = [ ...
        fitness1...
        fitness2 ];

end


%check output
if ( isnan( MO_fitness_array ) ~= 0 )
    error('SGA_FITNESS_MO_function() Output error ')
end

%SGA_FITNESS_MO_function end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -