Changeset 13470 for branches/PTSP/HeuristicLab.Problems.PTSP/3.3/Improvers/PTSPEstimatedInversionLocalImprovement.cs
- Timestamp:
- 12/15/15 16:38:08 (9 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/PTSP/HeuristicLab.Problems.PTSP/3.3/Improvers/PTSPEstimatedInversionLocalImprovement.cs
r13469 r13470 38 38 /// The operator tries to improve the probabilistic traveling salesman solution by swapping two randomly chosen edges for a certain number of times. 39 39 /// </remarks> 40 [Item("PTSP ExhaustiveInversionLocalImprovement", "An operator that improves probabilistic traveling salesman solutions. The operator tries to improve the probabilistic traveling salesman solution by swapping two randomly chosen edges for a certain number of times.")]40 [Item("PTSP Estimated Inversion Local Improvement", "An operator that improves probabilistic traveling salesman solutions. The operator tries to improve the probabilistic traveling salesman solution by swapping two randomly chosen edges for a certain number of times.")] 41 41 [StorableClass] 42 public sealed class PTSPE xhaustiveInversionLocalImprovement : SingleSuccessorOperator, IEstimatedPTSPOperator, ILocalImprovementOperator {42 public sealed class PTSPEstimatedInversionLocalImprovement : SingleSuccessorOperator, IEstimatedPTSPOperator, ILocalImprovementOperator { 43 43 44 44 public ILookupParameter<IntValue> LocalIterationsParameter { … … 79 79 80 80 [StorableConstructor] 81 private PTSPE xhaustiveInversionLocalImprovement(bool deserializing) : base(deserializing) { }82 private PTSPE xhaustiveInversionLocalImprovement(PTSPExhaustiveInversionLocalImprovement original, Cloner cloner) : base(original, cloner) { }83 public PTSPE xhaustiveInversionLocalImprovement()81 private PTSPEstimatedInversionLocalImprovement(bool deserializing) : base(deserializing) { } 82 private PTSPEstimatedInversionLocalImprovement(PTSPEstimatedInversionLocalImprovement original, Cloner cloner) : base(original, cloner) { } 83 public PTSPEstimatedInversionLocalImprovement() 84 84 : base() { 85 85 Parameters.Add(new LookupParameter<Permutation>("Permutation", "The solution as permutation.")); … … 95 95 96 96 public override IDeepCloneable Clone(Cloner cloner) { 97 return new PTSPE xhaustiveInversionLocalImprovement(this, cloner);97 return new PTSPEstimatedInversionLocalImprovement(this, cloner); 98 98 } 99 99 100 public static void Improve(Permutation assignment, DoubleMatrix distances, DoubleValue quality, IntValue localIterations, IntValue evaluatedSolutions, bool maximization, int maxIterations, CancellationToken cancellation, ItemList<BoolArray> realizations) {100 public static void Improve(Permutation assignment, DoubleMatrix distances, DoubleValue quality, IntValue localIterations, IntValue evaluatedSolutions, bool maximization, int maxIterations, ItemList<BoolArray> realizations, CancellationToken cancellation) { 101 101 var distanceM = (DistanceMatrix)distances; 102 Func<int, int, double> distance = (a, b) => distanceM[a, b]; 102 103 for (var i = localIterations.Value; i < maxIterations; i++) { 103 104 InversionMove bestMove = null; … … 105 106 double evaluations = 0.0; 106 107 foreach (var move in ExhaustiveInversionMoveGenerator.Generate(assignment)) { 107 double moveQuality = PTSPEstimatedInversionMoveEvaluator.Evaluate ByDistanceMatrix(assignment, move, distanceM, realizations);108 evaluations += 2 * (move.Index2 - move.Index1 + 1) / (double)assignment.Length;108 double moveQuality = PTSPEstimatedInversionMoveEvaluator.EvaluateMove(assignment, move, distance, realizations); 109 evaluations += realizations.Count * 4.0 / (assignment.Length * assignment.Length); 109 110 if (maximization && moveQuality > bestQuality 110 111 || !maximization && moveQuality < bestQuality) { … … 136 137 } 137 138 138 Improve(assignment, distances, quality, localIterations, evaluations, maximization, maxIterations, CancellationToken, realizations);139 Improve(assignment, distances, quality, localIterations, evaluations, maximization, maxIterations, realizations, CancellationToken); 139 140 140 141 localIterations.Value = 0;
Note: See TracChangeset
for help on using the changeset viewer.