Changeset 3094
- Timestamp:
- 03/18/10 02:03:30 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab 3.3/Files.txt
r3081 r3094 8 8 HeuristicLab.Algorithms.TS\3.3:HeuristicLab.Algorithms.TS-3.3.dll 9 9 HeuristicLab.Algorithms.LS\3.3:HeuristicLab.Algorithms.LS-3.3.dll 10 HeuristicLab.Algorithms.SimulatedAnnealing\3.3:HeuristicLab.Algorithms.SimulatedAnnealing-3.3.dll 10 11 HeuristicLab.Analysis\3.3:HeuristicLab.Analysis-3.3.dll 11 12 HeuristicLab.Analysis.Views\3.3:HeuristicLab.Analysis.Views-3.3.dll -
trunk/sources/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealingMainLoop.cs
r3093 r3094 95 95 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution.")); 96 96 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The value which represents the quality of a move.")); 97 Parameters.Add(new LookupParameter<DoubleValue>("StartTemperature", "The initial temperature."));98 Parameters.Add(new LookupParameter<DoubleValue>("EndTemperature", "The end temperature."));97 Parameters.Add(new ValueLookupParameter<DoubleValue>("StartTemperature", "The initial temperature.")); 98 Parameters.Add(new ValueLookupParameter<DoubleValue>("EndTemperature", "The end temperature.")); 99 99 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum number of iterations which should be processed.")); 100 100 Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored.")); … … 109 109 110 110 #region Create operators 111 VariableCreator variableCreator = new VariableCreator(); 112 BestQualityMemorizer initializeBestQuality = new BestQualityMemorizer(); 113 SequentialSubScopesProcessor sssp = new SequentialSubScopesProcessor(); 114 ResultsCollector resultsCollector = new ResultsCollector(); 115 BestQualityMemorizer bestQualityMemorizer = new BestQualityMemorizer(); 116 Placeholder annealingOperator = new Placeholder(); 117 UniformSequentialSubScopesProcessor mainProcessor = new UniformSequentialSubScopesProcessor(); 118 Placeholder moveGenerator = new Placeholder(); 119 SequentialSubScopesProcessor moveEvaluationProcessor = new SequentialSubScopesProcessor(); 120 Placeholder moveEvaluator = new Placeholder(); 121 ProbabilisticQualityComparator qualityComparator = new ProbabilisticQualityComparator(); 122 ConditionalBranch improvesQualityBranch = new ConditionalBranch(); 123 Placeholder moveMaker = new Placeholder(); 124 SubScopesRemover subScopesRemover = new SubScopesRemover(); 125 DataTableValuesCollector valuesCollector = new DataTableValuesCollector(); 126 IntCounter iterationsCounter = new IntCounter(); 127 Comparator iterationsComparator = new Comparator(); 128 ConditionalBranch iterationsTermination = new ConditionalBranch(); 129 EmptyOperator finished = new EmptyOperator(); 130 131 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0))); 132 variableCreator.CollectedValues.Add(new ValueParameter<DataTable>("Qualities", new DataTable("Qualities"))); 133 variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("Temperature", new DoubleValue(double.MaxValue))); 134 135 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Iterations")); 136 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Quality")); 137 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality") { ActualName = "BestQuality" }); 138 resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Qualities")); 139 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Temperature")); 140 141 annealingOperator.Name = "Annealing operator (placeholder)"; 142 annealingOperator.OperatorParameter.ActualName = "AnnealingOperator"; 143 144 moveGenerator.Name = "Move generator (placeholder)"; 145 moveGenerator.OperatorParameter.ActualName = "MoveGenerator"; 146 147 moveEvaluator.Name = "Move evaluator (placeholder)"; 148 moveEvaluator.OperatorParameter.ActualName = "MoveEvaluator"; 149 150 qualityComparator.LeftSideParameter.ActualName = "MoveQuality"; 151 qualityComparator.RightSideParameter.ActualName = "Quality"; 152 qualityComparator.ResultParameter.ActualName = "IsBetter"; 153 qualityComparator.DampeningParameter.ActualName = "Temperature"; 154 155 improvesQualityBranch.ConditionParameter.ActualName = "IsBetter"; 156 157 moveMaker.Name = "Move maker (placeholder)"; 158 moveMaker.OperatorParameter.ActualName = "MoveMaker"; 159 160 subScopesRemover.RemoveAllSubScopes = true; 161 162 valuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Quality")); 163 valuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("BestQuality")); 164 valuesCollector.DataTableParameter.ActualName = "Qualities"; 165 166 iterationsCounter.Name = "Increment Iterations"; 167 iterationsCounter.Increment = new IntValue(1); 168 iterationsCounter.ValueParameter.ActualName = "Iterations"; 169 170 iterationsComparator.Name = "Iterations >= MaximumIterations"; 171 iterationsComparator.LeftSideParameter.ActualName = "Iterations"; 172 iterationsComparator.RightSideParameter.ActualName = "MaximumIterations"; 173 iterationsComparator.ResultParameter.ActualName = "IterationsCondition"; 174 iterationsComparator.Comparison.Value = ComparisonType.GreaterOrEqual; 175 176 iterationsTermination.Name = "Iterations termination condition"; 177 iterationsTermination.ConditionParameter.ActualName = "IterationsCondition"; 178 179 finished.Name = "Finished"; 111 180 #endregion 112 181 113 182 #region Create operator graph 183 OperatorGraph.InitialOperator = variableCreator; 184 variableCreator.Successor = initializeBestQuality; 185 initializeBestQuality.Successor = sssp; 186 sssp.Operators.Add(resultsCollector); 187 sssp.Successor = bestQualityMemorizer; 188 bestQualityMemorizer.Successor = annealingOperator; 189 annealingOperator.Successor = mainProcessor; 190 mainProcessor.Operator = moveGenerator; 191 mainProcessor.Successor = valuesCollector; 192 moveGenerator.Successor = moveEvaluationProcessor; 193 moveEvaluationProcessor.Operators.Add(moveEvaluator); 194 moveEvaluationProcessor.Successor = subScopesRemover; 195 moveEvaluator.Successor = qualityComparator; 196 qualityComparator.Successor = improvesQualityBranch; 197 improvesQualityBranch.TrueBranch = moveMaker; 198 valuesCollector.Successor = iterationsCounter; 199 iterationsCounter.Successor = iterationsComparator; 200 iterationsComparator.Successor = iterationsTermination; 201 iterationsTermination.TrueBranch = finished; 202 iterationsTermination.FalseBranch = bestQualityMemorizer; 114 203 #endregion 115 204 } -
trunk/sources/HeuristicLab.Optimization.Operators/3.3/ExponentialDiscreteDoubleValueModifier.cs
r3093 r3094 31 31 [StorableClass] 32 32 public class ExponentialDiscreteDoubleValueModifier : DiscreteDoubleValueModifier { 33 /// <summary> 34 /// Calculates a new value based on exponential decay or growth. 35 /// </summary> 36 /// <exception cref="ArgumentException">Thrown when endValue or startValue or both are 0.</exception> 37 /// <param name="value">The last value.</param> 38 /// <param name="startValue">The start value.</param> 39 /// <param name="endValue">The end value.</param> 40 /// <param name="index">The current index.</param> 41 /// <param name="startIndex">The start index.</param> 42 /// <param name="endIndex">The end index.</param> 43 /// <returns>The new value.</returns> 33 44 protected override double Modify(double value, double startValue, double endValue, int index, int startIndex, int endIndex) { 45 if (endValue <= 0 || startValue <= 0) throw new ArgumentException("ExponentialDiscreteDoubleValueModifier: startValue and endValue must be greater than 0."); 34 46 double b = Math.Pow(endValue / startValue, 1.0 / (endIndex - startIndex)); 35 47 return startValue * Math.Pow(b, index - startIndex); -
trunk/sources/HeuristicLab.Optimization.Operators/3.3/HeuristicLab.Optimization.Operators-3.3.csproj
r3093 r3094 81 81 </ItemGroup> 82 82 <ItemGroup> 83 <Compile Include="ProbabilisticQualityComparator.cs" /> 83 84 <Compile Include="SquareRootDiscreteDoubleValueModifier.cs" /> 84 85 <Compile Include="DiscreteDoubleValueModifier.cs" /> -
trunk/sources/HeuristicLab.Optimization.Operators/3.3/QualityComparator.cs
r3078 r3094 56 56 DoubleValue right = RightSideParameter.ActualValue; 57 57 BoolValue maximization = MaximizationParameter.ActualValue; 58 bool better = maximization.Value && left.Value > right.Value 59 || !maximization.Value && left.Value < right.Value; 58 bool better = Compare(maximization.Value, left.Value, right.Value); 60 59 if (ResultParameter.ActualValue == null) 61 60 ResultParameter.ActualValue = new BoolValue(better); … … 63 62 return base.Apply(); 64 63 } 64 65 protected virtual bool Compare(bool maximization, double left, double right) { 66 return maximization && left > right || !maximization && left < right; 67 } 65 68 } 66 69 }
Note: See TracChangeset
for help on using the changeset viewer.