Changeset 7510
- Timestamp:
- 02/24/12 09:04:07 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearch.cs
r7259 r7510 289 289 private void UpdateMoveGenerator() { 290 290 IMoveGenerator oldMoveGenerator = MoveGenerator; 291 IMoveGenerator defaultMoveGenerator = Problem.Operators.OfType<IMoveGenerator>().FirstOrDefault(); 291 292 MoveGeneratorParameter.ValidValues.Clear(); 292 293 if (Problem != null) { … … 297 298 IMoveGenerator newMoveGenerator = MoveGeneratorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveGenerator.GetType()); 298 299 if (newMoveGenerator != null) MoveGenerator = newMoveGenerator; 299 } 300 else oldMoveGenerator = null; 301 } 302 if (oldMoveGenerator == null && defaultMoveGenerator != null) 303 MoveGenerator = defaultMoveGenerator; 300 304 if (MoveGenerator == null) { 301 305 ClearMoveParameters(); … … 312 316 moveTypes.Remove(type); 313 317 } 314 foreach (Type type in moveTypes) { 315 var operators = Problem.Operators.Where(x => type.IsAssignableFrom(x.GetType())).OrderBy(x => x.Name); 316 foreach (IMoveMaker moveMaker in operators.OfType<IMoveMaker>()) 317 MoveMakerParameter.ValidValues.Add(moveMaker); 318 foreach (ISingleObjectiveMoveEvaluator moveEvaluator in operators.OfType<ISingleObjectiveMoveEvaluator>()) 319 MoveEvaluatorParameter.ValidValues.Add(moveEvaluator); 320 } 318 319 var operators = Problem.Operators.Where(op => moveTypes.Any(m => m.IsInstanceOfType(op))).ToList(); 320 IMoveMaker defaultMoveMaker = operators.OfType<IMoveMaker>().FirstOrDefault(); 321 ISingleObjectiveMoveEvaluator defaultMoveEvaluator = operators.OfType<ISingleObjectiveMoveEvaluator>().FirstOrDefault(); 322 foreach (IMoveMaker moveMaker in operators.OfType<IMoveMaker>().OrderBy(op => op.Name)) 323 MoveMakerParameter.ValidValues.Add(moveMaker); 324 foreach (ISingleObjectiveMoveEvaluator moveEvaluator in operators.OfType<ISingleObjectiveMoveEvaluator>().OrderBy(op => op.Name)) 325 MoveEvaluatorParameter.ValidValues.Add(moveEvaluator); 326 321 327 if (oldMoveMaker != null) { 322 328 IMoveMaker mm = MoveMakerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveMaker.GetType()); 323 329 if (mm != null) MoveMaker = mm; 324 } 330 else oldMoveMaker = null; 331 } 332 if (oldMoveMaker == null && defaultMoveMaker != null) 333 MoveMaker = defaultMoveMaker; 334 325 335 if (oldMoveEvaluator != null) { 326 336 ISingleObjectiveMoveEvaluator me = MoveEvaluatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveEvaluator.GetType()); 327 337 if (me != null) MoveEvaluator = me; 328 } 338 else oldMoveEvaluator = null; 339 } 340 if (oldMoveEvaluator == null && defaultMoveEvaluator != null) 341 MoveEvaluator = defaultMoveEvaluator; 329 342 } 330 343 }
Note: See TracChangeset
for help on using the changeset viewer.