-
Notifications
You must be signed in to change notification settings - Fork 1
/
initialize_variables_s.m
85 lines (76 loc) · 3.7 KB
/
initialize_variables_s.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
function f = initialize_variables_s(N, M, V)
%% function f = initialize_variables(N, M, V, min_tange, max_range)
% This function initializes the chromosomes. Each chromosome has the
% following at this stage
% * set of decision variables
% * objective function values
%
% where,
% N - Population size
% M - Number of objective functions
% V - Number of decision variables
% min_range - A vector of decimal values which indicate the minimum value
% for each decision variable.
% max_range - Vector of maximum possible values for decision variables.
% Copyright (c) 2009, Aravind Seshadri
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are
% met:
%
% * Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
% * Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in
% the documentation and/or other materials provided with the distribution
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
% POSSIBILITY OF SUCH DAMAGE.
% min = min_range;
% max = max_range;
% K is the total number of array elements. For ease of computation decision
% variables and objective functions are concatenated to form a single
% array. For crossover and mutation only the decision variables are used
% while for selection, only the objective variable are utilized.
K = M + V;
%% Initialize each chromosome
% For each chromosome perform the following (N is the population size)
% for i = 1 : N
% % Initialize the decision variables based on the minimum and maximum
% % possible values. V is the number of decision variable. A random
% % number is picked between the minimum and maximum possible values for
% % the each decision variable.
% for j = 1 : V
% f(i,j) = min(j) + (max(j) - min(j))*rand(1);
% end
% % For ease of computation and handling data the chromosome also has the
% % vlaue of the objective function concatenated at the end. The elements
% % V + 1 to K has the objective function valued.
% % The function evaluate_objective takes one chromosome at a time,
% % infact only the decision variables are passed to the function along
% % with information about the number of objective functions which are
% % processed and returns the value for the objective functions. These
% % values are now stored at the end of the chromosome itself.
% f(i,V + 1: K) = evaluate_objective(f(i,:), M, V);
% end
f = randi([0,1], N, V); % f ΪÖÖȺ,V Ϊ³¤¶È
% zeroIdx = ~any(f,2);
% while(sum(zeroIdx))
% f(zeroIdx, :) = randi([0,1], sum(zeroIdx), V);
% zeroIdx = ~any(f,2);
% end
% THRESHOLDSET = (bin2dec(num2str(f)))./(2^V-1);
for i = 1 : N
f(i,V + 1: K) = evaluate_objective_s(M, f(i,1:V));
end
end