/// <summary>
        /// Generate a selection of randomly generated individuals.
        /// low range 0-0.5, high range 0.5-1.0.
        /// </summary>
        public void InitiatePopulation()
        {
            Random random = new Random();

            for (int i = 0; i < populationSize; i++)
            {
                population.Add(new IndividualFP());

                List <RuleFP> rulesToAdd = new List <RuleFP>();

                for (int r = 0; r < numberOfRules; r++)
                {
                    var currentRule = new RuleFP();
                    for (int c = 0; c < boundryLength; c++)
                    {
                        RuleFPBoundry conditionToAdd = null;
                        var           low            = random.NextDouble() / 2;       // 0 - 0.5
                        var           high           = 0.5 + random.NextDouble() / 2; // 0.5 - 1.0

                        conditionToAdd = new RuleFPBoundry((float)low, (float)high);

                        currentRule.condBoundry.Add(conditionToAdd);
                    }

                    // Output (0,1)
                    currentRule.output = random.Next(2);
                    rulesToAdd.Add(currentRule);
                }

                population[i].Rulebase = rulesToAdd;
            }
        }
Exemple #2
0
 public RuleFPBoundry(RuleFPBoundry clonedBoundry)
 {
     this.high = clonedBoundry.high;
     this.low  = clonedBoundry.low;
 }