Changeset 11300 for trunk/sources
- Timestamp:
- 08/26/14 11:12:16 (10 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearchImprovementOperator.cs
r11171 r11300 38 38 [Item("LocalSearchImprovementOperator", "A local search improvement operator.")] 39 39 [StorableClass] 40 public sealed class LocalSearchImprovementOperator : SingleSuccessorOperator, ILocalImprovement Operator, IStochasticOperator {40 public sealed class LocalSearchImprovementOperator : SingleSuccessorOperator, ILocalImprovementAlgorithmOperator, IStochasticOperator { 41 41 #region IGenericLocalImprovementOperator Properties 42 42 public Type ProblemType { get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); } } -
trunk/sources/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealingImprovementOperator.cs
r11171 r11300 38 38 [Item("SimulatedAnnealingImprovementOperator", "A simulated annealing improvement operator.")] 39 39 [StorableClass] 40 public sealed class SimulatedAnnealingImprovementOperator : SingleSuccessorOperator, ILocalImprovement Operator, IStochasticOperator {40 public sealed class SimulatedAnnealingImprovementOperator : SingleSuccessorOperator, ILocalImprovementAlgorithmOperator, IStochasticOperator { 41 41 #region IGenericLocalImprovementOperator Properties 42 42 public Type ProblemType { get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); } } -
trunk/sources/HeuristicLab.Algorithms.VariableNeighborhoodSearch/3.3/VariableNeighborhoodSearch.cs
r11171 r11300 283 283 private void ParameterizeLocalImprovementOperators() { 284 284 foreach (ILocalImprovementOperator op in LocalImprovementParameter.ValidValues) { 285 if (op != LocalImprovementParameter.Value) op.Problem = null;286 285 op.MaximumIterationsParameter.Value = null; 287 286 op.MaximumIterationsParameter.ActualName = LocalImprovementMaximumIterationsParameter.Name; 288 } 289 if (LocalImprovementParameter.Value != null) 290 LocalImprovementParameter.Value.Problem = Problem; 287 288 var algOp = op as ILocalImprovementAlgorithmOperator; 289 if (algOp != null && algOp != LocalImprovementParameter.Value) algOp.Problem = null; 290 } 291 if (LocalImprovementParameter.Value is ILocalImprovementAlgorithmOperator) 292 ((ILocalImprovementAlgorithmOperator)LocalImprovementParameter.Value).Problem = Problem; 291 293 } 292 294 private void InitializeLocalImprovementOperators() { … … 294 296 LocalImprovementParameter.ValidValues.Clear(); 295 297 } else { 296 foreach (var entry in LocalImprovementParameter.ValidValues.ToList()) {297 if (! entry.ProblemType.IsAssignableFrom(Problem.GetType())) {298 LocalImprovementParameter.ValidValues.Remove( entry);298 foreach (var algOp in LocalImprovementParameter.ValidValues.OfType<ILocalImprovementAlgorithmOperator>()) { 299 if (!algOp.ProblemType.IsInstanceOfType(Problem)) { 300 LocalImprovementParameter.ValidValues.Remove(algOp); 299 301 } 300 302 } 301 foreach (ILocalImprovementOperator op in ApplicationManager.Manager.GetInstances<ILocalImprovementOperator>().Where(x => x.ProblemType.IsAssignableFrom(Problem.GetType()))) { 302 if (!LocalImprovementParameter.ValidValues.Any(x => x.GetType() == op.GetType())) 303 // Regular ILocalImprovementOperators queried from Problem 304 foreach (var op in Problem.Operators.OfType<ILocalImprovementOperator>().Where(x => !(x is ILocalImprovementAlgorithmOperator))) { 305 LocalImprovementParameter.ValidValues.Add(op); 306 } 307 // ILocalImprovementAlgorithmOperators queried from ApplicationManager 308 var algOps = ApplicationManager.Manager.GetInstances<ILocalImprovementAlgorithmOperator>() 309 .Where(x => x.ProblemType.IsInstanceOfType(Problem)); 310 foreach (var op in algOps) { 311 if (LocalImprovementParameter.ValidValues.All(x => x.GetType() != op.GetType())) 303 312 LocalImprovementParameter.ValidValues.Add(op); 304 313 } -
trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
r9438 r11300 114 114 </ItemGroup> 115 115 <ItemGroup> 116 <Compile Include="Interfaces\ILocalImprovementAlgorithmOperator.cs" /> 116 117 <Compile Include="Interfaces\ISingleObjectivePathRelinker.cs" /> 117 118 <Compile Include="Interfaces\ISingleObjectiveImprovementOperator.cs" /> -
trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/ILocalImprovementOperator.cs
r11171 r11300 20 20 #endregion 21 21 22 using System;23 22 using HeuristicLab.Core; 24 23 using HeuristicLab.Data; … … 26 25 namespace HeuristicLab.Optimization { 27 26 public interface ILocalImprovementOperator : IOperator { 28 Type ProblemType { get; }29 IProblem Problem { get; set; }30 27 IValueLookupParameter<IntValue> MaximumIterationsParameter { get; } 31 28 ILookupParameter<IntValue> EvaluatedSolutionsParameter { get; } -
trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/LocalImprovement/QAPExhaustiveInsertionLocalImprovement.cs
r11171 r11300 35 35 [StorableClass] 36 36 public class QAPExhaustiveInsertionLocalImprovement : SingleSuccessorOperator, ILocalImprovementOperator { 37 38 public Type ProblemType {39 get { return typeof(QuadraticAssignmentProblem); }40 }41 42 [Storable]43 private QuadraticAssignmentProblem problem;44 public IProblem Problem {45 get { return problem; }46 set { problem = (QuadraticAssignmentProblem)value; }47 }48 37 49 38 public ILookupParameter<IntValue> LocalIterationsParameter { … … 87 76 protected QAPExhaustiveInsertionLocalImprovement(QAPExhaustiveInsertionLocalImprovement original, Cloner cloner) 88 77 : base(original, cloner) { 89 this.problem = cloner.Clone(original.problem);90 78 } 91 79 public QAPExhaustiveInsertionLocalImprovement() -
trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/LocalImprovement/QAPExhaustiveInversionLocalImprovement.cs
r11171 r11300 35 35 [StorableClass] 36 36 public class QAPExhaustiveInversionLocalImprovement : SingleSuccessorOperator, ILocalImprovementOperator { 37 38 public Type ProblemType {39 get { return typeof(QuadraticAssignmentProblem); }40 }41 42 [Storable]43 private QuadraticAssignmentProblem problem;44 public IProblem Problem {45 get { return problem; }46 set { problem = (QuadraticAssignmentProblem)value; }47 }48 37 49 38 public ILookupParameter<IntValue> LocalIterationsParameter { … … 87 76 protected QAPExhaustiveInversionLocalImprovement(QAPExhaustiveInversionLocalImprovement original, Cloner cloner) 88 77 : base(original, cloner) { 89 this.problem = cloner.Clone(original.problem);90 78 } 91 79 public QAPExhaustiveInversionLocalImprovement() -
trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/LocalImprovement/QAPExhaustiveSwap2LocalImprovement.cs
r11171 r11300 35 35 [StorableClass] 36 36 public class QAPExhaustiveSwap2LocalImprovement : SingleSuccessorOperator, ILocalImprovementOperator { 37 38 public Type ProblemType {39 get { return typeof(QuadraticAssignmentProblem); }40 }41 42 [Storable]43 private QuadraticAssignmentProblem problem;44 public IProblem Problem {45 get { return problem; }46 set { problem = (QuadraticAssignmentProblem)value; }47 }48 37 49 38 public ILookupParameter<IntValue> LocalIterationsParameter { … … 91 80 protected QAPExhaustiveSwap2LocalImprovement(QAPExhaustiveSwap2LocalImprovement original, Cloner cloner) 92 81 : base(original, cloner) { 93 this.problem = cloner.Clone(original.problem);94 82 } 95 83 public QAPExhaustiveSwap2LocalImprovement() -
trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/LocalImprovement/QAPStochasticScrambleLocalImprovement.cs
r11171 r11300 35 35 [StorableClass] 36 36 public class QAPStochasticScrambleLocalImprovement : SingleSuccessorOperator, ILocalImprovementOperator, IStochasticOperator { 37 38 public Type ProblemType {39 get { return typeof(QuadraticAssignmentProblem); }40 }41 42 [Storable]43 private QuadraticAssignmentProblem problem;44 public IProblem Problem {45 get { return problem; }46 set { problem = (QuadraticAssignmentProblem)value; }47 }48 37 49 38 public ILookupParameter<IntValue> LocalIterationsParameter { … … 95 84 protected QAPStochasticScrambleLocalImprovement(QAPStochasticScrambleLocalImprovement original, Cloner cloner) 96 85 : base(original, cloner) { 97 this.problem = cloner.Clone(original.problem);98 86 } 99 87 public QAPStochasticScrambleLocalImprovement() -
trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs
r11171 r11300 302 302 Operators.Add(new QAPAlleleFrequencyAnalyzer()); 303 303 Operators.Add(new QAPPopulationDiversityAnalyzer()); 304 305 Operators.Add(new QAPExhaustiveInsertionLocalImprovement()); 306 Operators.Add(new QAPExhaustiveInversionLocalImprovement()); 307 Operators.Add(new QAPStochasticScrambleLocalImprovement()); 304 308 Operators.Add(new QAPExhaustiveSwap2LocalImprovement()); 309 305 310 Operators.Add(new QAPSimilarityCalculator()); 306 311 ParameterizeAnalyzers(); -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/LocalImprovement/AlbaLambdaInterchangeLocalImprovementOperator.cs
r11171 r11300 37 37 [StorableClass] 38 38 public class AlbaLambdaInterchangeLocalImprovementOperator : VRPOperator, IStochasticOperator, ILocalImprovementOperator { 39 public Type ProblemType {40 get { return typeof(VehicleRoutingProblem); }41 }42 43 [Storable]44 private VehicleRoutingProblem problem;45 public IProblem Problem {46 get { return problem; }47 set { problem = (VehicleRoutingProblem)value; }48 }49 39 50 40 public IValueLookupParameter<IntValue> MaximumIterationsParameter { … … 84 74 protected AlbaLambdaInterchangeLocalImprovementOperator(AlbaLambdaInterchangeLocalImprovementOperator original, Cloner cloner) 85 75 : base(original, cloner) { 86 this.problem = cloner.Clone(original.problem);87 76 } 88 77 public AlbaLambdaInterchangeLocalImprovementOperator() … … 102 91 } 103 92 104 public static void Apply(AlbaEncoding solution, int maxIterations, 93 public static void Apply(AlbaEncoding solution, int maxIterations, 105 94 int lambda, int samples, IRandom random, IVRPProblemInstance problemInstance, ref double quality, out int evaluatedSolutions) { 106 95 evaluatedSolutions = 0; … … 120 109 } 121 110 } 122 if (bestMove != null) 111 if (bestMove != null) 123 112 AlbaLambdaInterchangeMoveMaker.Apply(solution, bestMove); 124 113 }
Note: See TracChangeset
for help on using the changeset viewer.