Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/28/12 15:47:26 (13 years ago)
Author:
spimming
Message:

#1680: merged changes from trunk into branch

Location:
branches/HeuristicLab.Hive.Azure
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive.Azure

  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearch.cs

    r7270 r7669  
    289289    private void UpdateMoveGenerator() {
    290290      IMoveGenerator oldMoveGenerator = MoveGenerator;
     291      IMoveGenerator defaultMoveGenerator = Problem.Operators.OfType<IMoveGenerator>().FirstOrDefault();
    291292      MoveGeneratorParameter.ValidValues.Clear();
    292293      if (Problem != null) {
     
    297298        IMoveGenerator newMoveGenerator = MoveGeneratorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveGenerator.GetType());
    298299        if (newMoveGenerator != null) MoveGenerator = newMoveGenerator;
    299       }
     300        else oldMoveGenerator = null;
     301      }
     302      if (oldMoveGenerator == null && defaultMoveGenerator != null)
     303        MoveGenerator = defaultMoveGenerator;
    300304      if (MoveGenerator == null) {
    301305        ClearMoveParameters();
     
    312316            moveTypes.Remove(type);
    313317        }
    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
    321327        if (oldMoveMaker != null) {
    322328          IMoveMaker mm = MoveMakerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveMaker.GetType());
    323329          if (mm != null) MoveMaker = mm;
    324         }
     330          else oldMoveMaker = null;
     331        }
     332        if (oldMoveMaker == null && defaultMoveMaker != null)
     333          MoveMaker = defaultMoveMaker;
     334
    325335        if (oldMoveEvaluator != null) {
    326336          ISingleObjectiveMoveEvaluator me = MoveEvaluatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveEvaluator.GetType());
    327337          if (me != null) MoveEvaluator = me;
    328         }
     338          else oldMoveEvaluator = null;
     339        }
     340        if (oldMoveEvaluator == null && defaultMoveEvaluator != null)
     341          MoveEvaluator = defaultMoveEvaluator;
    329342      }
    330343    }
Note: See TracChangeset for help on using the changeset viewer.