Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3195


Ignore:
Timestamp:
03/23/10 01:48:44 (15 years ago)
Author:
abeham
Message:

fixed algorithm when neighborhood contains only tabu moves. It will now terminate correctly. #840

Location:
trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3
Files:
2 edited

Legend:

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

    r3193 r3195  
    131131      BestAverageWorstQualityCalculator bestAverageWorstMoveQualityCalculator = new BestAverageWorstQualityCalculator();
    132132      TabuSelector tabuSelector = new TabuSelector();
     133      ConditionalBranch emptyNeighborhoodBranch1 = new ConditionalBranch();
    133134      RightReducer rightReducer = new RightReducer();
    134135      UniformSubScopesProcessor moveMakingProcessor = new UniformSubScopesProcessor();
     
    136137      Placeholder moveMaker = new Placeholder();
    137138      DataTableValuesCollector valuesCollector = new DataTableValuesCollector();
    138       SubScopesRemover subScopesRemover = new SubScopesRemover();
     139      SubScopesRemover subScopesRemover1 = new SubScopesRemover();
     140      ConditionalBranch emptyNeighborhoodBranch2 = new ConditionalBranch();
     141      UniformSubScopesProcessor removeMoves = new UniformSubScopesProcessor();
     142      SubScopesRemover subScopesRemover2 = new SubScopesRemover();
    139143      IntCounter iterationsCounter = new IntCounter();
    140144      Comparator iterationsComparator = new Comparator();
     
    150154      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("Worst Move Quality", new DoubleValue(0)));
    151155      variableCreator.CollectedValues.Add(new ValueParameter<DataTable>("MoveQualities", new DataTable("MoveQualities")));
     156      variableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("EmptyNeighborhood", new BoolValue(false)));
    152157
    153158      bestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality";
     
    206211      moveMakingProcessor.Name = "MoveMaking processor (UniformSubScopesProcessor)";
    207212
     213      emptyNeighborhoodBranch1.Name = "Neighborhood empty?";
     214      emptyNeighborhoodBranch1.ConditionParameter.ActualName = "EmptyNeighborhood";
     215
    208216      tabuMoveMaker.Name = "TabuMoveMaker (placeholder)";
    209217      tabuMoveMaker.OperatorParameter.ActualName = TabuMoveMakerParameter.Name;
     
    212220      moveMaker.OperatorParameter.ActualName = MoveMakerParameter.Name;
    213221
    214       subScopesRemover.RemoveAllSubScopes = true;
     222      subScopesRemover1.RemoveAllSubScopes = true;
     223
     224      emptyNeighborhoodBranch2.Name = "Neighborhood empty?";
     225      emptyNeighborhoodBranch2.ConditionParameter.ActualName = "EmptyNeighborhood";
     226
     227      subScopesRemover2.RemoveAllSubScopes = true;
    215228
    216229      iterationsCounter.Name = "Iterations Counter";
     
    254267      resultsCollector.Successor = mainProcessor;
    255268      mainProcessor.Operator = moveGenerator;
    256       mainProcessor.Successor = iterationsCounter;
     269      mainProcessor.Successor = emptyNeighborhoodBranch2;
    257270      moveGenerator.Successor = moveEvaluationProcessor;
    258271      moveEvaluationProcessor.Operator = moveEvaluator;
     
    263276      bestAverageWorstMoveQualityCalculator.Successor = valuesCollector;
    264277      valuesCollector.Successor = tabuSelector;
    265       tabuSelector.Successor = rightReducer;
     278      tabuSelector.Successor = emptyNeighborhoodBranch1;
     279      emptyNeighborhoodBranch1.FalseBranch = rightReducer;
     280      emptyNeighborhoodBranch1.TrueBranch = null;
     281      emptyNeighborhoodBranch1.Successor = null;
    266282      rightReducer.Successor = moveMakingProcessor;
    267283      moveMakingProcessor.Operator = tabuMoveMaker;
    268       moveMakingProcessor.Successor = subScopesRemover;
     284      moveMakingProcessor.Successor = subScopesRemover1;
    269285      tabuMoveMaker.Successor = moveMaker;
    270286      moveMaker.Successor = null;
    271       subScopesRemover.Successor = null;
     287      subScopesRemover1.Successor = null;
     288      emptyNeighborhoodBranch2.FalseBranch = iterationsCounter;
     289      emptyNeighborhoodBranch2.TrueBranch = removeMoves;
     290      emptyNeighborhoodBranch2.Successor = null;
     291      removeMoves.Operator = subScopesRemover2;
     292      removeMoves.Successor = null;
     293      subScopesRemover2.Successor = null;
    272294      iterationsCounter.Successor = iterationsComparator;
    273295      iterationsComparator.Successor = bestQualityMemorizer3;
  • trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSelector.cs

    r3140 r3195  
    7272      get { return (IValueLookupParameter<BoolValue>)Parameters["CopySelected"]; }
    7373    }
     74    public ILookupParameter<BoolValue> EmptyNeighborhoodParameter {
     75      get { return (ILookupParameter<BoolValue>)Parameters["EmptyNeighborhood"]; }
     76    }
    7477
    7578    public BoolValue CopySelected {
     
    9093      Parameters.Add(new SubScopesLookupParameter<BoolValue>("MoveTabu", "The tabu status of the move."));
    9194      Parameters.Add(new ValueLookupParameter<BoolValue>("CopySelected", "True if the selected move should be copied.", new BoolValue(false)));
     95      Parameters.Add(new LookupParameter<BoolValue>("EmptyNeighborhood", "Will be set to true if the neighborhood didn't contain any non-tabu moves. It is not set to false."));
    9296    }
    9397
     
    120124      }
    121125
    122       if (selected[0] == null) throw new InvalidOperationException("TabuSelector: The neighborhood contained no or too little moves that are not tabu.");
     126      if (selected[0] == null) {
     127        EmptyNeighborhoodParameter.ActualValue = new BoolValue(true);
     128        selected[0] = new Scope("All moves are tabu.");
     129      }
    123130
    124131      // remove from last to first so that the stored indices remain the same
Note: See TracChangeset for help on using the changeset viewer.