Home > Mateda2.0 > seeding > RandomInit.m

# RandomInit

## PURPOSE

[NewPop] = RandomInit(NumbVar,PopSize,Card,sampling_params)

## SYNOPSIS

function [NewPop] = RandomInit(NumbVar,PopSize,Card,sampling_params)

## DESCRIPTION

     [NewPop] = RandomInit(NumbVar,PopSize,Card,sampling_params)
     RandomInit:         Random Initialization of the population
     INPUTS
     NumbVar: Number of variables
     Card: For discrete variables:    Vector with the dimension of all the variables.
           For continuous variables:  Matrix of two vectors with the minimum and maximum real values
                                      each variable can take
     sampling_params{1}(1) = N: Number of generated individuals
     OUTPUTS
     NewPop: Sampled individuals

     Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

## SOURCE CODE

    0001 function [NewPop] = RandomInit(NumbVar,PopSize,Card,sampling_params)
    0002 % [NewPop] = RandomInit(NumbVar,PopSize,Card,sampling_params)
    0003 % RandomInit:         Random Initialization of the population
    0004 % INPUTS
    0005 % NumbVar: Number of variables
    0006 % Card: For discrete variables:    Vector with the dimension of all the variables.
    0007 %       For continuous variables:  Matrix of two vectors with the minimum and maximum real values
    0008 %                                  each variable can take
    0009 % sampling_params{1}(1) = N: Number of generated individuals
    0010 % OUTPUTS
    0011 % NewPop: Sampled individuals
    0012 %
    0013 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
    0014
    0015 if size(Card,1)==1  % Discrete case
    0016   NewPop = fix(repmat(Card,PopSize,1).*[rand(PopSize,NumbVar)]);
    0017 else
    0018   auxvector = Card(2,:) - Card(1,:);
    0019   NewPop = repmat(Card(1,:),PopSize,1) + (repmat(auxvector,PopSize,1).*[rand(PopSize,NumbVar)]);
    0020 end
    0021