Changeset 7518


Ignore:
Timestamp:
02/24/12 13:07:15 (7 years ago)
Author:
mkommend
Message:

#1691: Updated VariableNeighborHoodSearch to use default operators for the shaking factor parameter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.VariableNeighborhoodSearch/3.3/VariableNeighborhoodSearch.cs

    r7259 r7518  
    302302    }
    303303    private void UpdateShakingOperators() {
     304      IMultiNeighborhoodShakingOperator oldShakingOperator = ShakingOperator;
     305      IMultiNeighborhoodShakingOperator defaultShakingOperator = Problem.Operators.OfType<IMultiNeighborhoodShakingOperator>().FirstOrDefault();
    304306      ShakingOperatorParameter.ValidValues.Clear();
    305       foreach (IMultiNeighborhoodShakingOperator op in Problem.Operators.OfType<IMultiNeighborhoodShakingOperator>()) {
     307      foreach (IMultiNeighborhoodShakingOperator op in Problem.Operators.OfType<IMultiNeighborhoodShakingOperator>().OrderBy(op => op.Name)) {
    306308        ShakingOperatorParameter.ValidValues.Add(op);
    307309        op.CurrentNeighborhoodIndexParameter.ActualName = "CurrentNeighborhoodIndex";
    308310        op.NeighborhoodCountParameter.ActualName = "NeighborhoodCount";
     311      }
     312      if (oldShakingOperator != null) {
     313        IMultiNeighborhoodShakingOperator shakingOperator = ShakingOperatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldShakingOperator.GetType());
     314        if (shakingOperator != null) ShakingOperator = shakingOperator;
     315        else oldShakingOperator = null;
     316      }
     317      if (oldShakingOperator == null && defaultShakingOperator != null) {
     318        ShakingOperator = defaultShakingOperator;
    309319      }
    310320    }
Note: See TracChangeset for help on using the changeset viewer.