Changeset 3426
- Timestamp:
- 04/20/10 00:13:43 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs
r3413 r3426 89 89 get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorUpperBound"]; } 90 90 } 91 private ConstrainedValueParameter<IDiscreteDoubleValueModifier> ComparisonFactorModifierParameter {92 get { return ( ConstrainedValueParameter<IDiscreteDoubleValueModifier>)Parameters["ComparisonFactorModifier"]; }91 private OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier> ComparisonFactorModifierParameter { 92 get { return (OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>)Parameters["ComparisonFactorModifier"]; } 93 93 } 94 94 private ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter { … … 193 193 Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start).", new DoubleValue(0))); 194 194 Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorUpperBound", "The upper bound of the comparison factor (end).", new DoubleValue(1))); 195 Parameters.Add(new ConstrainedValueParameter<IDiscreteDoubleValueModifier>("ComparisonFactorModifier", "The operator used to modify the comparison factor."));195 Parameters.Add(new OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>("ComparisonFactorModifier", "The operator used to modify the comparison factor.", new ItemSet<IDiscreteDoubleValueModifier>(new IDiscreteDoubleValueModifier[] { new LinearDiscreteDoubleValueModifier() }), new LinearDiscreteDoubleValueModifier())); 196 196 Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.", new DoubleValue(100))); 197 197 Parameters.Add(new ValueLookupParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation.", new BoolValue(false))); … … 386 386 private void UpdateComparisonFactorModifiers() { 387 387 IDiscreteDoubleValueModifier oldModifier = ComparisonFactorModifier; 388 if (oldModifier == null) oldModifier = new LinearDiscreteDoubleValueModifier();389 388 390 389 ComparisonFactorModifierParameter.ValidValues.Clear(); 391 390 foreach (IDiscreteDoubleValueModifier modifier in comparisonFactorModifiers) 392 391 ComparisonFactorModifierParameter.ValidValues.Add(modifier); 393 394 IDiscreteDoubleValueModifier mod = ComparisonFactorModifierParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldModifier.GetType()); 395 if (mod != null) ComparisonFactorModifierParameter.Value = mod; 392 393 if (oldModifier != null) { 394 IDiscreteDoubleValueModifier mod = ComparisonFactorModifierParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldModifier.GetType()); 395 if (mod != null) ComparisonFactorModifierParameter.Value = mod; 396 } 396 397 } 397 398 private void UpdateCrossovers() { -
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithmMainLoop.cs
r3413 r3426 152 152 ConditionalBranch osBeforeMutationBranch = new ConditionalBranch(); 153 153 Placeholder evaluator1 = new Placeholder(); 154 IntCounter evaluationCounter1 = new IntCounter(); 154 155 WeightedParentsQualityComparator qualityComparer1 = new WeightedParentsQualityComparator(); 155 156 StochasticBranch mutationBranch1 = new StochasticBranch(); 156 157 Placeholder mutator1 = new Placeholder(); 157 158 Placeholder evaluator2 = new Placeholder(); 159 IntCounter evaluationCounter2 = new IntCounter(); 158 160 StochasticBranch mutationBranch2 = new StochasticBranch(); 159 161 Placeholder mutator2 = new Placeholder(); 160 162 Placeholder evaluator3 = new Placeholder(); 163 IntCounter evaluationCounter3 = new IntCounter(); 161 164 WeightedParentsQualityComparator qualityComparer2 = new WeightedParentsQualityComparator(); 162 165 SubScopesRemover subScopesRemover = new SubScopesRemover(); … … 171 174 Comparator comparator1 = new Comparator(); 172 175 Comparator comparator2 = new Comparator(); 176 Assigner evaluatedSolutionsAssigner = new Assigner(); 177 ResultsCollector evalSolCollector = new ResultsCollector(); 173 178 BestQualityMemorizer bestQualityMemorizer3 = new BestQualityMemorizer(); 174 179 BestQualityMemorizer bestQualityMemorizer4 = new BestQualityMemorizer(); … … 184 189 variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0))); 185 190 variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("CurrentSuccessRatio", new DoubleValue(0))); 191 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0))); 192 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutionsResult", new IntValue(0))); 186 193 187 194 variableAssigner.LeftSideParameter.ActualName = "ComparisonFactor"; … … 222 229 223 230 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations")); 231 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutionsResult")); 224 232 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality")); 225 233 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality")); … … 250 258 evaluator1.OperatorParameter.ActualName = EvaluatorParameter.Name; 251 259 260 evaluationCounter1.Name = "EvaluatedSolutions++"; 261 evaluationCounter1.Increment = new IntValue(1); 262 evaluationCounter1.ValueParameter.ActualName = "EvaluatedSolutions"; 263 252 264 qualityComparer1.ComparisonFactorParameter.ActualName = "ComparisonFactor"; 253 265 qualityComparer1.LeftSideParameter.ActualName = QualityParameter.Name; … … 265 277 evaluator2.OperatorParameter.ActualName = EvaluatorParameter.Name; 266 278 279 evaluationCounter2.Name = "EvaluatedSolutions++"; 280 evaluationCounter2.Increment = new IntValue(1); 281 evaluationCounter2.ValueParameter.ActualName = "EvaluatedSolutions"; 282 267 283 mutationBranch2.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name; 268 284 mutationBranch2.RandomParameter.ActualName = RandomParameter.Name; … … 273 289 evaluator3.Name = "Evaluator (placeholder)"; 274 290 evaluator3.OperatorParameter.ActualName = EvaluatorParameter.Name; 291 292 evaluationCounter3.Name = "EvaluatedSolutions++"; 293 evaluationCounter3.Increment = new IntValue(1); 294 evaluationCounter3.ValueParameter.ActualName = "EvaluatedSolutions"; 275 295 276 296 qualityComparer2.ComparisonFactorParameter.ActualName = "ComparisonFactor"; … … 313 333 comparator2.ResultParameter.ActualName = "TerminateSelectionPressure"; 314 334 comparator2.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name; 335 336 evaluatedSolutionsAssigner.LeftSideParameter.ActualName = "EvaluatedSolutionsResult"; 337 evaluatedSolutionsAssigner.RightSideParameter.ActualName = "EvaluatedSolutions"; 338 339 evalSolCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutionsResult")); 340 evalSolCollector.ResultsParameter.ActualName = ResultsParameter.Name; 315 341 316 342 bestQualityMemorizer3.BestQualityParameter.ActualName = "BestQuality"; … … 377 403 osBeforeMutationBranch.FalseBranch = mutationBranch2; 378 404 osBeforeMutationBranch.Successor = subScopesRemover; 379 evaluator1.Successor = qualityComparer1; 405 evaluator1.Successor = evaluationCounter1; 406 evaluationCounter1.Successor = qualityComparer1; 380 407 qualityComparer1.Successor = mutationBranch1; 381 408 mutationBranch1.FirstBranch = mutator1; … … 383 410 mutationBranch1.Successor = null; 384 411 mutator1.Successor = evaluator2; 385 evaluator2.Successor = null; 412 evaluator2.Successor = evaluationCounter2; 413 evaluationCounter2.Successor = null; 386 414 mutationBranch2.FirstBranch = mutator2; 387 415 mutationBranch2.SecondBranch = null; 388 416 mutationBranch2.Successor = evaluator3; 389 417 mutator2.Successor = null; 390 evaluator3.Successor = qualityComparer2; 418 evaluator3.Successor = evaluationCounter3; 419 evaluationCounter3.Successor = qualityComparer2; 391 420 subScopesRemover.Successor = null; 392 421 offspringSelector.OffspringCreator = selector; … … 401 430 comparisonFactorModifier.Successor = comparator1; 402 431 comparator1.Successor = comparator2; 403 comparator2.Successor = bestQualityMemorizer3; 432 comparator2.Successor = evaluatedSolutionsAssigner; 433 evaluatedSolutionsAssigner.Successor = evalSolCollector; 434 evalSolCollector.Successor = bestQualityMemorizer3; 404 435 bestQualityMemorizer3.Successor = bestQualityMemorizer4; 405 436 bestQualityMemorizer4.Successor = bestAverageWorstQualityCalculator2;
Note: See TracChangeset
for help on using the changeset viewer.