@@ -8,7 +8,7 @@ namespace MultiagentAlgorithm
88{
99 public static class Algorithm
1010 {
11- private static readonly ILog Log = LogManager . GetLogger ( MethodBase . GetCurrentMethod ( ) . DeclaringType ) ;
11+ // private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
1212
1313 public static ResultData Run ( BaseGraph graph , Options options , Random rnd , IExportGraph graphExport )
1414 {
@@ -22,10 +22,8 @@ public static ResultData Run(BaseGraph graph, Options options, Random rnd, IExpo
2222
2323 var bestCost = graph . GetGlobalCostFunction ( ) ;
2424 var bestCostIteration = 0 ;
25- var bestDistribution = ( Vertex [ ] ) graph . Vertices . Clone ( ) ;
26- Log . Info ( $ "Initial global cost: { bestCost } ") ;
27-
2825 var iteration = 0 ;
26+
2927 while ( bestCost > 0 && iteration < options . NumberOfIterations )
3028 {
3129 // At a given iteration each ant moves from the current position
@@ -78,29 +76,13 @@ public static ResultData Run(BaseGraph graph, Options options, Random rnd, IExpo
7876 {
7977 bestCost = globalCost ;
8078 bestCostIteration = iteration ;
81- bestDistribution = ( Vertex [ ] ) graph . Vertices . Clone ( ) ;
8279 }
83- Log . Info ( $ "Iteration [{ iteration } ] | Ant { ant } | Global cost: { globalCost } | Best cost: { bestCost } ") ;
8480 }
8581 iteration ++ ;
8682 }
8783 stopwatch . Stop ( ) ;
8884
8985 var result = new ResultData ( bestCost , bestCostIteration , stopwatch . ElapsedMilliseconds ) ;
90- Log . Info ( result . ToString ( ) ) ;
91-
92- if ( Log . IsDebugEnabled )
93- {
94- foreach ( var partition in Enumerable . Range ( 1 , options . NumberOfPartitions ) )
95- {
96- var numberOfVerticesWithinPartition = bestDistribution . Count ( vertex => vertex . Color == partition ) ;
97- Log . Debug ( $ "Partition [{ partition } ]: { numberOfVerticesWithinPartition } ") ;
98- }
99- }
100- LoggerHelper . LogVertices ( bestDistribution ) ;
101- LoggerHelper . LogVerticesOneLine ( bestDistribution ) ;
102- graphExport . ExportGraph ( bestDistribution ) ;
103- //LoggerHelper.LogChangesOnVertices(graph.changes);
10486
10587 return result ;
10688 }
0 commit comments