Changeset 15563 for branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/LocalSearch
- Timestamp:
- 12/30/17 23:10:29 (7 years ago)
- Location:
- branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/LocalSearch
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/LocalSearch/IteratedLS.cs
r15562 r15563 33 33 [Creatable(CreatableAttribute.Categories.SingleSolutionAlgorithms)] 34 34 [StorableClass] 35 public sealed class IteratedLS : ContextAlgorithm<LocalSearchContext> {35 public sealed class IteratedLS : StochasticAlgorithm<LocalSearchContext> { 36 36 37 37 public override bool SupportsPause { … … 92 92 93 93 protected override void Run(CancellationToken cancellationToken) { 94 var lastUpdate = ExecutionTime; 95 94 96 while (!StoppingCriterion()) { 95 97 var lsevaluations = 0; … … 109 111 110 112 IResult result; 111 if (Results.TryGetValue("Iterations", out result)) 112 ((IntValue)result.Value).Value = Context.Iterations; 113 else Results.Add(new Result("Iterations", new IntValue(Context.Iterations))); 114 if (Results.TryGetValue("EvaluatedSolutions", out result)) 115 ((IntValue)result.Value).Value = Context.EvaluatedSolutions; 116 else Results.Add(new Result("EvaluatedSolutions", new IntValue(Context.EvaluatedSolutions))); 113 if (ExecutionTime - lastUpdate > TimeSpan.FromSeconds(1)) { 114 if (Results.TryGetValue("Iterations", out result)) 115 ((IntValue)result.Value).Value = Context.Iterations; 116 else Results.Add(new Result("Iterations", new IntValue(Context.Iterations))); 117 if (Results.TryGetValue("EvaluatedSolutions", out result)) 118 ((IntValue)result.Value).Value = Context.EvaluatedSolutions; 119 else Results.Add(new Result("EvaluatedSolutions", new IntValue(Context.EvaluatedSolutions))); 120 lastUpdate = ExecutionTime; 121 } 117 122 if (Results.TryGetValue("BestQuality", out result)) 118 123 ((DoubleValue)result.Value).Value = Context.BestQuality; … … 127 132 if (cancellationToken.IsCancellationRequested) break; 128 133 } 134 IResult result2; 135 if (Results.TryGetValue("Iterations", out result2)) 136 ((IntValue)result2.Value).Value = Context.Iterations; 137 else Results.Add(new Result("Iterations", new IntValue(Context.Iterations))); 138 if (Results.TryGetValue("EvaluatedSolutions", out result2)) 139 ((IntValue)result2.Value).Value = Context.EvaluatedSolutions; 140 else Results.Add(new Result("EvaluatedSolutions", new IntValue(Context.EvaluatedSolutions))); 129 141 } 130 142 -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/LocalSearch/MultistartLS.cs
r15562 r15563 33 33 [Creatable(CreatableAttribute.Categories.SingleSolutionAlgorithms)] 34 34 [StorableClass] 35 public sealed class MultistartLS : ContextAlgorithm<LocalSearchContext> {35 public sealed class MultistartLS : StochasticAlgorithm<LocalSearchContext> { 36 36 37 37 public override bool SupportsPause { … … 71 71 72 72 protected override void Run(CancellationToken cancellationToken) { 73 var lastUpdate = ExecutionTime; 74 73 75 while (!StoppingCriterion()) { 74 76 var lsevaluations = 0; … … 89 91 90 92 IResult result; 91 if (Results.TryGetValue("Iterations", out result)) 92 ((IntValue)result.Value).Value = Context.Iterations; 93 else Results.Add(new Result("Iterations", new IntValue(Context.Iterations))); 94 if (Results.TryGetValue("EvaluatedSolutions", out result)) 95 ((IntValue)result.Value).Value = Context.EvaluatedSolutions; 96 else Results.Add(new Result("EvaluatedSolutions", new IntValue(Context.EvaluatedSolutions))); 93 if (ExecutionTime - lastUpdate > TimeSpan.FromSeconds(1)) { 94 if (Results.TryGetValue("Iterations", out result)) 95 ((IntValue)result.Value).Value = Context.Iterations; 96 else Results.Add(new Result("Iterations", new IntValue(Context.Iterations))); 97 if (Results.TryGetValue("EvaluatedSolutions", out result)) 98 ((IntValue)result.Value).Value = Context.EvaluatedSolutions; 99 else Results.Add(new Result("EvaluatedSolutions", new IntValue(Context.EvaluatedSolutions))); 100 lastUpdate = ExecutionTime; 101 } 97 102 if (Results.TryGetValue("BestQuality", out result)) 98 103 ((DoubleValue)result.Value).Value = Context.BestQuality; … … 107 112 if (cancellationToken.IsCancellationRequested) break; 108 113 } 114 115 IResult result2; 116 if (Results.TryGetValue("Iterations", out result2)) 117 ((IntValue)result2.Value).Value = Context.Iterations; 118 else Results.Add(new Result("Iterations", new IntValue(Context.Iterations))); 119 if (Results.TryGetValue("EvaluatedSolutions", out result2)) 120 ((IntValue)result2.Value).Value = Context.EvaluatedSolutions; 121 else Results.Add(new Result("EvaluatedSolutions", new IntValue(Context.EvaluatedSolutions))); 109 122 } 110 123 }
Note: See TracChangeset
for help on using the changeset viewer.