Changeset 3131 for trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3
- Timestamp:
- 03/19/10 18:20:30 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearch.cs
r3104 r3131 284 284 ITabuMoveMaker oldTabuMoveMaker = TabuMoveMaker; 285 285 ClearMoveParameters(); 286 List<Type> moveTypes = MoveGenerator.GetType().GetInterfaces().Where(x => typeof(IMoveOperator).IsAssignableFrom(x)).ToList(); 287 foreach (Type type in moveTypes.ToList()) { 288 if (moveTypes.Any(t => t != type && type.IsAssignableFrom(t))) 289 moveTypes.Remove(type); 290 } 291 foreach (Type type in moveTypes) { 292 var operators = Problem.Operators.Where(x => type.IsAssignableFrom(x.GetType())).OrderBy(x => x.Name); 293 foreach (IMoveMaker moveMaker in operators.OfType<IMoveMaker>()) 294 MoveMakerParameter.ValidValues.Add(moveMaker); 295 foreach (ISingleObjectiveMoveEvaluator moveEvaluator in operators.OfType<ISingleObjectiveMoveEvaluator>()) 296 MoveEvaluatorParameter.ValidValues.Add(moveEvaluator); 297 foreach (ITabuMoveEvaluator tabuMoveEvaluator in operators.OfType<ITabuMoveEvaluator>()) 298 TabuMoveEvaluatorParameter.ValidValues.Add(tabuMoveEvaluator); 299 foreach (ITabuMoveMaker tabuMoveMaker in operators.OfType<ITabuMoveMaker>()) 300 TabuMoveMakerParameter.ValidValues.Add(tabuMoveMaker); 301 } 302 if (oldMoveMaker != null) { 303 IMoveMaker mm = MoveMakerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveMaker.GetType()); 304 if (mm != null) MoveMaker = mm; 305 } 306 if (oldMoveEvaluator != null) { 307 ISingleObjectiveMoveEvaluator me = MoveEvaluatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveEvaluator.GetType()); 308 if (me != null) MoveEvaluator = me; 309 } 310 if (oldTabuMoveMaker != null) { 311 ITabuMoveMaker tmm = TabuMoveMakerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldTabuMoveMaker.GetType()); 312 if (tmm != null) TabuMoveMaker = tmm; 313 } 314 if (oldTabuMoveEvaluator != null) { 315 ITabuMoveEvaluator tme = TabuMoveEvaluatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldTabuMoveEvaluator.GetType()); 316 if (tme != null) TabuMoveEvaluator = tme; 286 if (MoveGenerator != null) { 287 List<Type> moveTypes = MoveGenerator.GetType().GetInterfaces().Where(x => typeof(IMoveOperator).IsAssignableFrom(x)).ToList(); 288 foreach (Type type in moveTypes.ToList()) { 289 if (moveTypes.Any(t => t != type && type.IsAssignableFrom(t))) 290 moveTypes.Remove(type); 291 } 292 foreach (Type type in moveTypes) { 293 var operators = Problem.Operators.Where(x => type.IsAssignableFrom(x.GetType())).OrderBy(x => x.Name); 294 foreach (IMoveMaker moveMaker in operators.OfType<IMoveMaker>()) 295 MoveMakerParameter.ValidValues.Add(moveMaker); 296 foreach (ISingleObjectiveMoveEvaluator moveEvaluator in operators.OfType<ISingleObjectiveMoveEvaluator>()) 297 MoveEvaluatorParameter.ValidValues.Add(moveEvaluator); 298 foreach (ITabuMoveEvaluator tabuMoveEvaluator in operators.OfType<ITabuMoveEvaluator>()) 299 TabuMoveEvaluatorParameter.ValidValues.Add(tabuMoveEvaluator); 300 foreach (ITabuMoveMaker tabuMoveMaker in operators.OfType<ITabuMoveMaker>()) 301 TabuMoveMakerParameter.ValidValues.Add(tabuMoveMaker); 302 } 303 if (oldMoveMaker != null) { 304 IMoveMaker mm = MoveMakerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveMaker.GetType()); 305 if (mm != null) MoveMaker = mm; 306 } 307 if (oldMoveEvaluator != null) { 308 ISingleObjectiveMoveEvaluator me = MoveEvaluatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveEvaluator.GetType()); 309 if (me != null) MoveEvaluator = me; 310 } 311 if (oldTabuMoveMaker != null) { 312 ITabuMoveMaker tmm = TabuMoveMakerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldTabuMoveMaker.GetType()); 313 if (tmm != null) TabuMoveMaker = tmm; 314 } 315 if (oldTabuMoveEvaluator != null) { 316 ITabuMoveEvaluator tme = TabuMoveEvaluatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldTabuMoveEvaluator.GetType()); 317 if (tme != null) TabuMoveEvaluator = tme; 318 } 317 319 } 318 320 }
Note: See TracChangeset
for help on using the changeset viewer.