Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3104


Ignore:
Timestamp:
03/18/10 22:57:22 (15 years ago)
Author:
abeham
Message:

Fixed changing of MoveTabuParameter and added two different tabu criteria for a move: One prevents only readding deleted edges, the other prevents both readding deleted edges and deleting added edges. #840

Location:
trunk/sources
Files:
3 added
1 deleted
6 edited

Legend:

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

    r3100 r3104  
    180180        op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged);
    181181      }
     182      foreach (ITabuMoveEvaluator op in Problem.Operators.OfType<ITabuMoveEvaluator>()) {
     183        op.MoveTabuParameter.ActualNameChanged += new EventHandler(TabuMoveEvaluator_MoveTabuParameter_ActualNameChanged);
     184      }
    182185      ParameterizeSolutionsCreator();
    183       ParameterizeTSMainLoop();
     186      ParameterizeMainLoop();
    184187      ParameterizeMoveEvaluator();
    185188      ParameterizeMoveMaker();
     
    196199      ParameterizeStochasticOperator(Problem.Evaluator);
    197200      ParameterizeSolutionsCreator();
    198       ParameterizeTSMainLoop();
     201      ParameterizeMainLoop();
    199202      ParameterizeMoveEvaluator();
    200203      ParameterizeMoveMaker();
     
    210213        op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged);
    211214      }
     215      foreach (ITabuMoveEvaluator op in Problem.Operators.OfType<ITabuMoveEvaluator>()) {
     216        op.MoveTabuParameter.ActualNameChanged -= new EventHandler(TabuMoveEvaluator_MoveTabuParameter_ActualNameChanged);
     217        op.MoveTabuParameter.ActualNameChanged += new EventHandler(TabuMoveEvaluator_MoveTabuParameter_ActualNameChanged);
     218      }
    212219      IMoveGenerator oldMoveGenerator = MoveGenerator;
    213220      UpdateMoveGenerator();
    214221      if (oldMoveGenerator == MoveGenerator) // in this case MoveGeneratorParameter_ValueChanged did not fire
    215222        UpdateMoveParameters();
    216       ParameterizeTSMainLoop();
     223      ParameterizeMainLoop();
    217224      ParameterizeMoveEvaluator();
    218225      ParameterizeMoveMaker();
     
    220227    }
    221228    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
    222       ParameterizeTSMainLoop();
     229      ParameterizeMainLoop();
    223230      ParameterizeMoveEvaluator();
    224231      ParameterizeMoveMaker();
     
    228235    }
    229236    private void MoveEvaluatorParameter_ValueChanged(object sender, EventArgs e) {
    230       ParameterizeTSMainLoop();
     237      ParameterizeMainLoop();
    231238      ParameterizeMoveEvaluator();
    232239      ParameterizeMoveMaker();
    233240    }
    234241    private void MoveEvaluator_MoveQualityParameter_ActualNameChanged(object sender, EventArgs e) {
    235       ParameterizeTSMainLoop();
    236       ParameterizeMoveEvaluator();
    237       ParameterizeMoveMaker();
     242      ParameterizeMainLoop();
     243      ParameterizeMoveEvaluator();
     244      ParameterizeMoveMaker();
     245    }
     246    private void TabuMoveEvaluatorParameter_ValueChanged(object sender, EventArgs e) {
     247      ParameterizeMainLoop();
     248    }
     249    private void TabuMoveEvaluator_MoveTabuParameter_ActualNameChanged(object sender, EventArgs e) {
     250      ParameterizeMainLoop();
    238251    }
    239252    #endregion
     
    250263      MoveGeneratorParameter.ValueChanged += new EventHandler(MoveGeneratorParameter_ValueChanged);
    251264      MoveEvaluatorParameter.ValueChanged += new EventHandler(MoveEvaluatorParameter_ValueChanged);
     265      TabuMoveEvaluatorParameter.ValueChanged += new EventHandler(TabuMoveEvaluatorParameter_ValueChanged);
    252266    }
    253267    private void UpdateMoveGenerator() {
     
    313327      SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
    314328    }
    315     private void ParameterizeTSMainLoop() {
     329    private void ParameterizeMainLoop() {
    316330      MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
    317331      MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
    318332      if (MoveEvaluator != null)
    319333        MainLoop.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
     334      if (TabuMoveEvaluator != null)
     335        MainLoop.MoveTabuParameter.ActualName = TabuMoveEvaluator.MoveTabuParameter.ActualName;
    320336    }
    321337    private void ParameterizeStochasticOperator(IOperator op) {
  • trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearchMainLoop.cs

    r3100 r3104  
    4848      get { return (LookupParameter<DoubleValue>)Parameters["MoveQuality"]; }
    4949    }
     50    public LookupParameter<BoolValue> MoveTabuParameter {
     51      get { return (LookupParameter<BoolValue>)Parameters["MoveTabu"]; }
     52    }
    5053    public ValueLookupParameter<IntValue> MaximumIterationsParameter {
    5154      get { return (ValueLookupParameter<IntValue>)Parameters["MaximumIterations"]; }
     
    8891      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
    8992      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The value which represents the quality of a move."));
     93      Parameters.Add(new LookupParameter<BoolValue>("MoveTabu", "The value that indicates if a move is tabu or not."));
    9094      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed."));
    9195      Parameters.Add(new ValueLookupParameter<IntValue>("TabuTenure", "The length of the tabu list, and also means the number of iterations a move is kept tabu"));
  • trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/HeuristicLab.Encodings.PermutationEncoding-3.3.csproj

    r3098 r3104  
    111111    <Compile Include="Moves\ThreeOpt\ThreeOptMove.cs" />
    112112    <Compile Include="Moves\ThreeOpt\ThreeOptMoveGenerator.cs" />
     113    <Compile Include="Moves\TwoOpt\PreventReaddTwoOptTabuMoveEvaluator.cs" />
    113114    <Compile Include="Moves\TwoOpt\StochasticTwoOptSingleMoveGenerator.cs" />
    114115    <Compile Include="Moves\TwoOpt\ExhaustiveTwoOptMoveGenerator.cs">
     
    127128    </Compile>
    128129    <Compile Include="Moves\TwoOpt\TwoOptTabuMoveAttribute.cs" />
    129     <Compile Include="Moves\TwoOpt\TwoOptTabuMoveEvaluator.cs" />
     130    <Compile Include="Moves\TwoOpt\PreventReaddDeleteTwoOptTabuMoveEvaluator.cs" />
    130131    <Compile Include="Moves\TwoOpt\TwoOptTabuMoveMaker.cs" />
    131132    <Compile Include="PermutationManipulator.cs" />
  • trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/TwoOpt/TwoOptTabuMoveMaker.cs

    r3074 r3104  
    3131  [Item("TwoOptTabuMoveMaker", "Declares a given 2-opt 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 TwoOptTabuMoveMaker : SingleSuccessorOperator, ITwoOptPermutationMoveOperator, ITabuMoveMaker {
     33  public class TwoOptTabuMoveMaker : TabuMoveMaker, ITwoOptPermutationMoveOperator {
    3434    public ILookupParameter<Permutation> PermutationParameter {
    3535      get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
     
    3838      get { return (LookupParameter<TwoOptMove>)Parameters["TwoOptMove"]; }
    3939    }
    40     public LookupParameter<ItemList<IItem>> TabuListParameter {
    41       get { return (LookupParameter<ItemList<IItem>>)Parameters["TabuList"]; }
    42     }
    43     public ValueLookupParameter<IntValue> TabuTenureParameter {
    44       get { return (ValueLookupParameter<IntValue>)Parameters["TabuTenure"]; }
    45     }
    4640
    4741    public TwoOptTabuMoveMaker()
    4842      : base() {
    4943      Parameters.Add(new LookupParameter<TwoOptMove>("TwoOptMove", "The move that was made."));
    50       Parameters.Add(new LookupParameter<ItemList<IItem>>("TabuList", "The tabu list where move attributes are stored."));
    51       Parameters.Add(new ValueLookupParameter<IntValue>("TabuTenure", "The tenure of the tabu list."));
    5244      Parameters.Add(new LookupParameter<Permutation>("Permutation", "The solution as permutation."));
    5345    }
    5446
    55     public override IOperation Apply() {
    56       ItemList<IItem> tabuList = TabuListParameter.ActualValue;
     47    protected override IItem GetTabuAttribute() {
    5748      TwoOptMove move = TwoOptMoveParameter.ActualValue;
    58       IntValue tabuTenure = TabuTenureParameter.ActualValue;
    5949      Permutation permutation = PermutationParameter.ActualValue;
    60      
    61       if (tabuList.Count >= tabuTenure.Value) {
    62         for (int i = 0; i < tabuTenure.Value - 1; i++)
    63           tabuList[i] = tabuList[i + 1];
    64         tabuList.RemoveAt(tabuList.Count - 1);
    65       }
    66 
    67       TwoOptTabuMoveAttribute attribute = new TwoOptTabuMoveAttribute(
    68         permutation.GetCircular(move.Index1 - 1), permutation[move.Index1],
    69         permutation[move.Index2], permutation.GetCircular(move.Index2 + 1));
    70       tabuList.Add(attribute);
    71       return base.Apply();
     50      return new TwoOptTabuMoveAttribute( permutation.GetCircular(move.Index1 - 1),
     51        permutation[move.Index1],
     52        permutation[move.Index2],
     53        permutation.GetCircular(move.Index2 + 1));
    7254    }
    7355
  • trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r3098 r3104  
    112112    <Compile Include="Interfaces\ITabuMoveEvaluator.cs" />
    113113    <Compile Include="Interfaces\ITabuMoveMaker.cs" />
     114    <Compile Include="TabuMoveMaker.cs" />
    114115    <Compile Include="UserDefinedAlgorithm.cs" />
    115116    <Compile Include="EngineAlgorithm.cs" />
  • trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/ITabuMoveEvaluator.cs

    r3044 r3104  
    2121
    2222using HeuristicLab.Core;
     23using HeuristicLab.Data;
    2324
    2425namespace HeuristicLab.Optimization {
    2526  public interface ITabuMoveEvaluator : IOperator {
     27    ILookupParameter<BoolValue> MoveTabuParameter { get; }
    2628  }
    2729}
Note: See TracChangeset for help on using the changeset viewer.