Changeset 6052
- Timestamp:
- 04/26/11 11:41:52 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearchImprovementOperator.cs
r6044 r6052 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; -
trunk/sources/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealingImprovementOperator.cs
r6043 r6052 259 259 } 260 260 261 private bool IsSubclassOfGeneric(Type generic, Type toCheck) { 262 while (toCheck != typeof(object)) { 263 var cur = toCheck.IsGenericType ? toCheck.GetGenericTypeDefinition() : toCheck; 264 if (generic == cur) { 265 return true; 266 } 267 toCheck = toCheck.BaseType; 268 } 269 return false; 270 } 271 261 272 private void UpdateAnalyzers() { 262 273 Analyzer.Operators.Clear(); 263 274 if (problem != null) { 264 275 foreach (IAnalyzer analyzer in problem.Operators.OfType<IAnalyzer>()) { 265 IAnalyzer clone = analyzer.Clone() as IAnalyzer; 266 foreach (IScopeTreeLookupParameter param in clone.Parameters.OfType<IScopeTreeLookupParameter>()) 267 param.Depth = 0; 268 Analyzer.Operators.Add(clone); 276 if (!IsSubclassOfGeneric(typeof(AlleleFrequencyAnalyzer<>), analyzer.GetType()) && 277 !IsSubclassOfGeneric(typeof(PopulationDiversityAnalyzer<>), analyzer.GetType())) { 278 IAnalyzer clone = analyzer.Clone() as IAnalyzer; 279 foreach (IScopeTreeLookupParameter param in clone.Parameters.OfType<IScopeTreeLookupParameter>()) 280 param.Depth = 0; 281 Analyzer.Operators.Add(clone); 282 } 269 283 } 270 284 }
Note: See TracChangeset
for help on using the changeset viewer.