Changeset 11678
- Timestamp:
- 12/10/14 12:42:59 (10 years ago)
- Location:
- branches/ALPS
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/AlpsGeneticAlgorithm.cs
r11676 r11678 21 21 22 22 using System; 23 using System.Collections;24 23 using System.Collections.Generic; 25 24 using System.Linq; … … 414 413 } 415 414 private void ParameterizeMainLoop() { 416 //MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;417 //MainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;418 //MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;419 //MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;420 415 MainLoop.MainOperator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name; 421 416 MainLoop.MainOperator.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; … … 500 495 if (oldCrossover != null) { 501 496 var crossover = CrossoverParameter.ValidValues.FirstOrDefault(c => c.GetType() == oldCrossover.GetType()); 502 CrossoverParameter.Value = crossover; 497 if (crossover != null) 498 CrossoverParameter.Value = crossover; 499 else 500 oldCrossover = null; 503 501 } 504 502 if (oldCrossover == null && defaultCrossover != null) … … 514 512 if (oldMutator != null) { 515 513 var mutator = MutatorParameter.ValidValues.FirstOrDefault(m => m.GetType() == oldMutator.GetType()); 516 MutatorParameter.Value = mutator; 514 if (mutator != null) 515 MutatorParameter.Value = mutator; 517 516 } 518 517 } -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/AlpsGeneticAlgorithmMainLoop.cs
r11676 r11678 175 175 ageCalculator.ParameterToReduce.ActualName = "Age"; 176 176 ageCalculator.TargetParameter.ActualName = "Age"; 177 ageCalculator.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Max); 177 ageCalculator.ReductionOperation.Value = null; 178 ageCalculator.ReductionOperation.ActualName = "AgeInheritance"; 178 179 ageCalculator.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign); 179 180 crossover.Successor = ageCalculator; -
branches/ALPS/HeuristicLab.Operators/3.3/DataReducer.cs
r11171 r11678 40 40 get { return (LookupParameter<IItem>)Parameters["TargetParameter"]; } 41 41 } 42 public Value Parameter<ReductionOperation> ReductionOperation {43 get { return (Value Parameter<ReductionOperation>)Parameters["ReductionOperation"]; }44 } 45 public Value Parameter<ReductionOperation> TargetOperation {46 get { return (Value Parameter<ReductionOperation>)Parameters["TargetOperation"]; }42 public ValueLookupParameter<ReductionOperation> ReductionOperation { 43 get { return (ValueLookupParameter<ReductionOperation>)Parameters["ReductionOperation"]; } 44 } 45 public ValueLookupParameter<ReductionOperation> TargetOperation { 46 get { return (ValueLookupParameter<ReductionOperation>)Parameters["TargetOperation"]; } 47 47 } 48 48 #endregion … … 58 58 Parameters.Add(new ScopeTreeLookupParameter<IItem>("ParameterToReduce", "The parameter on which the reduction operation should be applied.")); 59 59 Parameters.Add(new LookupParameter<IItem>("TargetParameter", "The target variable in which the reduced value should be stored.")); 60 Parameters.Add(new Value Parameter<ReductionOperation>("ReductionOperation", "The operation which is applied on the parameters to reduce."));61 Parameters.Add(new Value Parameter<ReductionOperation>("TargetOperation", "The operation used to apply the reduced value to the target variable."));60 Parameters.Add(new ValueLookupParameter<ReductionOperation>("ReductionOperation", "The operation which is applied on the parameters to reduce.", new ReductionOperation())); 61 Parameters.Add(new ValueLookupParameter<ReductionOperation>("TargetOperation", "The operation used to apply the reduced value to the target variable.", new ReductionOperation())); 62 62 #endregion 63 63 } … … 65 65 public override IDeepCloneable Clone(Cloner cloner) { 66 66 return new DataReducer(this, cloner); 67 } 68 69 [StorableHook(HookType.AfterDeserialization)] 70 private void AfterDeserialization() { 71 // BackwardsCompatibility3.3 72 var oldReductionOperation = Parameters["ReductionOperation"] as ValueParameter<ReductionOperation>; 73 if (oldReductionOperation != null) { 74 Parameters.Remove("ReductionOperation"); 75 Parameters.Add(new ValueLookupParameter<ReductionOperation>("ReductionOperation", "The operation which is applied on the parameters to reduce.", oldReductionOperation.Value)); 76 } 77 var oldTargetOperation = Parameters["TargetOperation"] as ValueParameter<ReductionOperation>; 78 if (oldTargetOperation != null) { 79 Parameters.Remove("TargetOperation"); 80 Parameters.Add(new ValueLookupParameter<ReductionOperation>("TargetOperation", "The operation used to apply the reduced value to the target variable.", oldTargetOperation.Value)); 81 } 67 82 } 68 83 … … 89 104 private void CalculateResult(IEnumerable<int> values, Type targetType) { 90 105 int result; 91 switch (ReductionOperation. Value.Value) {106 switch (ReductionOperation.ActualValue.Value) { 92 107 case ReductionOperations.Sum: 93 108 result = values.Sum(); … … 116 131 117 132 IntValue target; 118 switch (TargetOperation. Value.Value) {133 switch (TargetOperation.ActualValue.Value) { 119 134 case ReductionOperations.Sum: 120 135 target = InitializeTarget<IntValue, int>(targetType, 0); … … 149 164 private void CalculateResult(IEnumerable<double> values, Type targetType) { 150 165 double result; 151 switch (ReductionOperation. Value.Value) {166 switch (ReductionOperation.ActualValue.Value) { 152 167 case ReductionOperations.Sum: 153 168 result = values.Sum(); … … 176 191 177 192 DoubleValue target; 178 switch (TargetOperation. Value.Value) {193 switch (TargetOperation.ActualValue.Value) { 179 194 case ReductionOperations.Sum: 180 195 target = InitializeTarget<DoubleValue, double>(targetType, 0.0); … … 209 224 private void CalculateResult(IEnumerable<TimeSpan> values, Type targetType) { 210 225 TimeSpan result; 211 switch (ReductionOperation. Value.Value) {226 switch (ReductionOperation.ActualValue.Value) { 212 227 case ReductionOperations.Sum: 213 228 result = values.Aggregate(new TimeSpan(), (x, y) => x + y); … … 230 245 231 246 TimeSpanValue target; 232 switch (TargetOperation. Value.Value) {247 switch (TargetOperation.ActualValue.Value) { 233 248 case ReductionOperations.Sum: 234 249 target = InitializeTarget<TimeSpanValue, TimeSpan>(targetType, new TimeSpan()); … … 259 274 private void CalculateResult(IEnumerable<bool> values, Type targetType) { 260 275 bool result; 261 switch (ReductionOperation. Value.Value) {276 switch (ReductionOperation.ActualValue.Value) { 262 277 case ReductionOperations.All: 263 278 result = values.All(x => x); … … 271 286 272 287 BoolValue target; 273 switch (TargetOperation. Value.Value) {288 switch (TargetOperation.ActualValue.Value) { 274 289 case ReductionOperations.Assign: 275 290 target = InitializeTarget<BoolValue, bool>(targetType, true);
Note: See TracChangeset
for help on using the changeset viewer.