예제 #1
0
 public Individual FormRandomIndividual()
 {
     AddMoreInformation();
     Random randomCount = new Random();
         Individual individual = new Individual(numberOfFurniture, maxCountOfOneKindOfFurniture, additionalInformationAboutIndividual,
             randomCount, maxVolume, maxCost);
     
     return individual;
 }
예제 #2
0
 public Population(int _countOfPopulation, int _numberOfFurniture, int _maxCountOfOneKindOfFurniture,double _maxVolume,
     double _maxCost,int _maxNonImprovement,int _maxNonImprovementinTheBestIndividual)
 {
     theBestIndividual = FormRandomIndividual();
     nonImprovementinTheBestIndividual = 0;
     countOfPopulation = _countOfPopulation;
     numberOfFurniture = _numberOfFurniture;
     maxCountOfOneKindOfFurniture = _maxCountOfOneKindOfFurniture;
     maxVolume = _maxVolume;
     maxCost = _maxCost;
     maxNonImprovement = _maxNonImprovement;
     commonNonDominatedOld = new List<Individual>();
     maxNonImprovementinTheBestIndividual = _maxNonImprovementinTheBestIndividual;
 }
예제 #3
0
 private static List<Individual> steady(Individual a, Individual b)
 {
     List<Individual> lis = new List<Individual>();
     Random rand = new Random();
     int[] c1 = a.getIndividual().ToArray();
     int[] c2 = b.getIndividual().ToArray();
     for (int i = 0; i < a.getIndividual().Count; i++)
     {
         int point = rand.Next(0, 2);
         if (point == 0) { int temp = c1[i]; c1[i] = c2[i]; c2[i] = temp; }
     }
     a.setIndividual(c1.ToList());
     b.setIndividual(c2.ToList());
     lis.Add(a);
     lis.Add(b);
     return lis;
 }
예제 #4
0
 private static Individual simple(Individual individual)
 {
     int[] a = individual.getIndividual().ToArray();
     if (a.Length > 1)
     {
         int[] c = new int[a.Length];
         Random rand = new Random();
         int point = rand.Next(1, a.Length - 1);
         Array.Copy(a, c, a.Length);
         int ct = c[point];
         c[point] = c[point - 1];
         c[point - 1] = ct;
         individual.setIndividual(c.ToList());
         return individual;
     }
     else
     {
         return individual;
     }
 }
예제 #5
0
 public List<Individual> FormInitialPopulation()
 {
     InitialPopulation = new List<Individual>();
     AddMoreInformation();
     Random randomCount= new Random();
     for (int i=0; i< countOfPopulation; i++)
     {
         Individual individual = new Individual(numberOfFurniture, maxCountOfOneKindOfFurniture, additionalInformationAboutIndividual,
             randomCount,maxVolume,maxCost);
         InitialPopulation.Add(individual);
     }
     return InitialPopulation;
 }
예제 #6
0
 public bool CheckForTheBestIndividual(Individual nowIndividual)
 {
     if (theBestIndividual.AssessmentOfFitness < nowIndividual.AssessmentOfFitness)
     {
         theBestIndividual = nowIndividual;
         nonImprovementinTheBestIndividual = 0;
     }
     else
     {
         nonImprovementinTheBestIndividual++;
     }
     return maxNonImprovementinTheBestIndividual > nonImprovementinTheBestIndividual;
 }
예제 #7
0
 public bool CheckForNoImprovment()
 {
     InitialPopulation.OrderByDescending(x => x.AssessmentOfFitness);
     if (InitialPopulation.Count!=0)
     {
         if (InitialPopulation.First().Equals(InitialPopulation[InitialPopulation.Count - 1]))
         {
             maxOfMaxIndividual = InitialPopulation.First();
             return false;
         }
     }
     if (checkOldAndNewCommonNonDominatedOptions())
         nonImprovement++;
     else
     {
         nonImprovement = 0;
         commonNonDominatedOld.Clear();
         commonNonDominatedOld.AddRange(commonNonDominatedOptions.AsEnumerable());
         commonNonDominatedOptions.Clear();
     }
     return maxNonImprovement > nonImprovement;
 }