Changeset 1222 for trunk/sources/HeuristicLab.ES/ES.cs
- Timestamp:
- 02/24/09 00:58:23 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ES/ES.cs
r1091 r1222 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Text;25 24 using System.Xml; 26 25 using HeuristicLab.Core; 27 26 using HeuristicLab.Data; 28 using HeuristicLab.SequentialEngine;29 27 using HeuristicLab.Operators; 30 28 using HeuristicLab.Random; 31 29 using HeuristicLab.Logging; 32 30 using HeuristicLab.Selection; 33 using HeuristicLab.Selection.OffspringSelection; 34 using HeuristicLab.Evolutionary; 31 using HeuristicLab.RealVector; 35 32 36 33 namespace HeuristicLab.ES { … … 132 129 vi.AddVariable(new Variable("EvaluatedSolutions", new IntData())); 133 130 vi.AddVariable(new Variable("PlusNotation", new BoolData(true))); 131 vi.AddVariable(new Variable("ProblemDimension", new IntData(1))); 132 vi.AddVariable(new Variable("ShakingFactorsMin", new DoubleData(0.1))); 133 vi.AddVariable(new Variable("ShakingFactorsMax", new DoubleData(5.0))); 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)));137 vi.AddVariable(new Variable("LearningRate", new DoubleData( 0.1)));136 vi.AddVariable(new Variable("GeneralLearningRate", new DoubleData(1.0 / Math.Sqrt(2)))); 137 vi.AddVariable(new Variable("LearningRate", new DoubleData(1.0 / Math.Sqrt(2)))); 138 138 op.OperatorGraph.AddOperator(vi); 139 139 sp.AddSubOperator(vi); … … 177 177 sp2.AddSubOperator(c); 178 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); 179 UniformRandomRealVectorGenerator urrvg = new UniformRandomRealVectorGenerator(); 180 urrvg.GetVariableInfo("Length").ActualName = "ProblemDimension"; 181 urrvg.GetVariableInfo("Minimum").ActualName = "ShakingFactorsMin"; 182 urrvg.GetVariableInfo("Maximum").ActualName = "ShakingFactorsMax"; 183 urrvg.GetVariableInfo("RealVector").ActualName = "ShakingFactors"; 184 op.OperatorGraph.AddOperator(urrvg); 185 sp2.AddSubOperator(urrvg); 183 186 184 187 Sorter s = new Sorter(); … … 456 459 } 457 460 } 458 private DoubleArrayData myShakingFactors;459 /// <summary> 460 /// Gets or sets the initial strategy vector s(0).461 private IntData myProblemDimension; 462 /// <summary> 463 /// Gets or sets the problem dimension which determines the length of the strategy vector. 461 464 /// </summary> 462 465 /// <remarks>Calls <see cref="ItemBase.OnChanged"/> of base class <see cref="ItemBase"/> 463 466 /// in the setter.</remarks> 464 public double[] ShakingFactors { 465 get { return myShakingFactors.Data; } 466 set { myShakingFactors.Data = value; } 467 public int ProblemDimension { 468 get { return myProblemDimension.Data; } 469 set { myProblemDimension.Data = value; } 470 } 471 private DoubleData myShakingFactorsMin; 472 /// <summary> 473 /// Gets or sets the minimal value for each dimension of the strategy vector. 474 /// </summary> 475 /// <remarks>Calls <see cref="ItemBase.OnChanged"/> of base class <see cref="ItemBase"/> 476 /// in the setter.</remarks> 477 public double ShakingFactorsMin { 478 get { return myShakingFactorsMin.Data; } 479 set { 480 myShakingFactorsMin.Data = value; 481 OnChanged(); 482 } 483 } 484 private DoubleData myShakingFactorsMax; 485 /// <summary> 486 /// Gets or sets the maximal value for each dimension of the strategy vector. 487 /// </summary> 488 /// <remarks>Calls <see cref="ItemBase.OnChanged"/> of base class <see cref="ItemBase"/> 489 /// in the setter.</remarks> 490 public double ShakingFactorsMax { 491 get { return myShakingFactorsMax.Data; } 492 set { 493 myShakingFactorsMax.Data = value; 494 OnChanged(); 495 } 467 496 } 468 497 private DoubleData myGeneralLearningRate; … … 633 662 myMaximumGenerations = vi.GetVariable("MaximumGenerations").GetValue<IntData>(); 634 663 myPlusNotation = vi.GetVariable("PlusNotation").GetValue<BoolData>(); 664 myProblemDimension = vi.GetVariable("ProblemDimension").GetValue<IntData>(); 665 myShakingFactorsMin = vi.GetVariable("ShakingFactorsMin").GetValue<DoubleData>(); 666 myShakingFactorsMax = vi.GetVariable("ShakingFactorsMax").GetValue<DoubleData>(); 635 667 myGeneralLearningRate = vi.GetVariable("GeneralLearningRate").GetValue<DoubleData>(); 636 668 myLearningRate = vi.GetVariable("LearningRate").GetValue<DoubleData>(); … … 638 670 CombinedOperator co3 = (CombinedOperator)sp1.SubOperators[1]; 639 671 myPopulationInitialization = co3; 640 // Variable Injector641 VariableInjector vi2 = (VariableInjector)co3.OperatorGraph.InitialOperator.SubOperators[1].SubOperators[0].SubOperators[3];642 myShakingFactors = vi2.GetVariable("ShakingFactors").GetValue<DoubleArrayData>();643 672 // ES Main 644 673 CombinedOperator co4 = (CombinedOperator)sp1.SubOperators[2];
Note: See TracChangeset
for help on using the changeset viewer.