Changeset 13677
- Timestamp:
- 03/10/16 09:50:32 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.RandomSearch/3.3/RandomSearchAlgorithm.cs
r13580 r13677 35 35 36 36 namespace HeuristicLab.Algorithms.RandomSearch { 37 [Item("Random Search Algorithm ", "An random search algorithm.")]37 [Item("Random Search Algorithm (RS)", "An random search algorithm.")] 38 38 [Creatable(CreatableAttribute.Categories.Algorithms, Priority = 150)] 39 39 [StorableClass] … … 63 63 get { return (IFixedValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; } 64 64 } 65 private IFixedValueParameter<IntValue> NumberOfSamplesParameter {66 get { return (IFixedValueParameter<IntValue>)Parameters[" NumberOfSamples"]; }67 } 68 private IFixedValueParameter<IntValue> BatchSizeParameter {69 get { return (IFixedValueParameter<IntValue>)Parameters[" BatchSize"]; }70 } 71 private IFixedValueParameter<IntValue> NumberOfBatchesParameter {72 get { return (IFixedValueParameter<IntValue>)Parameters[" NumberOfBatches"]; }65 private IFixedValueParameter<IntValue> MaximumEvaluatedSolutionsParameter { 66 get { return (IFixedValueParameter<IntValue>)Parameters["MaximumEvaluatedSolutions"]; } 67 } 68 private IFixedValueParameter<IntValue> SampleSizeParameter { 69 get { return (IFixedValueParameter<IntValue>)Parameters["SampleSize"]; } 70 } 71 private IFixedValueParameter<IntValue> MaximumIterationsParameter { 72 get { return (IFixedValueParameter<IntValue>)Parameters["MaximumIterations"]; } 73 73 } 74 74 private IFixedValueParameter<MultiTerminator> TerminatorParameter { … … 89 89 get { return AnalyzerParameter.Value; } 90 90 } 91 public int NumberOfSamples {92 get { return NumberOfSamplesParameter.Value.Value; }93 set { NumberOfSamplesParameter.Value.Value = value; }94 } 95 public int BatchSize {96 get { return BatchSizeParameter.Value.Value; }97 set { BatchSizeParameter.Value.Value = value; }98 } 99 public int NumberOfBatches {100 get { return NumberOfBatchesParameter.Value.Value; }101 set { NumberOfBatchesParameter.Value.Value = value; }91 public int MaximumEvaluatedSolutions { 92 get { return MaximumEvaluatedSolutionsParameter.Value.Value; } 93 set { MaximumEvaluatedSolutionsParameter.Value.Value = value; } 94 } 95 public int SampleSize { 96 get { return SampleSizeParameter.Value.Value; } 97 set { SampleSizeParameter.Value.Value = value; } 98 } 99 public int MaximumIterations { 100 get { return MaximumIterationsParameter.Value.Value; } 101 set { MaximumIterationsParameter.Value.Value = value; } 102 102 } 103 103 public MultiTerminator Terminators { … … 152 152 Parameters.Add(new FixedValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); 153 153 Parameters.Add(new FixedValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze all individuals from all layers combined.", new MultiAnalyzer())); 154 Parameters.Add(new FixedValueParameter<IntValue>(" NumberOfSamples", "The number of random samples the algorithm should evaluate.", new IntValue(1000)));155 Parameters.Add(new FixedValueParameter<IntValue>(" BatchSize", "The number of random samples that are evaluated (in parallel) until they are analyzed.", new IntValue(100)));156 Parameters.Add(new FixedValueParameter<IntValue>(" NumberOfBatches", "The number batch runs (iterations)that the algorithm will run.", new IntValue(10)) { Hidden = true });154 Parameters.Add(new FixedValueParameter<IntValue>("MaximumEvaluatedSolutions", "The number of random samples the algorithm should evaluate.", new IntValue(1000))); 155 Parameters.Add(new FixedValueParameter<IntValue>("SampleSize", "The number of random samples that are evaluated (in parallel) per iteration.", new IntValue(100))); 156 Parameters.Add(new FixedValueParameter<IntValue>("MaximumIterations", "The number iterations that the algorithm will run.", new IntValue(10)) { Hidden = true }); 157 157 Parameters.Add(new FixedValueParameter<MultiTerminator>("Terminator", "The termination criteria that defines if the algorithm should continue or stop.", new MultiTerminator()) { Hidden = true }); 158 158 #endregion … … 187 187 resultsCollector.Successor = solutionCreator; 188 188 189 solutionCreator.NumberOfSolutionsParameter.ActualName = BatchSizeParameter.Name;189 solutionCreator.NumberOfSolutionsParameter.ActualName = SampleSizeParameter.Name; 190 190 solutionCreator.ParallelParameter.Value.Value = true; 191 191 solutionCreator.Successor = evaluationsCounter; … … 193 193 evaluationsCounter.ValueParameter.ActualName = "EvaluatedSolutions"; 194 194 evaluationsCounter.Increment = null; 195 evaluationsCounter.IncrementParameter.ActualName = BatchSizeParameter.Name;195 evaluationsCounter.IncrementParameter.ActualName = SampleSizeParameter.Name; 196 196 evaluationsCounter.Successor = analyzerPlaceholder; 197 197 … … 215 215 216 216 #region Create terminators 217 evaluationsTerminator = new ComparisonTerminator<IntValue>("EvaluatedSolutions", ComparisonType.Less, NumberOfSamplesParameter) { Name = "Number of Samples" };217 evaluationsTerminator = new ComparisonTerminator<IntValue>("EvaluatedSolutions", ComparisonType.Less, MaximumEvaluatedSolutionsParameter) { Name = "Evaluated solutions." }; 218 218 qualityTerminator = new SingleObjectiveQualityTerminator() { Name = "Quality" }; 219 219 executionTimeTerminator = new ExecutionTimeTerminator(this, new TimeSpanValue(TimeSpan.FromMinutes(5))); … … 312 312 singleObjectiveQualityAnalyzer.CurrentBestQualityParameter.NameChanged += QualityAnalyzer_CurrentBestQualityParameter_NameChanged; 313 313 314 NumberOfSamplesParameter.Value.ValueChanged += NumberOfSamples_ValueChanged;315 BatchSizeParameter.Value.ValueChanged += BatchSize_ValueChanged;316 NumberOfBatchesParameter.Value.ValueChanged += NumberOfBatches_ValueChanged;314 MaximumEvaluatedSolutionsParameter.Value.ValueChanged += MaximumEvaluatedSolutions_ValueChanged; 315 SampleSizeParameter.Value.ValueChanged += SampleSize_ValueChanged; 316 MaximumIterationsParameter.Value.ValueChanged += MaximumIterations_ValueChanged; 317 317 } 318 318 private void ParameterizeSolutionsCreator() { … … 339 339 op.IterationsParameter.ActualName = "BatchNumber"; 340 340 op.IterationsParameter.Hidden = true; 341 op.MaximumIterationsParameter.ActualName = NumberOfBatchesParameter.Name;341 op.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name; 342 342 } 343 343 } … … 354 354 } 355 355 } 356 private void NumberOfSamples_ValueChanged(object sender, EventArgs e) {357 NumberOfBatches = NumberOfSamples / BatchSize;358 } 359 private void BatchSize_ValueChanged(object sender, EventArgs e) {360 NumberOfBatches = NumberOfSamples / BatchSize;361 } 362 private void NumberOfBatches_ValueChanged(object sender, EventArgs e) {363 BatchSize = NumberOfSamples / NumberOfBatches;356 private void MaximumEvaluatedSolutions_ValueChanged(object sender, EventArgs e) { 357 MaximumIterations = MaximumEvaluatedSolutions / SampleSize; 358 } 359 private void SampleSize_ValueChanged(object sender, EventArgs e) { 360 MaximumIterations = MaximumEvaluatedSolutions / SampleSize; 361 } 362 private void MaximumIterations_ValueChanged(object sender, EventArgs e) { 363 SampleSize = MaximumEvaluatedSolutions / MaximumIterations; 364 364 } 365 365 #endregion
Note: See TracChangeset
for help on using the changeset viewer.