Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | None | 0 0
  1. namespace GeneticAlgorithm_cs
  2. {
  3.     class GreedyAlgorithm
  4.     {
  5.         private int color = 0;
  6.         private Count count;
  7.         private List<int> colorsList = new List<int>();
  8.  
  9.         public GreedyAlgorithm(Count c)
  10.         {
  11.             count = c;
  12.             for(int i = 0; i < Parameters.gensQuantity; i++)
  13.             {
  14.                 colorsList.Add(-1);
  15.             }
  16.             colorsList[0] = 0;
  17.         }
  18.  
  19.         public void Start()
  20.         {
  21.            
  22.             for(int i = 0; i < Parameters.gensQuantity; i++)
  23.             {
  24.                 colorsList[i] = 0;
  25.                 color = 0;
  26.                 for (int j = 1; j < count.Matrix[i].Count; j++)
  27.                 {
  28.                     Console.WriteLine(colorsList[count.Matrix[i][j] - 1]);
  29.                     Console.WriteLine(colorsList[i]);
  30.  
  31.                     if (colorsList[count.Matrix[i][j] - 1] == colorsList[i])
  32.                     {
  33.                         color++;
  34.                         colorsList[i] = color;
  35.                         j = 1;
  36.                     }
  37.                 }
  38.                
  39.             }
  40.  
  41.             Individual ind = new Individual();
  42.             ind.Colors = colorsList;
  43.  
  44.             Console.WriteLine("Konfliktów: " + count.GetConfolictQuantity(ind));
  45.             Console.WriteLine("Kolorwów: " + ind.GetColorQunatity());
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement