Changeset 5751
- Timestamp:
- 03/18/11 14:15:49 (14 years ago)
- Location:
- branches/VNS/HeuristicLab.Algorithms.LocalSearch/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VNS/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearch.cs
r5445 r5751 168 168 variableCreator.Name = "Initialize EvaluatedMoves"; 169 169 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedMoves", new IntValue())); 170 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0))); 171 variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("BestQuality", new DoubleValue(0))); 170 172 variableCreator.Successor = resultsCollector; 171 173 … … 182 184 mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name; 183 185 mainLoop.EvaluatedMovesParameter.ActualName = "EvaluatedMoves"; 186 mainLoop.IterationsParameter.ActualName = "Iterations"; 187 mainLoop.BestQualityParameter.ActualName = "BestQuality"; 184 188 185 189 moveQualityAnalyzer = new BestAverageWorstQualityAnalyzer(); -
branches/VNS/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearchImprovementOperator.cs
r5735 r5751 104 104 public LocalSearchImprovementOperator() 105 105 : base() { 106 loop = new LocalSearchMainLoop("LocalIterations", "BestLocalQuality"); 107 108 ResultsCollector rc = ((loop.OperatorGraph.InitialOperator as SingleSuccessorOperator).Successor 109 as SingleSuccessorOperator).Successor as ResultsCollector; 106 loop = new LocalSearchMainLoop(); 107 108 ResultsCollector rc = (loop.OperatorGraph.InitialOperator as SingleSuccessorOperator).Successor as ResultsCollector; 110 109 rc.CollectedValues.Remove("BestLocalQuality"); 111 110 … … 286 285 } 287 286 287 VariableCreator variableCreator = new VariableCreator(); 288 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("LocalIterations", new IntValue(0))); 289 variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("BestLocalQuality", new DoubleValue(0))); 290 291 variableCreator.Successor = loop; 292 288 293 loop.EvaluatedMovesParameter.ActualName = EvaluatedSolutionsParameter.ActualName; 289 294 290 processor.Operators.Add( loop);295 processor.Operators.Add(variableCreator); 291 296 processor.Successor = remover; 292 297 -
branches/VNS/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearchMainLoop.cs
r5735 r5751 46 46 get { return (LookupParameter<DoubleValue>)Parameters["Quality"]; } 47 47 } 48 public LookupParameter<DoubleValue> BestQualityParameter { 49 get { return (LookupParameter<DoubleValue>)Parameters["BestLocalQuality"]; } 50 } 48 51 public ValueLookupParameter<DoubleValue> BestKnownQualityParameter { 49 52 get { return (ValueLookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; } … … 52 55 get { return (LookupParameter<DoubleValue>)Parameters["MoveQuality"]; } 53 56 } 57 public LookupParameter<IntValue> IterationsParameter { 58 get { return (LookupParameter<IntValue>)Parameters["LocalIterations"]; } 59 } 54 60 public ValueLookupParameter<IntValue> MaximumIterationsParameter { 55 61 get { return (ValueLookupParameter<IntValue>)Parameters["MaximumIterations"]; } … … 77 83 [StorableConstructor] 78 84 private LocalSearchMainLoop(bool deserializing) : base(deserializing) { } 79 public LocalSearchMainLoop(string iterationsName, string bestQualityName)80 : base() {81 Initialize(iterationsName, bestQualityName);82 }83 85 public LocalSearchMainLoop() 84 86 : base() { 85 Initialize("Iterations", "BestQuality");87 Initialize(); 86 88 } 87 89 private LocalSearchMainLoop(LocalSearchMainLoop original, Cloner cloner) … … 92 94 } 93 95 94 private void Initialize( string iterationsName, string bestQualityName) {96 private void Initialize() { 95 97 #region Create parameters 96 98 Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator.")); 97 99 Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false.")); 98 100 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution.")); 99 Parameters.Add(new LookupParameter<DoubleValue>("Best Quality", "The value which represents the best quality fjo."));101 Parameters.Add(new LookupParameter<DoubleValue>("BestLocalQuality", "The value which represents the best quality found so far.")); 100 102 Parameters.Add(new ValueLookupParameter<DoubleValue>("BestKnownQuality", "The best known quality value found so far.")); 101 103 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The value which represents the quality of a move.")); 104 Parameters.Add(new LookupParameter<IntValue>("LocalIterations", "The number of generations.")); 102 105 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.")); 103 106 Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored.")); … … 112 115 113 116 #region Create operators 114 VariableCreator variableCreator = new VariableCreator();115 117 SubScopesProcessor subScopesProcessor0 = new SubScopesProcessor(); 116 118 Assigner bestQualityInitializer = new Assigner(); … … 137 139 ConditionalBranch iterationsTermination = new ConditionalBranch(); 138 140 139 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>(iterationsName, new IntValue(0))); // Class LocalSearch expects this to be called Iterations140 variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>(bestQualityName, new DoubleValue(0)));141 142 141 bestQualityInitializer.Name = "Initialize BestQuality"; 143 bestQualityInitializer.LeftSideParameter.ActualName = bestQualityName;142 bestQualityInitializer.LeftSideParameter.ActualName = BestQualityParameter.Name; 144 143 bestQualityInitializer.RightSideParameter.ActualName = QualityParameter.Name; 145 144 … … 148 147 149 148 resultsCollector1.CopyValue = new BoolValue(false); 150 resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>( iterationsName));151 resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>( bestQualityName, null, bestQualityName));149 resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>(IterationsParameter.Name)); 150 resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>(BestQualityParameter.Name, null, BestQualityParameter.Name)); 152 151 resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name; 153 152 … … 178 177 179 178 bestQualityUpdater.Name = "Update BestQuality"; 180 bestQualityUpdater.LeftSideParameter.ActualName = bestQualityName;179 bestQualityUpdater.LeftSideParameter.ActualName = BestQualityParameter.Name; 181 180 bestQualityUpdater.RightSideParameter.ActualName = QualityParameter.Name; 182 181 183 182 resultsCollector2.CopyValue = new BoolValue(false); 184 resultsCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>( bestQualityName, null, bestQualityName));183 resultsCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>(BestQualityParameter.Name, null, BestQualityParameter.Name)); 185 184 resultsCollector2.ResultsParameter.ActualName = ResultsParameter.Name; 186 185 … … 192 191 iterationsCounter.Name = "Iterations Counter"; 193 192 iterationsCounter.Increment = new IntValue(1); 194 iterationsCounter.ValueParameter.ActualName = iterationsName;193 iterationsCounter.ValueParameter.ActualName = IterationsParameter.Name; 195 194 196 195 iterationsComparator.Name = "Iterations >= MaximumIterations"; 197 196 iterationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual); 198 iterationsComparator.LeftSideParameter.ActualName = iterationsName;197 iterationsComparator.LeftSideParameter.ActualName = IterationsParameter.Name; 199 198 iterationsComparator.RightSideParameter.ActualName = MaximumIterationsParameter.Name; 200 199 iterationsComparator.ResultParameter.ActualName = "Terminate"; … … 205 204 206 205 #region Create operator graph 207 OperatorGraph.InitialOperator = variableCreator; 208 variableCreator.Successor = subScopesProcessor0; 206 OperatorGraph.InitialOperator = subScopesProcessor0; 209 207 subScopesProcessor0.Operators.Add(bestQualityInitializer); 210 208 subScopesProcessor0.Successor = resultsCollector1;
Note: See TracChangeset
for help on using the changeset viewer.