public override SAFuzzySystem TuneUpFuzzySystem(SAFuzzySystem Approx, ILearnAlgorithmConf conf) { SAFuzzySystem result = Approx; BeeParamsConf Config = conf as BeeParamsConf; Init(Config); theFuzzySystem = result; if (result.RulesDatabaseSet.Count < 1) { throw (new Exception("Что то не так с базой правил")); } theHive = new HiveParams(this, result.RulesDatabaseSet[0]); // HiveParams theHive = new ParallelHiveParams(this, result.RulesDatabaseSet[0]); // HiveParams theHive = new HiveParallelParams2(this, result.RulesDatabaseSet[0]); theBest = new BeeParams(result.RulesDatabaseSet[0], this); double temperature = initTemp; for (int r = 0; r < iterration; r++) { temperature = oneIterate(temperature); GC.Collect(); } theBest = lastStep(theBest); Approx.RulesDatabaseSet[0] = theBest.PositionOfBee; Approx.RulesDatabaseSet[0].TermsSet.Trim(); return(Approx); }
public static List <BeeParams> OutLookerFly(BeeParams Best, List <BeeParams> Source, Random rand, BeeParamsAlgorithm parrent) { List <BeeParams> Result = new List <BeeParams>(); for (int i = 0; i < Source.Count(); i++) { Result.Add(new OutLookersBeeParams(Source[i].PositionOfBee, Best.PositionOfBee, parrent, rand)); } return(Result); }
public new static List <BeeParams> WorkersFly(BeeParams Best, List <BeeParams> Source, Random rand, BeeParamsAlgorithm parrent) { List <BeeParams> Result = new List <BeeParams>(); Parallel.For(0, Source.Count, (int i) => { Result.Add(new WorkerParams(Source[i].PositionOfBee, Best.PositionOfBee, parrent, rand)); }); return(Result); }
public double oneIterate(double temperature) { theHive.flyScouts(countScouts, rand, theBest.PositionOfBee); double newtemperature = theHive.LimitScoutBeeSolution(temperature, coefTemp, rand); theBest = theHive.findBestinHive(); theHive.flyWorkers(theBest, rand); theHive.flyOutLookers(theBest, rand); countScouts = theHive.makeNewPopulation(TypeSelection, hiveSize, persentScouts, rand, border1, border2, border3, repeat1, repeat2, repeat3); theBest = theHive.findBestinHive(); return(newtemperature); }
public SAFuzzySystem TuneUpFuzzySystem(SingletonHybride Ocean, SAFuzzySystem Approximate, ILearnAlgorithmConf conf) { SAFuzzySystem result = Approximate; BeeParamsConf Config = conf as BeeParamsConf; Init(Config); theFuzzySystem = result; if (result.RulesDatabaseSet.Count < 1) { throw (new Exception("Что то не так с базой правил")); } theHive = new HiveParams(this, result.RulesDatabaseSet[0]); // HiveParams theHive = new ParallelHiveParams(this, result.RulesDatabaseSet[0]); // HiveParams theHive = new HiveParallelParams2(this, result.RulesDatabaseSet[0]); theBest = new BeeParams(result.RulesDatabaseSet[0], this); double temperature = initTemp; for (int r = 0; r < iterration; r++) { temperature = oneIterate(temperature); int CountSend = theHive.HostArchive.Count / 2; List <KnowlegeBaseSARules> toStore = new List <KnowlegeBaseSARules>(); for (int i = 0; i < CountSend; i++) { toStore.Add(theHive.HostArchive[i].PositionOfBee); } Ocean.Store(toStore, this.ToString()); int toGet = theHive.HostArchive.Count - CountSend; List <KnowlegeBaseSARules> Getted = Ocean.Get(toGet, FuzzyAbstract.Hybride.FuzzyHybrideBase.goodness.best, FuzzyAbstract.Hybride.FuzzyHybrideBase.islandStrategy.All); toGet = Getted.Count < toGet ? Getted.Count : toGet; for (int i = 0; i < toGet; i++) { theHive.HostArchive[i + CountSend].PositionOfBee = Getted[i]; } GC.Collect(); } theBest = lastStep(theBest); Approximate.RulesDatabaseSet[0] = theBest.PositionOfBee; return(result); }
protected BeeParams lastStep(BeeParams theBest) { Adaptive_LSM tryOpt = new Adaptive_LSM(); double tempgood = theBest.getGoodsImproove(); KnowlegeBaseSARules tempPositionofBee = theBest.PositionOfBee; SAFuzzySystem ToOpintNS = getCurrentNs(); KnowlegeBaseSARules zeroSolution = ToOpintNS.RulesDatabaseSet[0]; ToOpintNS.RulesDatabaseSet[0] = theBest.PositionOfBee; tryOpt.TuneUpFuzzySystem(ToOpintNS, new NullConfForAll()); theBest.PositionOfBee = ToOpintNS.RulesDatabaseSet[0]; double newgood = theBest.getGoodsImproove(); if (newgood > tempgood) { theBest.PositionOfBee = tempPositionofBee; } return(theBest); }
public override void flyWorkers(BeeParams best, Random rand) { Thread[] threads = new Thread[2]; threads[0] = new Thread(() => { theWorkers = ParralelWorkerParams.WorkersFly(best, hostArchive, rand, theParrent); }); threads[1] = new Thread(() => { theOutlookers = ParallelOultLookersBeeParams.OutLookerFly(best, hostArchive, rand, theParrent); }); try { threads[0].Start(); threads[1].Start(); } catch (Exception) { } while (threads[0].IsAlive || threads[1].IsAlive) { // Thread.Sleep(10); } }
public override void flyOutLookers(BeeParams best, Random rand) { }
public virtual void flyOutLookers(BeeParams best, Random rand) { theOutlookers = OutLookersBeeParams.OutLookerFly(best, hostArchive, rand, theParrent); }
public virtual void flyWorkers(BeeParams best, Random rand) { theWorkers = WorkerParams.WorkersFly(best, hostArchive, rand, theParrent); }
public override void flyOutLookers(BeeParams best, Random rand) { theOutlookers = ParallelOultLookersBeeParams.OutLookerFly(best, hostArchive, rand, theParrent); }
public override void flyWorkers(BeeParams best, Random rand) { theWorkers = ParralelWorkerParams.WorkersFly(best, hostArchive, rand, theParrent); }