- Timestamp:
- 03/10/16 12:16:23 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.RandomSearch/3.3/RandomSearchAlgorithm.cs
r13679 r13680 66 66 get { return (IFixedValueParameter<IntValue>)Parameters["MaximumEvaluatedSolutions"]; } 67 67 } 68 private IFixedValueParameter<IntValue> SampleSizeParameter {69 get { return (IFixedValueParameter<IntValue>)Parameters[" SampleSize"]; }68 private IFixedValueParameter<IntValue> BatchSizeParameter { 69 get { return (IFixedValueParameter<IntValue>)Parameters["BatchSize"]; } 70 70 } 71 71 private IFixedValueParameter<IntValue> MaximumIterationsParameter { … … 93 93 set { MaximumEvaluatedSolutionsParameter.Value.Value = value; } 94 94 } 95 public int SampleSize {96 get { return SampleSizeParameter.Value.Value; }97 set { SampleSizeParameter.Value.Value = value; }95 public int BatchSize { 96 get { return BatchSizeParameter.Value.Value; } 97 set { BatchSizeParameter.Value.Value = value; } 98 98 } 99 99 public int MaximumIterations { … … 151 151 Parameters.Add(new FixedValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); 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 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>("MaximumEvaluatedSolutions", "The number of random s amples 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 });153 Parameters.Add(new FixedValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the solutions each iteration.", new MultiAnalyzer())); 154 Parameters.Add(new FixedValueParameter<IntValue>("MaximumEvaluatedSolutions", "The number of random solutions the algorithm should evaluate.", new IntValue(1000))); 155 Parameters.Add(new FixedValueParameter<IntValue>("BatchSize", "The number of random solutions that are evaluated (in parallel) per iteration.", new IntValue(100))); 156 Parameters.Add(new FixedValueParameter<IntValue>("MaximumIterations", "The number of 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 … … 166 166 var evaluationsCounter = new IntCounter() { Name = "Increment EvaluatedSolutions" }; 167 167 var subScopesRemover = new SubScopesRemover(); 168 var batchNumberCounter = new IntCounter() { Name = "Increment BatchNumber" };168 var iterationsCounter = new IntCounter() { Name = "Increment Iterations" }; 169 169 var terminationOperator = new TerminationOperator(); 170 170 #endregion … … 179 179 randomCreator.Successor = variableCreator; 180 180 181 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>(" BatchNumber", new IntValue(0)));181 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0))); 182 182 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0))); 183 183 variableCreator.Successor = resultsCollector; 184 184 185 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>(" BatchNumber", "The current batchnumber."));185 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Iterations", "The current iteration number.")); 186 186 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The current number of evaluated solutions.")); 187 187 resultsCollector.Successor = solutionCreator; 188 188 189 solutionCreator.NumberOfSolutionsParameter.ActualName = SampleSizeParameter.Name;189 solutionCreator.NumberOfSolutionsParameter.ActualName = BatchSizeParameter.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 = SampleSizeParameter.Name;195 evaluationsCounter.IncrementParameter.ActualName = BatchSizeParameter.Name; 196 196 evaluationsCounter.Successor = analyzerPlaceholder; 197 197 … … 200 200 201 201 subScopesRemover.RemoveAllSubScopes = true; 202 subScopesRemover.Successor = batchNumberCounter;203 204 batchNumberCounter.ValueParameter.ActualName = "BatchNumber";205 batchNumberCounter.Increment = new IntValue(1);206 batchNumberCounter.Successor = terminationOperator;202 subScopesRemover.Successor = iterationsCounter; 203 204 iterationsCounter.ValueParameter.ActualName = "Iterations"; 205 iterationsCounter.Increment = new IntValue(1); 206 iterationsCounter.Successor = terminationOperator; 207 207 208 208 terminationOperator.TerminatorParameter.ActualName = TerminatorParameter.Name; … … 313 313 314 314 MaximumEvaluatedSolutionsParameter.Value.ValueChanged += MaximumEvaluatedSolutions_ValueChanged; 315 SampleSizeParameter.Value.ValueChanged += SampleSize_ValueChanged; 316 MaximumIterationsParameter.Value.ValueChanged += MaximumIterations_ValueChanged; 315 BatchSizeParameter.Value.ValueChanged += BatchSize_ValueChanged; 317 316 } 318 317 private void ParameterizeSolutionsCreator() { … … 337 336 if (Problem != null) { 338 337 foreach (IIterationBasedOperator op in Problem.Operators.OfType<IIterationBasedOperator>()) { 339 op.IterationsParameter.ActualName = " BatchNumber";338 op.IterationsParameter.ActualName = "Iterations"; 340 339 op.IterationsParameter.Hidden = true; 341 340 op.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name; … … 355 354 } 356 355 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; 356 MaximumIterations = MaximumEvaluatedSolutions / BatchSize; 357 } 358 private void BatchSize_ValueChanged(object sender, EventArgs e) { 359 MaximumIterations = MaximumEvaluatedSolutions / BatchSize; 364 360 } 365 361 #endregion
Note: See TracChangeset
for help on using the changeset viewer.