Changeset 5809 for trunk/sources/HeuristicLab.Algorithms.LocalSearch
- Timestamp:
- 03/23/11 01:09:38 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3
- Property svn:ignore
-
old new 3 3 obj 4 4 HeuristicLabAlgorithmsLocalSearchPlugin.cs 5 *.vs10x
-
- Property svn:ignore
-
trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearch.cs
r5753 r5809 38 38 [Creatable("Algorithms")] 39 39 [StorableClass] 40 public sealed class LocalSearch : EngineAlgorithm, IStorableContent {40 public sealed class LocalSearch : HeuristicOptimizationEngineAlgorithm, IStorableContent { 41 41 public string Filename { get; set; } 42 42 43 43 #region Problem Properties 44 44 public override Type ProblemType { 45 get { return typeof(ISingleObjective Problem); }46 } 47 public new ISingleObjective Problem Problem {48 get { return (ISingleObjective Problem)base.Problem; }45 get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); } 46 } 47 public new ISingleObjectiveHeuristicOptimizationProblem Problem { 48 get { return (ISingleObjectiveHeuristicOptimizationProblem)base.Problem; } 49 49 set { base.Problem = value; } 50 50 } -
trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearchImprovementOperator.cs
r5753 r5809 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Text; 25 using HeuristicLab.Analysis; 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 using HeuristicLab. Persistence.Default.CompositeSerializers.Storable;28 using HeuristicLab.Data; 28 29 using HeuristicLab.Operators; 29 using HeuristicLab.Common;30 using HeuristicLab.Parameters;31 using HeuristicLab.Algorithms.LocalSearch;32 using HeuristicLab.Data;33 30 using HeuristicLab.Optimization; 34 31 using HeuristicLab.Optimization.Operators; 35 using HeuristicLab.Analysis; 32 using HeuristicLab.Parameters; 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 36 34 37 35 namespace HeuristicLab.Algorithms.LocalSearch { … … 41 39 [Item("LocalSearchImprovementOperator", "A local search improvement operator.")] 42 40 [StorableClass] 43 public class LocalSearchImprovementOperator : SingleSuccessorOperator, ILocalImprovementOperator {41 public class LocalSearchImprovementOperator : SingleSuccessorOperator, ILocalImprovementOperator { 44 42 [Storable] 45 43 private LocalSearchMainLoop loop; … … 47 45 [Storable] 48 46 private BestAverageWorstQualityAnalyzer qualityAnalyzer; 49 47 50 48 private ConstrainedValueParameter<IMoveGenerator> MoveGeneratorParameter { 51 49 get { return (ConstrainedValueParameter<IMoveGenerator>)Parameters["MoveGenerator"]; } … … 88 86 89 87 [StorableConstructor] 90 protected LocalSearchImprovementOperator(bool deserializing) : base(deserializing) { }88 protected LocalSearchImprovementOperator(bool deserializing) : base(deserializing) { } 91 89 [StorableHook(HookType.AfterDeserialization)] 92 90 private void AfterDeserialization() { … … 95 93 protected LocalSearchImprovementOperator(LocalSearchImprovementOperator original, Cloner cloner) 96 94 : base(original, cloner) { 97 98 99 95 this.loop = cloner.Clone(original.loop); 96 this.qualityAnalyzer = cloner.Clone(original.qualityAnalyzer); 97 Initialize(); 100 98 } 101 99 public override IDeepCloneable Clone(Cloner cloner) { … … 104 102 public LocalSearchImprovementOperator() 105 103 : base() { 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 104 loop = new LocalSearchMainLoop(); 105 106 ResultsCollector rc = (loop.OperatorGraph.InitialOperator as SingleSuccessorOperator).Successor as ResultsCollector; 107 rc.CollectedValues.Remove("BestLocalQuality"); 108 109 qualityAnalyzer = new BestAverageWorstQualityAnalyzer(); 110 111 Parameters.Add(new ConstrainedValueParameter<IMoveGenerator>("MoveGenerator", "The operator used to generate moves to the neighborhood of the current solution.")); 112 Parameters.Add(new ConstrainedValueParameter<IMoveMaker>("MoveMaker", "The operator used to perform a move.")); 113 Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>("MoveEvaluator", "The operator used to evaluate a move.")); 114 Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(150))); 115 Parameters.Add(new ValueParameter<IntValue>("SampleSize", "Number of moves that MultiMoveGenerators should create. This is ignored for Exhaustive- and SingleMoveGenerators.", new IntValue(1500))); 116 Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of evaluated moves.")); 117 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the solution.", new MultiAnalyzer())); 118 119 Initialize(); 122 120 } 123 121 … … 130 128 ChooseMoveOperators(); 131 129 132 ParameterizeMoveGenerators(problem as ISingleObjective Problem);133 ParameterizeMoveEvaluators(problem as ISingleObjective Problem);134 ParameterizeMoveMakers(problem as ISingleObjective Problem);135 136 ParameterizeAnalyzers(problem as ISingleObjective Problem);137 UpdateAnalyzers(problem as ISingleObjective Problem);138 } 139 140 void ParameterizeAnalyzers(ISingleObjective Problem problem) {130 ParameterizeMoveGenerators(problem as ISingleObjectiveHeuristicOptimizationProblem); 131 ParameterizeMoveEvaluators(problem as ISingleObjectiveHeuristicOptimizationProblem); 132 ParameterizeMoveMakers(problem as ISingleObjectiveHeuristicOptimizationProblem); 133 134 ParameterizeAnalyzers(problem as ISingleObjectiveHeuristicOptimizationProblem); 135 UpdateAnalyzers(problem as ISingleObjectiveHeuristicOptimizationProblem); 136 } 137 138 void ParameterizeAnalyzers(ISingleObjectiveHeuristicOptimizationProblem problem) { 141 139 qualityAnalyzer.ResultsParameter.ActualName = "Results"; 142 140 if (problem != null) { … … 148 146 } 149 147 150 void UpdateAnalyzers(ISingleObjective Problem problem) {148 void UpdateAnalyzers(ISingleObjectiveHeuristicOptimizationProblem problem) { 151 149 Analyzer.Operators.Clear(); 152 150 if (problem != null) { … … 228 226 if (mm != null) MoveMaker = mm; 229 227 else MoveMaker = validMoveMakers.FirstOrDefault(); 230 } 228 } 231 229 232 230 if (oldMoveEvaluator != null) { … … 234 232 if (me != null) MoveEvaluator = me; 235 233 else MoveEvaluator = validMoveEvaluators.FirstOrDefault(); 236 } 234 } 237 235 } 238 236 } … … 244 242 } 245 243 246 private void ParameterizeMoveGenerators(ISingleObjective Problem problem) {244 private void ParameterizeMoveGenerators(ISingleObjectiveHeuristicOptimizationProblem problem) { 247 245 if (problem != null) { 248 246 foreach (IMultiMoveGenerator generator in problem.Operators.OfType<IMultiMoveGenerator>()) … … 250 248 } 251 249 } 252 private void ParameterizeMoveEvaluators(ISingleObjective Problem problem) {250 private void ParameterizeMoveEvaluators(ISingleObjectiveHeuristicOptimizationProblem problem) { 253 251 foreach (ISingleObjectiveMoveEvaluator op in problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) { 254 252 op.QualityParameter.ActualName = problem.Evaluator.QualityParameter.ActualName; 255 253 } 256 254 } 257 private void ParameterizeMoveMakers(ISingleObjective Problem problem) {255 private void ParameterizeMoveMakers(ISingleObjectiveHeuristicOptimizationProblem problem) { 258 256 foreach (IMoveMaker op in problem.Operators.OfType<IMoveMaker>()) { 259 257 op.QualityParameter.ActualName = problem.Evaluator.QualityParameter.ActualName;
Note: See TracChangeset
for help on using the changeset viewer.