public Population(int size, IFitnessFunction fitnessFunction, IReproduction reproductionFunction, INodeMutator mutator, ISelection selection)
        {
            this.populationSize = size;
            this.fitnessFunction = fitnessFunction;
            this.reproductionFunction = reproductionFunction;
            this.mutator = mutator;
            this.selector = selection;

            this.fitnessFunction.Initialise();

            // Create the initial population
            for (int i = 0; i < size; i++)
            {
                try
                {
                    NodeContext zeroContext = new NodeContext();
                    zeroContext.AvailableCollections = fitnessFunction.GetCollections();
                    zeroContext.AvailableInputs = fitnessFunction.GetInputs();

                    INode candidateNode = NodeFactory.GenerateNode(zeroContext);

                    // Make sure we have a decent candidate (i.e. not too large)
                    double fitness = this.fitnessFunction.CalculateFitness(candidateNode);
                    if (fitness == Double.MaxValue) continue;

                    this.population.Add(NodeFactory.GenerateNode(zeroContext));
                }
                catch (StackOverflowException)
                {
                }
            }
        }
		//---------------------------------------------------------------------

		/// <summary>
		/// Initializes the instance and its associated site variables.
		/// </summary>
		protected void Initialize(int       timestep,
		                          double[,] establishProbabilities)
		{
			this.timestep = timestep;
			this.nextTimeToRun = timestep;

			SiteVars.Initialize();
			defaultReproduction = new Seeding(WardSeedDispersal.Algorithm);
			SiteVars.Reproduction.ActiveSiteValues = defaultReproduction;
			Reproduction.SetEstablishProbabilities(establishProbabilities);
		}
        public TwoIslandsPopulation(int size, IFitnessFunction fitnessFunction, IReproduction reproductionFunction, INodeMutator mutator, ISelection selection)
        {
            this.populationSize = size;
            this.fitnessFunction = fitnessFunction;
            this.reproductionFunction = reproductionFunction;
            this.mutator = mutator;
            this.selector = selection;

            this.fitnessFunction.Initialise();

            // The main population needs initializing
            this.IntialisePopulation(this.mainPopulation);

            this.IntialisePopulation(this.secondaryPopulation);
        }