The present results differ from the previous results in giving a smaller x
1
and
larger x
2
. Fitnesses calculated at the three estimates, given in the above order, are
2.388, 2.388, and 2.387. Based on the evaluated fitnesses, the first two approaches
are equivalent and the best, followed closely by the numerical approach.
MATLAB CODE: See Section 2.18.30.
2.14.5.2 The Brute force approach
We now consider the “Brute force” approach. From the initial plotting we know
that the optimum occurs within limits of, say, x
1,min
to x
1,max
and x
2,min
to x
2,max
.
Suppose we wish to obtain an estimate that is 0.005: we can try all values within
the foregoing ranges that differ by 0.005. The number of combinations we will
need to try is roughly
x
1;max
x
1;min
0:005
x
2;max
x
2;min
0:005
. Alternatively, we could
simply try a large number of values within the specified range and then, if
necessary, use the resulting output to refine our range. This is illustrated in the
code below where I generate 10,000 combinations. Rather than generate a matrix
to hold W the code below uses the R function expand.grid to generate a two
column matrix called d with the appropriate combinations. In R the routine order
is then used to find the row with the highest fitness.
R CODE:
rm(list¼ls()) # remove all objects from memory
FITNESS <- function(x) # Function to calculate fitness
{This function is the same as that used for plotting, except that W
not –W is returned
return(W) }
# MAIN PROGRAM
# Create vectors to produce an n by n matrix of combinations
n <- 100 # Number of rows and columns
x <- seq(from¼0, to¼5, length¼n)
y <-x
d <- expand.grid(x,y) # Create 2xn
2
matrix of all combinations
W <- apply(d,1,FITNESS) # Use apply to calculate fitnesses
# Now find position of row that has the highest fitness
# Row is stored in first row of Best, Best[1]
Best <- order(W, na.last¼TRUE, decreasing¼TRUE)
x1 <- d[Best[1],1] # Best x1
x2 <- d[Best[1],2] # Best x2
# Calculate x3
R <- 400; N <- 100 # Parameter values
x3 <- (R-N*(x1þx2))/N # x3
print(c(x1,x2,x3,W[Best[1]])) # Propagule sizes and W
OUTPUT:
[1] 2.77777778 1.21212121 0.01010101 2.38771586
FISHERIAN OPTIMALITY MODELS 129