public static int ParetoRel(ChromosomeDE first, ChromosomeDE second) { bool firstCooler = true;; bool secondCooler = true; foreach (var critName in first.Crits.Keys) { if (first.Crits[critName].Value == second.Crits[critName].Value) { continue; } var kritBattle = first.Crits[critName].Info.Extremum == CritExtremum.fe_max ? first.Crits[critName].Value > second.Crits[critName].Value : first.Crits[critName].Value < second.Crits[critName].Value; firstCooler &= kritBattle; secondCooler &= !kritBattle; if ((!firstCooler) && (!secondCooler)) { break; } } return (firstCooler && secondCooler ? 0: firstCooler ? 1 : secondCooler ? -1 : 0); }
public void AddCrit(ChromosomeDE critsFrom, bool copyValues = false) { foreach (var ci in critsFrom.Crits.Values) { AddCrit(ci.Info, copyValues ? ci.Value : null); } }
public static void TryGetInPareto(IList <ChromosomeDE> pareto, ChromosomeDE candidate) { for (int i = pareto.Count - 1; i >= 0; i--) { var pr = pareto[i]; switch (ChromosomeDE.ParetoRel(pr, candidate)) { case 1: { return; } case -1: { pareto.RemoveAt(i); } break; default: break; } } pareto.Add(candidate); }
public PopulationDE(int minSize, int maxSize, ChromosomeDE adamChromosome) : base(minSize, maxSize, adamChromosome) { }