Changeset 6055 for branches/histogram/HeuristicLab.Algorithms.LocalSearch
- Timestamp:
- 04/27/11 09:22:20 (14 years ago)
- Location:
- branches/histogram
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/histogram
- Property svn:mergeinfo changed
/trunk/sources merged: 6047-6048,6051-6054
- Property svn:mergeinfo changed
-
branches/histogram/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearch.cs
r6046 r6055 349 349 } 350 350 private void ParameterizeMainLoop() { 351 MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name; 352 MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 353 MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 351 if (Problem != null) { 352 MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name; 353 MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 354 MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 355 } 354 356 if (MoveEvaluator != null) 355 357 MainLoop.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName; 356 358 } 357 359 private void ParameterizeStochasticOperator(IOperator op) { 358 if (op is IStochasticOperator) 359 ((IStochasticOperator)op).RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName; 360 if (op is IStochasticOperator) { 361 IStochasticOperator stOp = (IStochasticOperator)op; 362 stOp.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName; 363 stOp.RandomParameter.Hidden = true; 364 } 360 365 } 361 366 private void ParameterizeMoveGenerators() { 362 367 if (Problem != null) { 363 foreach (IMultiMoveGenerator generator in Problem.Operators.OfType<IMultiMoveGenerator>()) 368 foreach (IMultiMoveGenerator generator in Problem.Operators.OfType<IMultiMoveGenerator>()) { 364 369 generator.SampleSizeParameter.ActualName = SampleSizeParameter.Name; 370 generator.SampleSizeParameter.Hidden = true; 371 } 365 372 } 366 373 } … … 368 375 foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) { 369 376 op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 377 op.QualityParameter.Hidden = true; 370 378 } 371 379 } … … 373 381 foreach (IMoveMaker op in Problem.Operators.OfType<IMoveMaker>()) { 374 382 op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 375 if (MoveEvaluator != null) 383 op.QualityParameter.Hidden = true; 384 if (MoveEvaluator != null) { 376 385 op.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName; 386 op.MoveQualityParameter.Hidden = true; 387 } else { 388 op.MoveQualityParameter.Hidden = false; 389 } 377 390 } 378 391 } 379 392 private void ParameterizeAnalyzers() { 380 393 moveQualityAnalyzer.ResultsParameter.ActualName = "Results"; 394 moveQualityAnalyzer.ResultsParameter.Hidden = true; 381 395 if (Problem != null) { 382 396 moveQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 383 if (MoveEvaluator != null) 397 moveQualityAnalyzer.MaximizationParameter.Hidden = true; 398 if (MoveEvaluator != null) { 384 399 moveQualityAnalyzer.QualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName; 400 moveQualityAnalyzer.QualityParameter.Hidden = true; 401 } else moveQualityAnalyzer.QualityParameter.Hidden = false; 385 402 moveQualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name; 403 moveQualityAnalyzer.BestKnownQualityParameter.Hidden = true; 404 } else { 405 moveQualityAnalyzer.MaximizationParameter.Hidden = false; 406 moveQualityAnalyzer.BestKnownQualityParameter.Hidden = false; 386 407 } 387 408 } … … 390 411 foreach (IIterationBasedOperator op in Problem.Operators.OfType<IIterationBasedOperator>()) { 391 412 op.IterationsParameter.ActualName = "Iterations"; 413 op.IterationsParameter.Hidden = true; 392 414 op.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name; 415 op.MaximumIterationsParameter.Hidden = true; 393 416 } 394 417 } -
branches/histogram/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearchImprovementOperator.cs
r6046 r6055 200 200 ParameterizeLSMainLoop(); 201 201 ParameterizeAnalyzers(); 202 UpdateAnalyzers(); 202 203 } 203 204 … … 234 235 } 235 236 237 private bool IsSubclassOfGeneric(Type generic, Type toCheck) { 238 while (toCheck != typeof(object)) { 239 var cur = toCheck.IsGenericType ? toCheck.GetGenericTypeDefinition() : toCheck; 240 if (generic == cur) { 241 return true; 242 } 243 toCheck = toCheck.BaseType; 244 } 245 return false; 246 } 247 248 private void UpdateAnalyzers() { 249 Analyzer.Operators.Clear(); 250 if (problem != null) { 251 foreach (IAnalyzer analyzer in problem.Operators.OfType<IAnalyzer>()) { 252 if (!IsSubclassOfGeneric(typeof(AlleleFrequencyAnalyzer<>), analyzer.GetType()) && 253 !IsSubclassOfGeneric(typeof(PopulationDiversityAnalyzer<>), analyzer.GetType())) { 254 IAnalyzer clone = analyzer.Clone() as IAnalyzer; 255 foreach (IScopeTreeLookupParameter param in clone.Parameters.OfType<IScopeTreeLookupParameter>()) 256 param.Depth = 0; 257 Analyzer.Operators.Add(clone); 258 } 259 } 260 } 261 Analyzer.Operators.Add(qualityAnalyzer); 262 } 263 236 264 private void UpdateMoveOperators() { 237 265 IMoveGenerator oldMoveGenerator = MoveGenerator;
Note: See TracChangeset
for help on using the changeset viewer.