Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/28/11 13:47:28 (13 years ago)
Author:
sforsten
Message:

#1669: branch has been merged with the trunk in revision 7081 and methods in RegressionBenchmark have been renamed.

Location:
branches/RegressionBenchmarks
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/RegressionBenchmarks

  • branches/RegressionBenchmarks/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSeachOperator.cs

    r6628 r7085  
    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;
  • branches/RegressionBenchmarks/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSearch.cs

    r6953 r7085  
    5151
    5252    #region Parameter Properties
    53     public FixedValueParameter<MultiAnalyzer> AnalyzerParameter {
    54       get { return (FixedValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
     53    public IValueParameter<MultiAnalyzer> AnalyzerParameter {
     54      get { return (IValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
    5555    }
    5656    public FixedValueParameter<IntValue> SeedParameter {
     
    7777    public FixedValueParameter<BoolValue> UseNewTabuTenureAdaptionSchemeParameter {
    7878      get { return (FixedValueParameter<BoolValue>)Parameters["UseNewTabuTenureAdaptionScheme"]; }
     79    }
     80    public FixedValueParameter<BoolValue> TerminateOnOptimalSolutionParameter {
     81      get { return (FixedValueParameter<BoolValue>)Parameters["TerminateOnOptimalSolution"]; }
    7982    }
    8083    #endregion
     
    112115      get { return UseNewTabuTenureAdaptionSchemeParameter.Value.Value; }
    113116      set { UseNewTabuTenureAdaptionSchemeParameter.Value.Value = value; }
     117    }
     118    public bool TerminateOnOptimalSolution {
     119      get { return TerminateOnOptimalSolutionParameter.Value.Value; }
     120      set { TerminateOnOptimalSolutionParameter.Value.Value = value; }
    114121    }
    115122    #endregion
     
    132139    }
    133140    public RobustTabooSearch() {
    134       Parameters.Add(new FixedValueParameter<MultiAnalyzer>("Analyzer", "The analyzers that are applied after each iteration.", new MultiAnalyzer()));
     141      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The analyzers that are applied after each iteration.", new MultiAnalyzer()));
    135142      Parameters.Add(new FixedValueParameter<IntValue>("Seed", "The seed value of the random number generator.", new IntValue(0)));
    136143      Parameters.Add(new FixedValueParameter<BoolValue>("SetSeedRandomly", "True whether the seed should be set randomly for each run, false if it should be fixed.", new BoolValue(true)));
     
    140147      Parameters.Add(new FixedValueParameter<BoolValue>("UseAlternativeAspiration", "True if the alternative aspiration condition should be used that takes moves that have not been made for some time above others.", new BoolValue(false)));
    141148      Parameters.Add(new FixedValueParameter<IntValue>("AlternativeAspirationTenure", "The time t that a move will be remembered for the alternative aspiration condition.", new IntValue(int.MaxValue)));
    142       Parameters.Add(new FixedValueParameter<BoolValue>("TerminateOnOptimalSolution", "True when the algorithm should stop if it reached a quality equal or smaller to the BestKnownQuality.", new BoolValue(true)));
     149      Parameters.Add(new FixedValueParameter<BoolValue>("TerminateOnOptimalSolution", "True when the algorithm should stop if it reached a quality equal or smaller to the BestKnownQuality.", new BoolValue(false)));
    143150      Parameters.Add(new FixedValueParameter<BoolValue>("UseNewTabuTenureAdaptionScheme", @"In an updated version of his implementation, Eric Taillard introduced a different way to change the tabu tenure.
    144151Instead of setting it uniformly between min and max, it will be set between 0 and max according to a right-skewed distribution.
    145152Set this option to false if you want to optimize using the earlier 1991 version, and set to true if you want to optimize using the newer version.
    146153Please note that the MinimumTabuTenure parameter has no effect in the new version.", new BoolValue(true)));
     154
     155      TerminateOnOptimalSolutionParameter.Hidden = true;
    147156
    148157      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
     
    298307    [StorableHook(HookType.AfterDeserialization)]
    299308    private void AfterDeserialization() {
     309      // BackwardsCompatibility3.3
     310      #region Backwards compatible code, remove with 3.4
     311      if (Parameters["Analyzer"] is FixedValueParameter<MultiAnalyzer>) {
     312        MultiAnalyzer analyzer = AnalyzerParameter.Value;
     313        Parameters.Remove("Analyzer");
     314        Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The analyzers that are applied after each iteration.", analyzer));
     315      }
     316      #endregion
    300317      RegisterEventHandlers();
    301318    }
Note: See TracChangeset for help on using the changeset viewer.