Changeset 1091 for trunk/sources/HeuristicLab.ES/ES.cs
- Timestamp:
- 01/08/09 10:19:30 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ES/ES.cs
r896 r1091 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-200 8Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2009 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 48 48 49 49 CombinedOperator co = CreateES(); 50 co.Name = " ES";50 co.Name = "σSA-ES"; 51 51 engine.OperatorGraph.AddOperator(co); 52 52 engine.OperatorGraph.InitialOperator = co; … … 134 134 vi.AddVariable(new Variable("Generations", new IntData())); 135 135 vi.AddVariable(new Variable("MaximumGenerations", new IntData(1000))); 136 vi.AddVariable(new Variable("GeneralLearningRate", new DoubleData(0.1))); 136 137 vi.AddVariable(new Variable("LearningRate", new DoubleData(0.1))); 137 vi.AddVariable(new Variable("DampeningFactor", new DoubleData(10.0)));138 vi.AddVariable(new Variable("ShakingFactor", new DoubleData(5.0)));139 vi.AddVariable(new Variable("TargetSuccessProbability", new DoubleData(0.2)));140 vi.AddVariable(new Variable("SuccessProbability", new DoubleData(0.2)));141 vi.AddVariable(new Variable("UseSuccessRule", new BoolData(true)));142 138 op.OperatorGraph.AddOperator(vi); 143 139 sp.AddSubOperator(vi); … … 180 176 op.OperatorGraph.AddOperator(c); 181 177 sp2.AddSubOperator(c); 178 179 VariableInjector vi = new VariableInjector(); 180 vi.AddVariable(new Variable("ShakingFactors", new DoubleArrayData(new double[] { 5.0 }))); 181 op.OperatorGraph.AddOperator(vi); 182 sp2.AddSubOperator(vi); 182 183 183 184 Sorter s = new Sorter(); … … 285 286 op.OperatorGraph.InitialOperator = sp1; 286 287 287 ConditionalBranch cb = new ConditionalBranch();288 cb.GetVariableInfo("Condition").ActualName = "UseSuccessRule";289 op.OperatorGraph.AddOperator(cb);290 sp1.AddSubOperator(cb);291 292 SequentialProcessor sp2 = new SequentialProcessor();293 op.OperatorGraph.AddOperator(sp2);294 cb.AddSubOperator(sp2);295 296 OffspringAnalyzer oa = new OffspringAnalyzer();297 oa.Name = "Offspring Analyzer";298 oa.GetVariable("ParentsCount").Value = new IntData(1);299 oa.GetVariable("ComparisonFactor").Value = new DoubleData(0.0);300 op.OperatorGraph.AddOperator(oa);301 sp2.AddSubOperator(oa);302 303 SequentialProcessor sp3 = new SequentialProcessor();304 op.OperatorGraph.AddOperator(sp3);305 oa.AddSubOperator(sp3);306 cb.AddSubOperator(sp3);307 308 288 OperatorExtractor oe1 = new OperatorExtractor(); 309 289 oe1.Name = "Recombinator"; 310 290 oe1.GetVariableInfo("Operator").ActualName = "Recombinator"; 311 291 op.OperatorGraph.AddOperator(oe1); 312 sp 3.AddSubOperator(oe1);292 sp1.AddSubOperator(oe1); 313 293 314 294 UniformSequentialSubScopesProcessor ussp = new UniformSequentialSubScopesProcessor(); 315 295 op.OperatorGraph.AddOperator(ussp); 316 sp 3.AddSubOperator(ussp);317 318 SequentialProcessor sp 4= new SequentialProcessor();319 op.OperatorGraph.AddOperator(sp 4);320 ussp.AddSubOperator(sp 4);296 sp1.AddSubOperator(ussp); 297 298 SequentialProcessor sp2 = new SequentialProcessor(); 299 op.OperatorGraph.AddOperator(sp2); 300 ussp.AddSubOperator(sp2); 321 301 322 302 OperatorExtractor oe2 = new OperatorExtractor(); … … 324 304 oe2.GetVariableInfo("Operator").ActualName = "Mutator"; 325 305 op.OperatorGraph.AddOperator(oe2); 326 sp 4.AddSubOperator(oe2);306 sp2.AddSubOperator(oe2); 327 307 328 308 OperatorExtractor oe3 = new OperatorExtractor(); … … 330 310 oe3.GetVariableInfo("Operator").ActualName = "Evaluator"; 331 311 op.OperatorGraph.AddOperator(oe3); 332 sp 4.AddSubOperator(oe3);312 sp2.AddSubOperator(oe3); 333 313 334 314 Counter c = new Counter(); 335 315 c.GetVariableInfo("Value").ActualName = "EvaluatedSolutions"; 336 316 op.OperatorGraph.AddOperator(c); 337 sp4.AddSubOperator(c); 338 339 SuccessRuleMutationStrengthAdjuster srmsa = new SuccessRuleMutationStrengthAdjuster(); 340 srmsa.Name = "SuccessRuleMutationStrengthAdjuster"; 341 op.OperatorGraph.AddOperator(srmsa); 342 sp2.AddSubOperator(srmsa); 317 sp2.AddSubOperator(c); 343 318 344 319 Sorter s = new Sorter(); … … 411 386 /// Gets or sets the µ value of the current instance. 412 387 /// </summary> 413 /// <remarks>Sets also the lambda and the rho value. Calls <see cref="ItemBase.OnChanged"/> of388 /// <remarks>Sets also the λ and the ρ value if necessary. Using the comma notation it must hold that λ >= µ and generally µ >= ρ must hold as well. Calls <see cref="ItemBase.OnChanged"/> of 414 389 /// base class <see cref="ItemBase"/>.</remarks> 415 390 public int Mu { … … 426 401 private IntData myRho; 427 402 /// <summary> 428 /// Gets or sets the rhovalue of the current instance.429 /// </summary> 430 /// <remarks>Sets also the µ value . Calls <see cref="ItemBase.OnChanged"/> of403 /// Gets or sets the ρ value of the current instance. 404 /// </summary> 405 /// <remarks>Sets also the µ value to be as large as the new ρ value if it was smaller before. Calls <see cref="ItemBase.OnChanged"/> of 431 406 /// base class <see cref="ItemBase"/>.</remarks> 432 407 public int Rho { … … 442 417 private IntData myLambda; 443 418 /// <summary> 444 /// Gets or sets the lambdavalue of the current instance.445 /// </summary> 446 /// <remarks> May also change the µ value under certain circumstances.419 /// Gets or sets the λ value of the current instance. 420 /// </summary> 421 /// <remarks>If the comma notation is used, it also changes the µ value to be as large as the new λ value if it was larger before. Note that in general for good optimization results it needs to be fairly larger than mu. 447 422 /// Calls <see cref="ItemBase.OnChanged"/> of base class <see cref="ItemBase"/>.</remarks> 448 423 public int Lambda { … … 452 427 if (PlusNotation) myLambda.Data = value; 453 428 else { 454 if (value > 1 && value < Mu) {429 if (value >= 1 && value < Mu) { 455 430 myLambda.Data = value; 456 myMu.Data = value - 1; 457 } else if (value == 1) { 458 myMu.Data = 1; 459 myLambda.Data = 2; 431 myMu.Data = value; 460 432 } else if (value > Mu) { 461 433 myLambda.Data = value; … … 468 440 private BoolData myPlusNotation; 469 441 /// <summary> 470 /// Gets or sets the boolean flag whether it is a plus notation or not.471 /// </summary> 472 /// <remarks> May also set the lambda value under certain circumstances.442 /// Gets or sets the boolean flag whether the plus notation is used (true) or the comma notation (false). 443 /// </summary> 444 /// <remarks>If set to false (comma notation) it sets λ to be as large as µ if is lower. Note that in general for good optimization results it needs to be fairly larger than µ. 473 445 /// Calls <see cref="ItemBase.OnChanged"/> of base class <see cref="ItemBase"/>.</remarks> 474 446 public bool PlusNotation { … … 476 448 set { 477 449 if (!value && myPlusNotation.Data) { // from plus to point 478 if (Lambda < =Mu) {479 myLambda.Data = Mu + 1;450 if (Lambda < Mu) { 451 myLambda.Data = Mu; 480 452 } 481 453 } … … 484 456 } 485 457 } 486 private DoubleData myShakingFactor; 487 /// <summary> 488 /// Gets or sets the shaking factor of the current instance. 489 /// </summary> 490 public double ShakingFactor { 491 get { return myShakingFactor.Data; } 492 set { myShakingFactor.Data = value; } 493 } 494 private DoubleData mySuccessProbability; 495 496 private DoubleData myTargetSuccessProbability; 497 /// <summary> 498 /// Gets or sets the success probability. 499 /// </summary> 500 /// <remarks>Gets the target success probability and sets also the target success probability.</remarks> 501 public double SuccessProbability { 502 get { return myTargetSuccessProbability.Data; } 503 set { 504 myTargetSuccessProbability.Data = value; 505 mySuccessProbability.Data = value; 458 private DoubleArrayData myShakingFactors; 459 /// <summary> 460 /// Gets or sets the initial strategy vector s(0). 461 /// </summary> 462 /// <remarks>Calls <see cref="ItemBase.OnChanged"/> of base class <see cref="ItemBase"/> 463 /// in the setter.</remarks> 464 public double[] ShakingFactors { 465 get { return myShakingFactors.Data; } 466 set { myShakingFactors.Data = value; } 467 } 468 private DoubleData myGeneralLearningRate; 469 /// <summary> 470 /// Gets or sets the general learning rate (tau0). 471 /// </summary> 472 /// <remarks>Calls <see cref="ItemBase.OnChanged"/> of base class <see cref="ItemBase"/> 473 /// in the setter.</remarks> 474 public double GeneralLearningRate { 475 get { return myGeneralLearningRate.Data; } 476 set { 477 if (value > 0.0 && value <= 1.0) { 478 myGeneralLearningRate.Data = value; 479 OnChanged(); 480 } 506 481 } 507 482 } 508 483 private DoubleData myLearningRate; 509 484 /// <summary> 510 /// Gets or sets the learning rate .485 /// Gets or sets the learning rate (tau). 511 486 /// </summary> 512 487 /// <remarks>Calls <see cref="ItemBase.OnChanged"/> of base class <see cref="ItemBase"/> … … 521 496 } 522 497 } 523 private DoubleData myDampeningFactor;524 /// <summary>525 /// Gets or sets the dampening factor.526 /// </summary>527 /// <remarks>Calls <see cref="ItemBase.OnChanged"/> of base class <see cref="ItemBase"/>528 /// in the setter.</remarks>529 public double DampeningFactor {530 get { return myDampeningFactor.Data; }531 set {532 if (value >= 1.0) {533 myDampeningFactor.Data = value;534 OnChanged();535 }536 }537 }538 498 private IntData myMaximumGenerations; 539 499 /// <summary> … … 543 503 get { return myMaximumGenerations.Data; } 544 504 set { myMaximumGenerations.Data = value; } 545 }546 private BoolData myUseSuccessRule;547 /// <summary>548 /// Gets or sets the boolean flag whether to use the success rule or not.549 /// </summary>550 public bool UseSuccessRule {551 get { return myUseSuccessRule.Data; }552 set { myUseSuccessRule.Data = value; }553 505 } 554 506 private CombinedOperator myES; … … 681 633 myMaximumGenerations = vi.GetVariable("MaximumGenerations").GetValue<IntData>(); 682 634 myPlusNotation = vi.GetVariable("PlusNotation").GetValue<BoolData>(); 683 myShakingFactor = vi.GetVariable("ShakingFactor").GetValue<DoubleData>(); 684 myTargetSuccessProbability = vi.GetVariable("TargetSuccessProbability").GetValue<DoubleData>(); 685 mySuccessProbability = vi.GetVariable("SuccessProbability").GetValue<DoubleData>(); 635 myGeneralLearningRate = vi.GetVariable("GeneralLearningRate").GetValue<DoubleData>(); 686 636 myLearningRate = vi.GetVariable("LearningRate").GetValue<DoubleData>(); 687 myDampeningFactor = vi.GetVariable("DampeningFactor").GetValue<DoubleData>();688 myUseSuccessRule = vi.GetVariable("UseSuccessRule").GetValue<BoolData>();689 637 // Population Initialization 690 638 CombinedOperator co3 = (CombinedOperator)sp1.SubOperators[1]; 691 639 myPopulationInitialization = co3; 640 // Variable Injector 641 VariableInjector vi2 = (VariableInjector)co3.OperatorGraph.InitialOperator.SubOperators[1].SubOperators[0].SubOperators[3]; 642 myShakingFactors = vi2.GetVariable("ShakingFactors").GetValue<DoubleArrayData>(); 692 643 // ES Main 693 644 CombinedOperator co4 = (CombinedOperator)sp1.SubOperators[2];
Note: See TracChangeset
for help on using the changeset viewer.