Changeset 12548 for branches/ALPS
- Timestamp:
- 06/30/15 12:40:20 (9 years ago)
- Location:
- branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/Alps.cs
r12531 r12548 162 162 #region Preconfigured Terminators 163 163 [Storable] 164 pr ivateComparisonTerminator<IntValue> evaluationsTerminator;164 protected ComparisonTerminator<IntValue> evaluationsTerminator; 165 165 [Storable] 166 pr ivateSingleObjectiveQualityTerminator qualityTerminator;166 protected SingleObjectiveQualityTerminator qualityTerminator; 167 167 [Storable] 168 pr ivateExecutionTimeTerminator executionTimeTerminator;168 protected ExecutionTimeTerminator executionTimeTerminator; 169 169 #endregion 170 170 … … 201 201 layerQualityAnalyzer = new BestAverageWorstQualityAnalyzer(); 202 202 203 evaluationsTerminator = new ComparisonTerminator<IntValue>("EvaluatedSolutions", ComparisonType.Less, new IntValue(int.MaxValue)) { Name = "Evaluations" }; 204 qualityTerminator = new SingleObjectiveQualityTerminator() { Name = "Quality" }; 205 executionTimeTerminator = new ExecutionTimeTerminator(this, new TimeSpanValue(TimeSpan.FromMinutes(5))); 206 203 207 ParameterizeAgeLimits(); 204 208 ParameterizeAgeInheritanceReduction(); … … 207 211 UpdateAnalyzers(); 208 212 209 CreateTerminators();210 213 ParameterizeTerminators(); 211 UpdateTerminators();212 214 213 215 Initialize(); … … 231 233 ParameterizeTerminators(); 232 234 UpdateAnalyzers(); 233 UpdateTerminators();234 235 Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged; 235 236 } … … 262 263 ParameterizeStochasticOperator(@operator); 263 264 UpdateAnalyzers(); 264 UpdateTerminators();265 265 base.Problem_OperatorsChanged(sender, e); 266 266 } … … 410 410 } 411 411 } 412 protected virtual void UpdateTerminators() {413 var newTerminators = new Dictionary<ITerminator, bool> {414 {evaluationsTerminator, Terminators.Operators.Contains(evaluationsTerminator) && Terminators.Operators.ItemChecked(evaluationsTerminator)},415 {qualityTerminator, Terminators.Operators.Contains(qualityTerminator) && Terminators.Operators.ItemChecked(qualityTerminator) },416 {executionTimeTerminator, Terminators.Operators.Contains(executionTimeTerminator) && Terminators.Operators.ItemChecked(executionTimeTerminator)}417 };418 if (Problem != null) {419 foreach (var terminator in Problem.Operators.OfType<ITerminator>())420 newTerminators.Add(terminator, !Terminators.Operators.Contains(terminator) || Terminators.Operators.ItemChecked(terminator));421 }422 423 Terminators.Operators.Clear();424 425 foreach (var newTerminator in newTerminators)426 Terminators.Operators.Add(newTerminator.Key, newTerminator.Value);427 }428 protected virtual void CreateTerminators() {429 evaluationsTerminator = new ComparisonTerminator<IntValue>("EvaluatedSolutions", ComparisonType.Less, new IntValue(int.MaxValue)) { Name = "Evaluations" };430 qualityTerminator = new SingleObjectiveQualityTerminator() { Name = "Quality" };431 executionTimeTerminator = new ExecutionTimeTerminator(this, new TimeSpanValue(TimeSpan.FromMinutes(5)));432 }433 412 #endregion 434 413 } -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/AlpsGeneticAlgorithm.cs
r12533 r12548 200 200 } 201 201 202 generationsTerminator = new ComparisonTerminator<IntValue>("Generations", ComparisonType.Less, new IntValue(1000)) { Name = "Generations" }; 203 202 204 ParameterizeSelectors(); 205 206 UpdateTerminators(); 207 203 208 Initialize(); 204 209 } … … 213 218 UpdateCrossovers(); 214 219 UpdateMutators(); 220 UpdateTerminators(); 215 221 } 216 222 protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) { … … 229 235 UpdateCrossovers(); 230 236 UpdateMutators(); 237 UpdateTerminators(); 231 238 } 232 239 protected override void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) { … … 291 298 292 299 #region Updates 293 pr otected override void UpdateTerminators() {300 private void UpdateTerminators() { 294 301 var newTerminators = new Dictionary<ITerminator, bool> { 295 302 {generationsTerminator, !Terminators.Operators.Contains(generationsTerminator) || Terminators.Operators.ItemChecked(generationsTerminator)}, 303 {evaluationsTerminator, Terminators.Operators.Contains(evaluationsTerminator) && Terminators.Operators.ItemChecked(evaluationsTerminator)}, 304 {qualityTerminator, Terminators.Operators.Contains(qualityTerminator) && Terminators.Operators.ItemChecked(qualityTerminator) }, 305 {executionTimeTerminator, Terminators.Operators.Contains(executionTimeTerminator) && Terminators.Operators.ItemChecked(executionTimeTerminator)} 296 306 }; 297 298 base.UpdateTerminators(); 307 if (Problem != null) { 308 foreach (var terminator in Problem.Operators.OfType<ITerminator>()) 309 newTerminators.Add(terminator, !Terminators.Operators.Contains(terminator) || Terminators.Operators.ItemChecked(terminator)); 310 } 311 312 Terminators.Operators.Clear(); 299 313 300 314 foreach (var newTerminator in newTerminators) 301 Terminators.Operators.Insert(0, newTerminator.Key, newTerminator.Value); 302 } 303 protected override void CreateTerminators() { 304 generationsTerminator = new ComparisonTerminator<IntValue>("Generations", ComparisonType.Less, new IntValue(1000)) { Name = "Generations" }; 305 base.CreateTerminators(); 315 Terminators.Operators.Add(newTerminator.Key, newTerminator.Value); 306 316 } 307 317 private void UpdateCrossovers() {
Note: See TracChangeset
for help on using the changeset viewer.