Repository navigation
Expand file tree
/
Copy pathset_initial_pop.m
More file actions
38 lines (35 loc) · 1.92 KB
/
Copy pathset_initial_pop.m
File metadata and controls
38 lines (35 loc) · 1.92 KB
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
#############################################################
# Estimation of Distribution Algorithm (EDA) #
# (Octave implementation) #
# #
# Filename: set_initial_pop.m #
# #
# Description: #
# This function sets an initial random population that #
# consists in 'row_num' vectors, generated with the #
# function 'randi'; They have 'cols_num' random values, #
# between 1 and 'max_ascii_num' #
# #
# Input variables #
# - row_num | The number of solutions of the #
# | initial population. #
# #
# - col_num | The number of elements of each #
# | solution. #
# #
# Output variables #
# - initial_pop | A random initial population. #
# #
# Internal variables #
# - max_ascii_num | The maximum character (in decimal ascii #
# | code), that could be represented. #
# #
# Author: Nico Formoso (nicolasformoso@gmail.com) #
#############################################################
function [ initial_pop ] = set_initial_pop(row_num, cols_num)
max_ascii_num = 165;
initial_pop = zeros(row_num,cols_num);
for i = 1:row_num
initial_pop(i,:) = randi(max_ascii_num, 1, cols_num);
endfor
endfunction