Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/19/10 18:21:24 (15 years ago)
Author:
abeham
Message:

fixed TabuSelector #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

    r3104 r3132  
    162162      bestAverageWorstMoveQualityCalculator.QualityParameter.ActualName = "MoveQuality";
    163163      bestAverageWorstMoveQualityCalculator.WorstQualityParameter.ActualName = "Worst Move Quality";
    164 
    165       tabuSelector.NumberOfSelectedSubScopes = new IntValue(1);
    166164
    167165      moveMakingProcessor.Name = "MoveMaking processor (UniformSequentialSubScopesProcessor)";
  • trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSelector.cs

    r3100 r3132  
    6969      get { return (ILookupParameter<ItemArray<BoolValue>>)Parameters["MoveTabu"]; }
    7070    }
    71 
    72     public IntValue NumberOfSelectedSubScopes {
    73       set { NumberOfSelectedSubScopesParameter.Value = value; }
     71    public IValueLookupParameter<BoolValue> CopySelectedParameter {
     72      get { return (IValueLookupParameter<BoolValue>)Parameters["CopySelected"]; }
    7473    }
    7574
     
    8584      Parameters.Add(new SubScopesLookupParameter<DoubleValue>("MoveQuality", "The quality of the move."));
    8685      Parameters.Add(new SubScopesLookupParameter<BoolValue>("MoveTabu", "The tabu status of the move."));
     86      Parameters.Add(new ValueLookupParameter<BoolValue>("CopySelected", "True if the selected move should be copied."));
    8787    }
    8888
     
    9494    /// <returns>The selected scopes.</returns>
    9595    protected override IScope[] Select(List<IScope> scopes) {
    96       int count = NumberOfSelectedSubScopesParameter.ActualValue.Value;
    9796      bool copy = CopySelectedParameter.Value.Value;
    9897      bool aspiration = AspirationParameter.ActualValue.Value;
     
    102101      ItemArray<BoolValue> moveTabus = MoveTabuParameter.ActualValue;
    103102
    104       IScope[] selected = new IScope[count];
     103      IScope[] selected = new IScope[1];
    105104
    106105      // remember scopes that should be removed
    107106      List<int> scopesToRemove = new List<int>();
    108107      for (int i = 0; i < scopes.Count; i++) {
    109         if (count > 0 && (!moveTabus[i].Value
    110           || aspiration && IsBetter(maximization, moveQualities[i].Value, bestQuality))) {
     108        if (!moveTabus[i].Value
     109          || aspiration && IsBetter(maximization, moveQualities[i].Value, bestQuality)) {
    111110          scopesToRemove.Add(i);
    112           if (copy) selected[selected.Length - count] = (IScope)scopes[i].Clone();
    113           else selected[selected.Length - count] = scopes[i];
    114           count--;
    115           if (count == 0) break;
     111          if (copy) selected[0] = (IScope)scopes[i].Clone();
     112          else selected[0] = scopes[i];
     113          break;
    116114        }
    117115      }
    118116
    119       if (count > 0) throw new InvalidOperationException("TabuSelector: The neighborhood contained no or too little moves that are not tabu.");
     117      if (selected[0] == null) throw new InvalidOperationException("TabuSelector: The neighborhood contained no or too little moves that are not tabu.");
    120118
    121119      // remove from last to first so that the stored indices remain the same
Note: See TracChangeset for help on using the changeset viewer.