Changeset 3048 for trunk/sources/HeuristicLab.Algorithms.SGA/3.3
- Timestamp:
- 03/15/10 23:49:54 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.SGA/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.SGA/3.3/SGA.cs
r3023 r3048 51 51 52 52 #region Parameter Properties 53 private ValueParameter<Int Data> SeedParameter {54 get { return (ValueParameter<Int Data>)Parameters["Seed"]; }55 } 56 private ValueParameter<Bool Data> SetSeedRandomlyParameter {57 get { return (ValueParameter<Bool Data>)Parameters["SetSeedRandomly"]; }58 } 59 private ValueParameter<Int Data> PopulationSizeParameter {60 get { return (ValueParameter<Int Data>)Parameters["PopulationSize"]; }53 private ValueParameter<IntValue> SeedParameter { 54 get { return (ValueParameter<IntValue>)Parameters["Seed"]; } 55 } 56 private ValueParameter<BoolValue> SetSeedRandomlyParameter { 57 get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; } 58 } 59 private ValueParameter<IntValue> PopulationSizeParameter { 60 get { return (ValueParameter<IntValue>)Parameters["PopulationSize"]; } 61 61 } 62 62 private ConstrainedValueParameter<ISelector> SelectorParameter { … … 66 66 get { return (ConstrainedValueParameter<ICrossover>)Parameters["Crossover"]; } 67 67 } 68 private ValueParameter<Double Data> MutationProbabilityParameter {69 get { return (ValueParameter<Double Data>)Parameters["MutationProbability"]; }68 private ValueParameter<DoubleValue> MutationProbabilityParameter { 69 get { return (ValueParameter<DoubleValue>)Parameters["MutationProbability"]; } 70 70 } 71 71 private OptionalConstrainedValueParameter<IManipulator> MutatorParameter { 72 72 get { return (OptionalConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; } 73 73 } 74 private ValueParameter<Int Data> ElitesParameter {75 get { return (ValueParameter<Int Data>)Parameters["Elites"]; }76 } 77 private ValueParameter<Int Data> MaximumGenerationsParameter {78 get { return (ValueParameter<Int Data>)Parameters["MaximumGenerations"]; }74 private ValueParameter<IntValue> ElitesParameter { 75 get { return (ValueParameter<IntValue>)Parameters["Elites"]; } 76 } 77 private ValueParameter<IntValue> MaximumGenerationsParameter { 78 get { return (ValueParameter<IntValue>)Parameters["MaximumGenerations"]; } 79 79 } 80 80 #endregion 81 81 82 82 #region Properties 83 public Int DataSeed {83 public IntValue Seed { 84 84 get { return SeedParameter.Value; } 85 85 set { SeedParameter.Value = value; } 86 86 } 87 public Bool DataSetSeedRandomly {87 public BoolValue SetSeedRandomly { 88 88 get { return SetSeedRandomlyParameter.Value; } 89 89 set { SetSeedRandomlyParameter.Value = value; } 90 90 } 91 public Int DataPopulationSize {91 public IntValue PopulationSize { 92 92 get { return PopulationSizeParameter.Value; } 93 93 set { PopulationSizeParameter.Value = value; } … … 101 101 set { CrossoverParameter.Value = value; } 102 102 } 103 public Double DataMutationProbability {103 public DoubleValue MutationProbability { 104 104 get { return MutationProbabilityParameter.Value; } 105 105 set { MutationProbabilityParameter.Value = value; } … … 109 109 set { MutatorParameter.Value = value; } 110 110 } 111 public Int DataElites {111 public IntValue Elites { 112 112 get { return ElitesParameter.Value; } 113 113 set { ElitesParameter.Value = value; } 114 114 } 115 public Int DataMaximumGenerations {115 public IntValue MaximumGenerations { 116 116 get { return MaximumGenerationsParameter.Value; } 117 117 set { MaximumGenerationsParameter.Value = value; } … … 134 134 public SGA() 135 135 : base() { 136 Parameters.Add(new ValueParameter<Int Data>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntData(0)));137 Parameters.Add(new ValueParameter<Bool Data>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolData(true)));138 Parameters.Add(new ValueParameter<Int Data>("PopulationSize", "The size of the population of solutions.", new IntData(100)));136 Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); 137 Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); 138 Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100))); 139 139 Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction.")); 140 140 Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.")); 141 Parameters.Add(new ValueParameter<Double Data>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new DoubleData(0.05)));141 Parameters.Add(new ValueParameter<DoubleValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new DoubleValue(0.05))); 142 142 Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 143 Parameters.Add(new ValueParameter<Int Data>("Elites", "The numer of elite solutions which are kept in each generation.", new IntData(1)));144 Parameters.Add(new ValueParameter<Int Data>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntData(1000)));143 Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1))); 144 Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000))); 145 145 146 146 RandomCreator randomCreator = new RandomCreator(); … … 266 266 private void ParameterizeSelectors() { 267 267 foreach (ISelector selector in Selectors) { 268 selector.CopySelected = new Bool Data(true);269 selector.NumberOfSelectedSubScopesParameter.Value = new Int Data(2 * (PopulationSizeParameter.Value.Value - ElitesParameter.Value.Value));268 selector.CopySelected = new BoolValue(true); 269 selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(2 * (PopulationSizeParameter.Value.Value - ElitesParameter.Value.Value)); 270 270 ParameterizeStochasticOperator(selector); 271 271 } -
trunk/sources/HeuristicLab.Algorithms.SGA/3.3/SGAMainLoop.cs
r3026 r3048 41 41 get { return (ValueLookupParameter<IRandom>)Parameters["Random"]; } 42 42 } 43 public ValueLookupParameter<Bool Data> MaximizationParameter {44 get { return (ValueLookupParameter<Bool Data>)Parameters["Maximization"]; }45 } 46 public SubScopesLookupParameter<Double Data> QualityParameter {47 get { return (SubScopesLookupParameter<Double Data>)Parameters["Quality"]; }43 public ValueLookupParameter<BoolValue> MaximizationParameter { 44 get { return (ValueLookupParameter<BoolValue>)Parameters["Maximization"]; } 45 } 46 public SubScopesLookupParameter<DoubleValue> QualityParameter { 47 get { return (SubScopesLookupParameter<DoubleValue>)Parameters["Quality"]; } 48 48 } 49 49 public ValueLookupParameter<IOperator> SelectorParameter { … … 53 53 get { return (ValueLookupParameter<IOperator>)Parameters["Crossover"]; } 54 54 } 55 public ValueLookupParameter<Double Data> MutationProbabilityParameter {56 get { return (ValueLookupParameter<Double Data>)Parameters["MutationProbability"]; }55 public ValueLookupParameter<DoubleValue> MutationProbabilityParameter { 56 get { return (ValueLookupParameter<DoubleValue>)Parameters["MutationProbability"]; } 57 57 } 58 58 public ValueLookupParameter<IOperator> MutatorParameter { … … 62 62 get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; } 63 63 } 64 public ValueLookupParameter<Int Data> ElitesParameter {65 get { return (ValueLookupParameter<Int Data>)Parameters["Elites"]; }66 } 67 public ValueLookupParameter<Int Data> MaximumGenerationsParameter {68 get { return (ValueLookupParameter<Int Data>)Parameters["MaximumGenerations"]; }64 public ValueLookupParameter<IntValue> ElitesParameter { 65 get { return (ValueLookupParameter<IntValue>)Parameters["Elites"]; } 66 } 67 public ValueLookupParameter<IntValue> MaximumGenerationsParameter { 68 get { return (ValueLookupParameter<IntValue>)Parameters["MaximumGenerations"]; } 69 69 } 70 70 public ValueLookupParameter<VariableCollection> ResultsParameter { … … 84 84 #region Create parameters 85 85 Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator.")); 86 Parameters.Add(new ValueLookupParameter<Bool Data>("Maximization", "True if the problem is a maximization problem, otherwise false."));87 Parameters.Add(new SubScopesLookupParameter<Double Data>("Quality", "The value which represents the quality of a solution."));86 Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false.")); 87 Parameters.Add(new SubScopesLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution.")); 88 88 Parameters.Add(new ValueLookupParameter<IOperator>("Selector", "The operator used to select solutions for reproduction.")); 89 89 Parameters.Add(new ValueLookupParameter<IOperator>("Crossover", "The operator used to cross solutions.")); 90 Parameters.Add(new ValueLookupParameter<Double Data>("MutationProbability", "The probability that the mutation operator is applied on a solution."));90 Parameters.Add(new ValueLookupParameter<DoubleValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.")); 91 91 Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions.")); 92 92 Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions.")); 93 Parameters.Add(new ValueLookupParameter<Int Data>("Elites", "The numer of elite solutions which are kept in each generation."));94 Parameters.Add(new ValueLookupParameter<Int Data>("MaximumGenerations", "The maximum number of generations which should be processed."));93 Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.")); 94 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.")); 95 95 Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored.")); 96 96 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the SGA should be applied.")); … … 123 123 OperatorGraph.InitialOperator = variableCreator; 124 124 125 variableCreator.CollectedValues.Add(new ValueParameter<Int Data>("Generations", new IntData(0)));126 variableCreator.CollectedValues.Add(new ValueParameter<Double Data>("Best Quality", new DoubleData(0)));127 variableCreator.CollectedValues.Add(new ValueParameter<Double Data>("Average Quality", new DoubleData(0)));128 variableCreator.CollectedValues.Add(new ValueParameter<Double Data>("Worst Quality", new DoubleData(0)));125 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); 126 variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("Best Quality", new DoubleValue(0))); 127 variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("Average Quality", new DoubleValue(0))); 128 variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("Worst Quality", new DoubleValue(0))); 129 129 variableCreator.CollectedValues.Add(new ValueParameter<DataTable>("Qualities", new DataTable("Qualities"))); 130 130 variableCreator.Successor = resultsCollector; 131 131 132 resultsCollector.CollectedValues.Add(new LookupParameter<Int Data>("Generations"));133 resultsCollector.CollectedValues.Add(new LookupParameter<Double Data>("Best Quality"));134 resultsCollector.CollectedValues.Add(new LookupParameter<Double Data>("Average Quality"));135 resultsCollector.CollectedValues.Add(new LookupParameter<Double Data>("Worst Quality"));132 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations")); 133 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality")); 134 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Average Quality")); 135 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Worst Quality")); 136 136 resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Qualities")); 137 137 resultsCollector.ResultsParameter.ActualName = "Results"; … … 150 150 sequentialSubScopesProcessor1.Successor = sequentialSubScopesProcessor2; 151 151 152 childrenCreator.ParentsPerChild = new Int Data(2);152 childrenCreator.ParentsPerChild = new IntValue(2); 153 153 childrenCreator.Successor = uniformSequentialSubScopesProcessor; 154 154 … … 185 185 sequentialSubScopesProcessor2.Successor = mergingReducer; 186 186 187 leftSelector.CopySelected = new Bool Data(false);187 leftSelector.CopySelected = new BoolValue(false); 188 188 leftSelector.NumberOfSelectedSubScopesParameter.ActualName = "Elites"; 189 189 leftSelector.Successor = rightReducer; … … 193 193 mergingReducer.Successor = intCounter; 194 194 195 intCounter.Increment = new Int Data(1);195 intCounter.Increment = new IntValue(1); 196 196 intCounter.ValueParameter.ActualName = "Generations"; 197 197 intCounter.Successor = comparator; 198 198 199 comparator.Comparison = new Comparison Data(Comparison.GreaterOrEqual);199 comparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual); 200 200 comparator.LeftSideParameter.ActualName = "Generations"; 201 201 comparator.ResultParameter.ActualName = "Terminate"; … … 210 210 bestAverageWorstQualityCalculator.Successor = dataTableValuesCollector; 211 211 212 dataTableValuesCollector.CollectedValues.Add(new LookupParameter<Double Data>("Best Quality"));213 dataTableValuesCollector.CollectedValues.Add(new LookupParameter<Double Data>("Average Quality"));214 dataTableValuesCollector.CollectedValues.Add(new LookupParameter<Double Data>("Worst Quality"));212 dataTableValuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality")); 213 dataTableValuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Average Quality")); 214 dataTableValuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Worst Quality")); 215 215 dataTableValuesCollector.DataTableParameter.ActualName = "Qualities"; 216 216 dataTableValuesCollector.Successor = conditionalBranch;
Note: See TracChangeset
for help on using the changeset viewer.