Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/22/11 14:54:17 (12 years ago)
Author:
abeham
Message:

#1541

  • Fixed permutation view and changed label
  • Fixed problem in the RTS operator when all moves are tabu (the original code continues when all moves are tabu, so this is also the case here)
  • Changed the Analyzer parameter type in RTS, a FixedValueParameter is not appropriate for operator parameters
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSeachOperator.cs

    r6628 r7040  
    3131namespace HeuristicLab.Problems.QuadraticAssignment.Algorithms {
    3232  [Item("RobustTabooSearchOperator", "Performs an iteration of the robust taboo search algorithm as descrbied in Taillard 1991.")]
     33  [StorableClass]
    3334  public sealed class RobustTabooSeachOperator : SingleSuccessorOperator, IIterationBasedOperator, IStochasticOperator {
    3435
     
    8586    public IValueLookupParameter<IntValue> AlternativeAspirationTenureParameter {
    8687      get { return (IValueLookupParameter<IntValue>)Parameters["AlternativeAspirationTenure"]; }
     88    }
     89
     90    private ILookupParameter<BoolValue> AllMovesTabuParameter {
     91      get { return (ILookupParameter<BoolValue>)Parameters["AllMovesTabu"]; }
    8792    }
    8893    #endregion
     
    111116      Parameters.Add(new ValueLookupParameter<BoolValue>("UseAlternativeAspiration", "True if the alternative aspiration condition should be used that takes moves that have not been made for some time above others."));
    112117      Parameters.Add(new ValueLookupParameter<IntValue>("AlternativeAspirationTenure", "The time t that a move will be remembered for the alternative aspiration condition."));
     118      Parameters.Add(new LookupParameter<BoolValue>("AllMovesTabu", "Indicates that all moves are tabu."));
    113119    }
    114120
    115121    public override IDeepCloneable Clone(Cloner cloner) {
    116122      return new RobustTabooSeachOperator(this, cloner);
     123    }
     124
     125    [StorableHook(HookType.AfterDeserialization)]
     126    private void AfterDeserialization() {
     127      // BackwardsCompatibility3.3
     128      #region Backwards compatible code, remove with 3.4
     129      if (!Parameters.ContainsKey("AllMovesTabu")) {
     130        Parameters.Add(new LookupParameter<BoolValue>("AllMovesTabu", "Indicates that all moves are tabu."));
     131      }
     132      #endregion
    117133    }
    118134
     
    131147        bestQuality = BestQualityParameter.ActualValue;
    132148      }
     149      bool allMovesTabu = false;
     150      if (AllMovesTabuParameter.ActualValue == null)
     151        AllMovesTabuParameter.ActualValue = new BoolValue(false);
     152      else allMovesTabu = AllMovesTabuParameter.ActualValue.Value;
    133153
    134154      int minTenure = MinimumTabuTenureParameter.ActualValue.Value;
     
    147167        if (lastMove == null)
    148168          moveQuality = QAPSwap2MoveEvaluator.Apply(solution, move, weights, distances);
     169        else if (allMovesTabu) moveQuality = moveQualityMatrix[move.Index1, move.Index2];
    149170        else moveQuality = QAPSwap2MoveEvaluator.Apply(solution, move, moveQualityMatrix[move.Index1, move.Index2], weights, distances, lastMove);
    150171
     
    180201      }
    181202
    182       LastMoveParameter.ActualValue = bestMove;
    183 
    184       if (bestMove == null) return base.Apply();
     203      allMovesTabu = bestMove == null;
     204      if (!allMovesTabu)
     205        LastMoveParameter.ActualValue = bestMove;
     206      AllMovesTabuParameter.ActualValue.Value = allMovesTabu;
     207
     208      if (allMovesTabu) return base.Apply();
    185209
    186210      bool useNewAdaptionScheme = UseNewTabuTenureAdaptionSchemeParameter.ActualValue.Value;
Note: See TracChangeset for help on using the changeset viewer.