Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/14/10 03:52:07 (15 years ago)
Author:
abeham
Message:

Updated Tabu search, permutation move operators, real vector move operators, binary vector move operators #840
Added a Tabu Search TSP workbench

Location:
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3
Files:
1 added
1 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/HeuristicLab.Encodings.BinaryVectorEncoding-3.3.csproj

    r3118 r3340  
    106106    <Compile Include="Moves\OneBitflipMove\OneBitflipMoveGenerator.cs" />
    107107    <Compile Include="Moves\OneBitflipMove\OneBitflipMoveMaker.cs" />
    108     <Compile Include="Moves\OneBitflipMove\OneBitflipTabuMoveMaker.cs" />
    109     <Compile Include="Moves\OneBitflipMove\PreventOneBitflipTabuMoveEvaluator.cs" />
     108    <Compile Include="Moves\OneBitflipMove\OneBitflipMoveTabuChecker.cs" />
     109    <Compile Include="Moves\OneBitflipMove\OneBitflipMoveTabuMaker.cs" />
     110    <Compile Include="Moves\OneBitflipMove\OneBitflipMoveAttribute.cs" />
    110111    <Compile Include="Moves\OneBitflipMove\StochasticOneBitflipMultiMoveGenerator.cs" />
    111112    <Compile Include="Moves\OneBitflipMove\StochasticOneBitflipSingleMoveGenerator.cs" />
  • trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Moves/OneBitflipMove/OneBitflipMoveTabuChecker.cs

    r3339 r3340  
    2929
    3030namespace HeuristicLab.Encodings.BinaryVectorEncoding {
    31   [Item("PreventOneBitflipTabuMoveEvaluator", "Prevents peforming a one bitflip move again.")]
     31  [Item("OneBitflipMoveTabuChecker", "Prevents peforming a one bitflip move again.")]
    3232  [StorableClass]
    33   public class PreventOneBitflipTabuMoveEvaluator : SingleSuccessorOperator, IOneBitflipMoveOperator, ITabuChecker {
     33  public class OneBitflipMoveTabuChecker : SingleSuccessorOperator, IOneBitflipMoveOperator, ITabuChecker {
    3434    public ILookupParameter<OneBitflipMove> OneBitflipMoveParameter {
    3535      get { return (LookupParameter<OneBitflipMove>)Parameters["OneBitflipMove"]; }
     
    4444      get { return (ILookupParameter<BoolValue>)Parameters["MoveTabu"]; }
    4545    }
    46     private ScopeParameter CurrentScopeParameter {
    47       get { return (ScopeParameter)Parameters["CurrentScope"]; }
     46    public IValueLookupParameter<BoolValue> MaximizationParameter {
     47      get { return (IValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
     48    }
     49    public ILookupParameter<DoubleValue> MoveQualityParameter {
     50      get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; }
     51    }
     52    public ValueParameter<BoolValue> UseAspirationCriterionParameter {
     53      get { return (ValueParameter<BoolValue>)Parameters["UseAspirationCriterion"]; }
    4854    }
    4955
    50     public PreventOneBitflipTabuMoveEvaluator()
     56    public BoolValue UseAspirationCriterion {
     57      get { return UseAspirationCriterionParameter.Value; }
     58      set { UseAspirationCriterionParameter.Value = value; }
     59    }
     60
     61    public OneBitflipMoveTabuChecker()
    5162      : base() {
    5263      Parameters.Add(new LookupParameter<OneBitflipMove>("OneBitflipMove", "The move to evaluate."));
     
    5465      Parameters.Add(new LookupParameter<BinaryVector>("BinaryVector", "The solution as permutation."));
    5566      Parameters.Add(new LookupParameter<ItemList<IItem>>("TabuList", "The tabu list."));
    56       Parameters.Add(new ScopeParameter("CurrentScope", "The current scope."));
     67      Parameters.Add(new ValueParameter<BoolValue>("UseAspirationCriterion", "Whether to use the aspiration criterion or not.", new BoolValue(true)));
     68      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, else if it is a minimization problem."));
     69      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The quality of the current move."));
    5770    }
    5871
     
    6073      ItemList<IItem> tabuList = TabuListParameter.ActualValue;
    6174      OneBitflipMove move = OneBitflipMoveParameter.ActualValue;
     75      double moveQuality = MoveQualityParameter.ActualValue.Value;
     76      bool maximization = MaximizationParameter.ActualValue.Value;
     77      bool useAspiration = UseAspirationCriterion.Value;
    6278      bool isTabu = false;
    6379      foreach (IItem tabuMove in tabuList) {
    64         OneBitflipMove attribute = (tabuMove as OneBitflipMove);
     80        OneBitflipMoveAttribute attribute = (tabuMove as OneBitflipMoveAttribute);
    6581        if (attribute != null) {
    66           if (attribute.Index == move.Index) {
    67             isTabu = true;
    68             break;
     82          if (!useAspiration
     83            || maximization && moveQuality <= attribute.MoveQuality
     84            || !maximization && moveQuality >= attribute.MoveQuality) {
     85            if (attribute.Index == move.Index) {
     86              isTabu = true;
     87              break;
     88            }
    6989          }
    7090        }
  • trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Moves/OneBitflipMove/OneBitflipMoveTabuMaker.cs

    r3339 r3340  
    2929
    3030namespace HeuristicLab.Encodings.BinaryVectorEncoding {
    31   [Item("OneBitflipTabuMoveMaker", "Declares a given one bitflip move as tabu, by adding its attributes to the tabu list. It also removes the oldest entry in the tabu list when its size is greater than tenure.")]
     31  [Item("OneBitflipMoveTabuMaker", "Declares a given one bitflip move as tabu, by adding its attributes to the tabu list. It also removes the oldest entry in the tabu list when its size is greater than tenure.")]
    3232  [StorableClass]
    33   public class OneBitflipTabuMoveMaker : TabuMaker, IOneBitflipMoveOperator {
     33  public class OneBitflipMoveTabuMaker : TabuMaker, IOneBitflipMoveOperator {
    3434    public ILookupParameter<BinaryVector> BinaryVectorParameter {
    3535      get { return (ILookupParameter<BinaryVector>)Parameters["BinaryVector"]; }
     
    3939    }
    4040
    41     public OneBitflipTabuMoveMaker()
     41    public OneBitflipMoveTabuMaker()
    4242      : base() {
    4343      Parameters.Add(new LookupParameter<BinaryVector>("BinaryVector", "The solution as BinaryVector."));
     
    4545    }
    4646
    47     protected override IItem GetTabuAttribute() {
    48       return OneBitflipMoveParameter.ActualValue;
     47    protected override IItem GetTabuAttribute(bool maximization, double quality, double moveQuality) {
     48      double baseQuality = moveQuality;
     49      if (maximization && quality > moveQuality || !maximization && quality < moveQuality) baseQuality = quality;
     50      return new OneBitflipMoveAttribute(OneBitflipMoveParameter.ActualValue.Index, baseQuality);
    4951    }
    5052
Note: See TracChangeset for help on using the changeset viewer.