initialize_variables.m

来自「NSGA-2 一种非常强大的多目标遗传算法,本人已经把它调通.」· M 代码 · 共 36 行

M
36
字号
function f = initialize_variables(N,problem,inp_para_definition)


% function f = initialize_variables(N,problem)
% N - Population size
% problem - takes integer values 1 and 2 where,
%           '1' for MOP1
%           '2' for MOP2
%
% This function initializes the population with N individuals and each
% individual having M decision variables based on the selected problem. 
% M = 6 for problem MOP1 and M = 12 for problem MOP2. The objective space
% for MOP1 is 2 dimensional while for MOP2 is 3 dimensional.

% Both the MOP's has 0 to 1 as its range for all the decision variables. 
min = 0;
max = 1;
switch problem
    case 1
        M = 6;
        K = 8;    % k=决策变量(6)+目标变量(2)=8
    case 2
        M = 12;
        K = 15;
    case 3     % case 1和case 2 用来对整个算法进行常规验证,作为调试之用;case 3 为本工程所需;
         M = 8;  %(input parameters  个数)
         K = 10;
end
for i = 1 : N
    % Initialize the decision variables
    for j = 1 : M
        f(i,j) = input_parameter_produce(j,inp_para_definition); % i.e f(i,j) = min + (max - min)*rand(1);
    end
    % Evaluate the objective function
    f(i,M + 1: K) = evaluate_objective(f(i,:),problem);
end

⌨️ 快捷键说明

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