Exemple #1
0
        public void Create(Configuration <FoodType> config)
        {
            this.Config = config;
            int noOfBees = config.populationSize;

            if (noOfBees <= 1)
            {
                throw new Exception("You dey Craze? Dem tell you say one (1) bee na Swarm?");
            }
            if (Bees.Count == 0)
            {
                for (int index = 1; index <= noOfBees; index++)
                {
                    BeeTypeClass _type = default(BeeTypeClass);
                    if (index < (noOfBees / 2))
                    {
                        _type = BeeTypeClass.Employed;
                    }
                    else
                    {
                        _type = BeeTypeClass.Onlooker;
                    }
                    IBee <FoodType> bee = (IBee <FoodType>)Activator.CreateInstance <IBee>();
                    bee.Init(config.mutationFunction, config.objectiveFunction, _type, index - 1, _failureLimit, config.movement);
                    Bees.Add(bee);
                }
            }
            this.Start();
        }
Exemple #2
0
 public BeeLahc(Func <FoodType, FoodType> mFunc, Func <FoodType, double> fFunc, BeeTypeClass _type,
                int ID = 0, int _failureLimit = 20, int _tableSize = 50, Search.Direction movement = Search.Direction.Optimization)
 {
     if ((movement == Search.Direction.Divergence))
     {
         this.Fitness   = double.MinValue;
         defaultFitness = double.MinValue;
     }
     else if (movement == Search.Direction.Optimization)
     {
         this.Fitness   = double.MaxValue;
         defaultFitness = double.MaxValue;
     }
     if (mFunc == null | fFunc == null)
     {
         throw new Exception(string.Format("Ogbeni, na Bee #{0} be this. How i wan take mutate na?", ID));
     }
     this._nonImprovementLimit = _failureLimit;
     this._mutationFunc        = mFunc;
     this._fitnessFunc         = fFunc;
     this.Type     = _type;
     this.lahc     = new LAHC(_tableSize, this.Fitness, movement);
     this.Movement = movement;
 }
Exemple #3
0
 public Bee(Func <FoodType, FoodType> mFunc, Func <FoodType, double> fFunc, BeeTypeClass _type, int ID = 0, int _failureLimit = 20, Search.Direction movement = Search.Direction.Optimization)
 {
     this.Init(mFunc, fFunc, _type, ID, _failureLimit, movement);
 }