Displaying 3 results from an estimated 3 matches for "create_bin_chromosome".
2009 Feb 18
2
how to randomly eliminate half the entries in a vector?
...matter anything that looks odd.
Below my partial solution .. the HUX function is what I am trying
to finish if someone can point me in the right direction.
Thanks
Esmail
------
rm(list=ls())
####################################################
# create a binary vector of size "len"
#
create_bin_Chromosome <- function(len)
{
sample(0:1, len, replace=T)
}
####################################################
# HUX - half uniform crossover
#
# 1. determines the locations of where the two strings
# differ (easy xor)
#
# 2. randomly selects half of those positions
#
# 3. exchanges (flips) the bi...
2010 Mar 11
2
Comparing matrices
...Esmail
ps: Am I correct that if I do the assignment
pop2 = pop
I create a totally separate instance/(deep)copy of the
data? I tried a few tests that seem to confirm this, but I'd
rather be sure.
------- code ------------
# create a binary vector of size "len"
create_bin_Chromosome <- function(len)
{
sample(0:1, len, replace=T)
}
# create popsize members, each of length len
create_pop_2 <- function(popsize, len)
{
datasize=len*popsize
npop <- matrix(0, popsize, len, byrow=T)
for(i in 1:popsize)
npop[i,] = create_bin_Chromosome(len)
npop
}
PO...
2009 Apr 26
3
3 questions regarding matrix copy/shuffle/compares
...'they are equal'
else
print 'they are not equal'
Is there an equivalent R code segment?
Thanks,
Esmail
--------------- the code called above -------------
####################################################
# create a binary vector of size "len"
#
create_bin_Chromosome <- function(len)
{
sample(0:1, len, replace=T)
}
############## create_population ###################
# create population of chromosomes of length len
# the matrix contains twice as much space as popsize
#
create_pop_2 <- function(popsize, len)
{
datasize=len*popsize
print(datasiz...