Changeset 2997
- Timestamp:
- 03/11/10 02:23:25 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 14 added
- 3 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab 3.3/Files.txt
r2945 r2997 6 6 HeuristicLab.Algorithms.SGA\3.3:HeuristicLab.Algorithms.SGA-3.3.dll 7 7 HeuristicLab.Algorithms.SGA.Views\3.3:HeuristicLab.Algorithms.SGA.Views-3.3.dll 8 HeuristicLab.Algorithms.TS\3.3:HeuristicLab.Algorithms.TS-3.3.dll 8 9 HeuristicLab.Analysis\3.3:HeuristicLab.Analysis-3.3.dll 9 10 HeuristicLab.Analysis.Views\3.3:HeuristicLab.Analysis.Views-3.3.dll -
trunk/sources/HeuristicLab.Algorithms.TS/3.3/HeuristicLab.Algorithms.TS-3.3.csproj
r2981 r2997 83 83 <Compile Include="HeuristicLabAlgorithmsTSPlugin.cs" /> 84 84 <Compile Include="Properties\AssemblyInfo.cs" /> 85 <Compile Include="TabuSelector.cs" /> 86 <Compile Include="TSOperator.cs" /> 85 <Compile Include="TabuListCreator.cs"> 86 <SubType>Code</SubType> 87 </Compile> 88 <Compile Include="TabuSelector.cs"> 89 <SubType>Code</SubType> 90 </Compile> 91 <Compile Include="TSOperator.cs"> 92 <SubType>Code</SubType> 93 </Compile> 87 94 </ItemGroup> 88 95 <ItemGroup> -
trunk/sources/HeuristicLab.Algorithms.TS/3.3/TSOperator.cs
r2982 r2997 25 25 using HeuristicLab.Operators; 26 26 using HeuristicLab.Parameters; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Selection; 27 29 28 30 namespace HeuristicLab.Algorithms.TS { … … 31 33 /// </summary> 32 34 [Item("TSOperator", "An operator which represents a Tabu Search.")] 35 [StorableClass(StorableClassType.Empty)] 33 36 public class TSOperator : AlgorithmOperator { 34 37 #region Parameter properties … … 51 54 get { return (ValueLookupParameter<VariableCollection>)Parameters["Results"]; } 52 55 } 56 public ValueLookupParameter<IOperator> MoveGeneratorParameter { 57 get { return (ValueLookupParameter<IOperator>)Parameters["MoveGenerator"]; } 58 } 59 public ValueLookupParameter<IOperator> MoveQualityEvaluatorParameter { 60 get { return (ValueLookupParameter<IOperator>)Parameters["MoveQualityEvaluator"]; } 61 } 62 public ValueLookupParameter<IOperator> MoveTabuEvaluatorParameter { 63 get { return (ValueLookupParameter<IOperator>)Parameters["MoveTabuEvaluator"]; } 64 } 65 public ValueLookupParameter<IOperator> TabuSelectorParameter { 66 get { return (ValueLookupParameter<IOperator>)Parameters["TabuSelector"]; } 67 } 68 public ValueLookupParameter<IOperator> MoveTabuMakerParameter { 69 get { return (ValueLookupParameter<IOperator>)Parameters["MoveTabuMaker"]; } 70 } 71 public ValueLookupParameter<IOperator> MoveMakerParameter { 72 get { return (ValueLookupParameter<IOperator>)Parameters["MoveMaker"]; } 73 } 74 53 75 private ScopeParameter CurrentScopeParameter { 54 76 get { return (ScopeParameter)Parameters["CurrentScope"]; } 55 77 } 56 57 78 public IScope CurrentScope { 58 79 get { return CurrentScopeParameter.ActualValue; } … … 69 90 Parameters.Add(new ValueLookupParameter<IntData>("TabuTenure", "The length of the tabu list, and also means the number of iterations a move is kept tabu")); 70 91 Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored.")); 92 93 Parameters.Add(new ValueLookupParameter<IOperator>("MoveGenerator", "The operator that generates the moves.")); 94 Parameters.Add(new ValueLookupParameter<IOperator>("MoveQualityEvaluator", "The operator that evaluates the quality of a move.")); 95 Parameters.Add(new ValueLookupParameter<IOperator>("MoveTabuEvaluator", "The operator that evaluates whether a move is tabu.")); 96 TabuSelector tabuSelectorOp = new TabuSelector(); 97 tabuSelectorOp.NumberOfSelectedSubScopes = new IntData(1); 98 Parameters.Add(new ValueLookupParameter<IOperator>("TabuSelector", "The operator that selects among the moves the next best.", tabuSelectorOp)); 99 Parameters.Add(new ValueLookupParameter<IOperator>("MoveTabuMaker", "The operator that declares a move tabu.")); 100 Parameters.Add(new ValueLookupParameter<IOperator>("MoveMaker", "The operator that performs a move and updates the quality.")); 101 71 102 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the TS should be applied.")); 72 103 #endregion 73 104 74 105 #region Create operators 106 TabuListCreator tabuListCreator = new TabuListCreator(); 75 107 VariableCreator variableCreator = new VariableCreator(); 108 BestQualityMemorizer bestQualityMemorizer = new BestQualityMemorizer(); 76 109 ResultsCollector resultsCollector = new ResultsCollector(); 110 UniformSequentialSubScopesProcessor mainProcessor = new UniformSequentialSubScopesProcessor(); 77 111 Placeholder moveGenerator = new Placeholder(); 78 112 UniformSequentialSubScopesProcessor moveEvaluationProcessor = new UniformSequentialSubScopesProcessor(); … … 80 114 Placeholder moveTabuEvaluator = new Placeholder(); 81 115 SubScopesSorter moveQualitySorter = new SubScopesSorter(); 116 BestAverageWorstQualityCalculator bestAverageWorstMoveQualityCalculator = new BestAverageWorstQualityCalculator(); 82 117 Placeholder tabuSelector = new Placeholder(); 83 SequentialSubScopesProcessor moveMakingProcessor = new SequentialSubScopesProcessor();84 EmptyOperator emptyOp = new EmptyOperator();85 UniformSequentialSubScopesProcessor actualMoveMakingProcessor = new UniformSequentialSubScopesProcessor();118 RightReducer rightReducer = new RightReducer(); 119 UniformSequentialSubScopesProcessor moveMakingProcessor = new UniformSequentialSubScopesProcessor(); 120 Placeholder moveTabuMaker = new Placeholder(); 86 121 Placeholder moveMaker = new Placeholder(); 87 Placeholder moveTabuMaker = new Placeholder();122 DataTableValuesCollector valuesCollector = new DataTableValuesCollector(); 88 123 SubScopesRemover subScopesRemover = new SubScopesRemover(); 89 124 IntCounter iterationsCounter = new IntCounter(); … … 93 128 94 129 variableCreator.CollectedValues.Add(new ValueParameter<IntData>("Iterations", new IntData(0))); 95 variableCreator.CollectedValues.Add(new ValueParameter<DoubleData>("Best Quality", new DoubleData(0)));96 130 variableCreator.CollectedValues.Add(new ValueParameter<DoubleData>("Best Move Quality", new DoubleData(0))); 97 131 variableCreator.CollectedValues.Add(new ValueParameter<DoubleData>("Average Move Quality", new DoubleData(0))); 98 132 variableCreator.CollectedValues.Add(new ValueParameter<DoubleData>("Worst Move Quality", new DoubleData(0))); 99 variableCreator.CollectedValues.Add(new ValueParameter<DataTable>("Qualities", new DataTable("Qualities")));100 133 variableCreator.CollectedValues.Add(new ValueParameter<DataTable>("MoveQualities", new DataTable("MoveQualities"))); 101 134 102 135 resultsCollector.CollectedValues.Add(new LookupParameter<IntData>("Iterations")); 103 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleData>("Best Quality") );136 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleData>("Best Quality") { ActualName = "BestQuality" }); 104 137 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleData>("Best Move Quality")); 105 138 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleData>("Average Move Quality")); 106 139 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleData>("Worst Move Quality")); 107 resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Qualities"));108 140 resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("MoveQualities")); 109 141 resultsCollector.ResultsParameter.ActualName = "Results"; 110 142 143 mainProcessor.Name = "Solution processor (UniformSequentialSubScopesProcessor)"; 144 111 145 moveGenerator.Name = "MoveGenerator (placeholder)"; 112 146 moveGenerator.OperatorParameter.ActualName = "MoveGenerator"; … … 121 155 moveQualitySorter.ValueParameter.ActualName = "MoveQuality"; 122 156 157 bestAverageWorstMoveQualityCalculator.AverageQualityParameter.ActualName = "Average Move Quality"; 158 bestAverageWorstMoveQualityCalculator.BestQualityParameter.ActualName = "Best Move Quality"; 159 bestAverageWorstMoveQualityCalculator.MaximizationParameter.ActualName = "Maximization"; 160 bestAverageWorstMoveQualityCalculator.QualityParameter.ActualName = "MoveQuality"; 161 bestAverageWorstMoveQualityCalculator.WorstQualityParameter.ActualName = "Worst Move Quality"; 162 123 163 tabuSelector.Name = "TabuSelector (placeholder)"; 124 164 tabuSelector.OperatorParameter.ActualName = "TabuSelector"; 125 165 166 moveMakingProcessor.Name = "MoveMaking processor (UniformSequentialSubScopesProcessor)"; 167 168 moveTabuMaker.Name = "MoveTabuMaker (placeholder)"; 169 moveTabuMaker.OperatorParameter.ActualName = "MoveTabuMaker"; 170 126 171 moveMaker.Name = "MoveMaker (placeholder)"; 127 172 moveMaker.OperatorParameter.ActualName = "MoveMaker"; 128 173 129 moveTabuMaker.Name = "MoveTabuMaker (placeholder)"; 130 moveTabuMaker.OperatorParameter.ActualName = "MoveTabuMaker"; 174 valuesCollector.CollectedValues.Add(new LookupParameter<DoubleData>("Best Move Quality")); 175 valuesCollector.CollectedValues.Add(new LookupParameter<DoubleData>("Average Move Quality")); 176 valuesCollector.CollectedValues.Add(new LookupParameter<DoubleData>("Worst Move Quality")); 177 valuesCollector.DataTableParameter.ActualName = "MoveQualities"; 131 178 132 179 subScopesRemover.RemoveAllSubScopes = true; 133 180 181 iterationsCounter.Name = "Iterations Counter"; 134 182 iterationsCounter.Increment = new IntData(1); 135 iterationsCounter.IncrementParameter.ActualName = "Iterations"; 136 183 iterationsCounter.ValueParameter.ActualName = "Iterations"; 184 185 iterationsComparator.Name = "Iterations Comparator"; 137 186 iterationsComparator.Comparison = new ComparisonData(Comparison.Less); 138 187 iterationsComparator.LeftSideParameter.ActualName = "Iterations"; … … 140 189 iterationsComparator.ResultParameter.ActualName = "IterationsCondition"; 141 190 191 iterationsTermination.Name = "Iterations Termination Condition"; 142 192 iterationsTermination.ConditionParameter.ActualName = "IterationsCondition"; 143 193 #endregion 144 194 145 195 #region Create operator graph 146 OperatorGraph.InitialOperator = variableCreator; 147 variableCreator.Successor = resultsCollector; 148 resultsCollector.Successor = moveGenerator; 196 OperatorGraph.InitialOperator = tabuListCreator; 197 tabuListCreator.Successor = variableCreator; 198 variableCreator.Successor = bestQualityMemorizer; 199 bestQualityMemorizer.Successor = resultsCollector; 200 resultsCollector.Successor = mainProcessor; 201 mainProcessor.Operator = moveGenerator; 202 mainProcessor.Successor = valuesCollector; 149 203 moveGenerator.Successor = moveEvaluationProcessor; 150 204 moveEvaluationProcessor.Operator = moveQualityEvaluator; 205 moveEvaluationProcessor.Successor = moveQualitySorter; 151 206 moveQualityEvaluator.Successor = moveTabuEvaluator; 152 moveEvaluationProcessor.Successor = moveQualitySorter; 153 moveQualitySorter.Successor = tabuSelector; 154 tabuSelector.Successor = moveMakingProcessor; 155 moveMakingProcessor.Operators.AddRange(new Operator[] { emptyOp, actualMoveMakingProcessor }); 156 actualMoveMakingProcessor.Operator = moveTabuMaker; 207 moveQualitySorter.Successor = bestAverageWorstMoveQualityCalculator; 208 bestAverageWorstMoveQualityCalculator.Successor = tabuSelector; 209 tabuSelector.Successor = rightReducer; 210 rightReducer.Successor = moveMakingProcessor; 211 moveMakingProcessor.Operator = moveTabuMaker; 212 moveMakingProcessor.Successor = subScopesRemover; 157 213 moveTabuMaker.Successor = moveMaker; 158 moveMakingProcessor.Successor = subScopesRemover; 159 subScopesRemover.Successor = iterationsCounter; 214 valuesCollector.Successor = iterationsCounter; 160 215 iterationsCounter.Successor = iterationsComparator; 161 216 iterationsComparator.Successor = iterationsTermination; 162 iterationsTermination.TrueBranch = resultsCollector;217 iterationsTermination.TrueBranch = bestQualityMemorizer; 163 218 iterationsTermination.FalseBranch = finished; 164 219 #endregion -
trunk/sources/HeuristicLab.Algorithms.TS/3.3/TabuSelector.cs
r2994 r2997 40 40 public class TabuSelector : Selector { 41 41 /// <summary> 42 /// The quality of the current solution.43 /// </summary>44 public LookupParameter<DoubleData> QualityParameter {45 get { return (LookupParameter<DoubleData>)Parameters["Quality"]; }46 }47 /// <summary>48 42 /// The best found quality so far. 49 43 /// </summary> … … 76 70 } 77 71 72 public IntData NumberOfSelectedSubScopes { 73 set { NumberOfSelectedSubScopesParameter.Value = value; } 74 } 75 78 76 /// <summary> 79 77 /// Initializes a new intsance with 6 parameters (<c>Quality</c>, <c>BestQuality</c>, … … 82 80 public TabuSelector() 83 81 : base() { 84 Parameters.Add(new LookupParameter<DoubleData>("Quality", "The quality of the current solution."));85 82 Parameters.Add(new LookupParameter<DoubleData>("BestQuality", "The best found quality so far.")); 86 83 Parameters.Add(new ValueLookupParameter<BoolData>("Aspiration", "Whether the default aspiration criterion should be used or not. The default aspiration criterion accepts a tabu move if it results in a better solution than the best solution found so far.", new BoolData(true))); … … 101 98 bool maximization = MaximizationParameter.ActualValue.Value; 102 99 double bestQuality = BestQualityParameter.ActualValue.Value; 103 double quality = QualityParameter.ActualValue.Value;104 100 ItemArray<DoubleData> moveQualities = MoveQualityParameter.ActualValue; 105 101 ItemArray<BoolData> moveTabus = MoveTabuParameter.ActualValue; … … 110 106 List<int> scopesToRemove = new List<int>(); 111 107 for (int i = 0; i < scopes.Count; i++) { 112 if (count > 0 && (!moveTabus[i].Value || aspiration && 113 (maximization && moveQualities[i].Value + quality > bestQuality 114 || !maximization && moveQualities[i].Value + quality < bestQuality))) { 108 if (count > 0 && (!moveTabus[i].Value 109 || aspiration && IsBetter(maximization, moveQualities[i].Value, bestQuality))) { 115 110 scopesToRemove.Add(i); 116 111 if (copy) selected[selected.Length - count] = (IScope)scopes[i].Clone(); … … 133 128 return selected; 134 129 } 130 131 private bool IsBetter(bool maximization, double moveQuality, double bestQuality) { 132 return (maximization && moveQuality > bestQuality || !maximization && moveQuality < bestQuality); 133 } 135 134 } 136 135 } -
trunk/sources/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj
r2908 r2997 85 85 <None Include="HeuristicLabAnalysisPlugin.cs.frame" /> 86 86 <Compile Include="BestAverageWorstQualityCalculator.cs" /> 87 <Compile Include="BestQualityMemorizer.cs" /> 87 88 <Compile Include="DataRow.cs" /> 88 89 <Compile Include="HeuristicLabAnalysisPlugin.cs" /> -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/HeuristicLab.Encodings.Permutation-3.3.csproj
r2984 r2997 96 96 <Compile Include="Interfaces\IPermutationCrossover.cs" /> 97 97 <Compile Include="Interfaces\IPermutationManipulator.cs" /> 98 <Compile Include="Interfaces\IPermutationMoveGenerator.cs" /> 98 99 <Compile Include="Interfaces\IPermutationOperator.cs" /> 99 100 <Compile Include="Manipulators\InsertionManipulator.cs" /> … … 104 105 <Compile Include="Manipulators\TranslocationInversionManipulator.cs" /> 105 106 <Compile Include="Manipulators\TranslocationManipulator.cs" /> 106 <Compile Include="Moves\Permutation2IndexMove.cs" /> 107 <Compile Include="Moves\Permutation2OptExhaustiveMoveGenerator.cs" /> 108 <Compile Include="Moves\Permutation2OptMove.cs" /> 107 <Compile Include="Moves\ExhaustiveTwoOptMoveGenerator.cs"> 108 <SubType>Code</SubType> 109 </Compile> 110 <Compile Include="Moves\TwoIndexMove.cs"> 111 <SubType>Code</SubType> 112 </Compile> 113 <Compile Include="Moves\TwoOptMove.cs"> 114 <SubType>Code</SubType> 115 </Compile> 116 <Compile Include="Moves\TwoOptMoveMaker.cs"> 117 <SubType>Code</SubType> 118 </Compile> 119 <Compile Include="Moves\TwoOptMoveTabuAttribute.cs"> 120 <SubType>Code</SubType> 121 </Compile> 122 <Compile Include="Moves\TwoOptMoveTabuEvaluator.cs"> 123 <SubType>Code</SubType> 124 </Compile> 125 <Compile Include="Moves\TwoOptMoveTabuMaker.cs"> 126 <SubType>Code</SubType> 127 </Compile> 109 128 <Compile Include="PermutationManipulator.cs" /> 110 129 <Compile Include="PermutationCrossover.cs" /> -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Manipulators/InversionManipulator.cs
r2994 r2997 47 47 } while (breakPoint2 == breakPoint1); 48 48 if (breakPoint2 < breakPoint1) { int h = breakPoint1; breakPoint1 = breakPoint2; breakPoint2 = h; } 49 Apply(permutation, breakPoint1, breakPoint2); 50 } 49 51 52 public static void Apply(Permutation permutation, int breakPoint1, int breakPoint2) { 50 53 for (int i = 0; i <= (breakPoint2 - breakPoint1) / 2; i++) { // invert permutation between breakpoints 51 54 int temp = permutation[breakPoint1 + i]; -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Permutation.cs
r2994 r2997 85 85 } 86 86 87 public int GetCircular(int position) { 88 if (position >= Length) position = position % Length; 89 while (position < 0) position += Length; 90 return this[position]; 91 } 92 87 93 #region IStringConvertibleArrayData Members 88 94 int IStringConvertibleArrayData.Length { -
trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
r2900 r2997 86 86 <None Include="HeuristicLabOptimizationPlugin.cs.frame" /> 87 87 <Compile Include="Algorithm.cs" /> 88 <Compile Include="Interfaces\IMoveGenerator.cs" /> 88 89 <Compile Include="Interfaces\IMultiObjectiveSelector.cs" /> 89 90 <Compile Include="Interfaces\ISingleObjectiveSelector.cs" /> -
trunk/sources/HeuristicLab.Problems.TSP/3.3/HeuristicLab.Problems.TSP-3.3.csproj
r2988 r2997 93 93 <Compile Include="Interfaces\ITSPPathEvaluator.cs" /> 94 94 <Compile Include="HeuristicLabProblemsTSPPlugin.cs" /> 95 <Compile Include="MoveEvaluators\TwoOptMoveTSPEvaluator.cs"> 96 <SubType>Code</SubType> 97 </Compile> 95 98 <Compile Include="TSPLIBParser.cs" /> 96 99 <Compile Include="TSP.cs" />
Note: See TracChangeset
for help on using the changeset viewer.