예제 #1
0
 public virtual void Final()
 {
     theFuzzySystem.RulesDatabaseSet[0] = Best;
     baseLine   = theFuzzySystem.ErrorLearnSamples(theFuzzySystem.RulesDatabaseSet[0]);
     theScouts  = null;
     theWorkers = null;
     theScout   = null;
     theWorker  = null;
     GC.Collect();
 }
예제 #2
0
        public virtual void oneIterate(FS result)
        {
            theScouts.Clear();
            theWorkers.Clear();
            baseLine  = result.ErrorLearnSamples(result.RulesDatabaseSet[0]);
            Best      = result.RulesDatabaseSet[0];
            theScout  = null;
            theWorker = null;
            for (int s = 0; s < countScouts; s++)
            {
                double goodsLine = -1;
                int    ztryes    = 0;
                while ((goodsLine <= 0) && (ztryes < 100))
                {
                    theScout = new Scout(Best, theFuzzySystem);
                    theScout.generateNewRule(typeTerm, rand);
                    goodsLine = theScout.getGoodsImproove(baseLine);
                }
                theScouts.Add(theScout);
            }
            BeeComparer toBeeSort = new BeeComparer();

            theScouts.Sort(toBeeSort);
            KnowlegeBaseRules ScoutBest = theScouts[theScouts.Count - 1].PositionOfBee;
            int ScoutBestNumRule        = theScouts[theScouts.Count - 1].NumOFRule;

            for (int w = 0; w < countWorkers; w++)
            {
                theWorker = new Worker(ScoutBest, theFuzzySystem);
                theWorkers.Add(theWorker);
                theWorkers[theWorkers.Count - 1].WorkerFly(ScoutBestNumRule, rand);
                theWorkers[theWorkers.Count - 1].getGoodsImproove(baseLine);
            }

            theWorkers.Sort(toBeeSort);

            if (theScouts[theScouts.Count - 1].Goods > theWorkers[theWorkers.Count - 1].Goods)
            {
                Best = theScouts[theScouts.Count - 1].PositionOfBee;
            }
            else
            {
                Best = theWorkers[theWorkers.Count - 1].PositionOfBee;
            }
            theFuzzySystem.RulesDatabaseSet[0] = Best;
        }