Changeset 5337 for branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding
- Timestamp:
- 01/20/11 01:30:44 (14 years ago)
- Location:
- branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurationTree.cs
r5328 r5337 113 113 114 114 #region constructors and cloning 115 public ParameterConfigurationTree( EngineAlgorithm algorithm)115 public ParameterConfigurationTree(IAlgorithm algorithm) 116 116 : base(null, algorithm.GetType()) { 117 117 this.Optimize = true; // root must always be optimized -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs
r5313 r5337 217 217 } 218 218 219 private IEnumerable<Type> GetValidTypes(IValueParameter parameter) {219 private static IEnumerable<Type> GetValidTypes(IValueParameter parameter) { 220 220 // in case of IOperator return empty list, otherwise hundreds of types would be returned. this mostly occurs for Successor which will never be optimized 221 221 if (parameter.DataType == typeof(IOperator)) 222 222 return new List<Type>(); 223 223 224 // return only one type for ValueTypeValues<> (Int, Double, Percent, Bool). Otherwise 2 types would be returned for DoubleValue (PercentValue which is derived) 225 if (IsSubclassOfRawGeneric(typeof(ValueTypeValue<>), parameter.DataType)) 226 return new List<Type> { parameter.DataType }; 227 224 228 if (IsSubclassOfRawGeneric(typeof(OptionalConstrainedValueParameter<>), parameter.GetType())) { 229 // use existing validvalues if known 225 230 var parameterValidValues = (IEnumerable)parameter.GetType().GetProperty("ValidValues").GetValue(parameter, new object[] { }); 226 231 return parameterValidValues.Cast<object>().Select(x => x.GetType()); 227 232 } else { 228 return ApplicationManager.Manager.GetTypes(valueDataType, true); 233 // otherwise use all assignable types 234 return ApplicationManager.Manager.GetTypes(parameter.DataType, true); 229 235 } 230 236 } … … 273 279 return true; 274 280 } 275 toCheck = toCheck.BaseType; 281 toCheck = toCheck.BaseType; // baseType is null when toCheck is an Interface 282 if (toCheck == null) 283 return false; 276 284 } 277 285 return false; -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/DoubleValueRange.cs
r5207 r5337 29 29 } 30 30 31 public void ApplyStepSize(DoubleValue value) {32 value.Value = ((int)Math.Round(value.Value / this.StepSize.Value, 0)) * this.StepSize.Value;31 public double ApplyStepSize(double value) { 32 return (Math.Round(value / this.StepSize.Value, 0)) * this.StepSize.Value; 33 33 } 34 34 … … 44 44 solutions.Add(new DoubleValue(value)); 45 45 value += StepSize.Value; 46 value = ApplyStepSize(value); 46 47 } 47 48 return solutions; -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/IntValueRange.cs
r5207 r5337 29 29 } 30 30 31 public void ApplyStepSize(IntValuevalue) {32 value.Value = ((int)Math.Round(value.Value / (double)this.StepSize.Value, 0)) * this.StepSize.Value;31 public int ApplyStepSize(int value) { 32 return ((int)Math.Round(value / (double)this.StepSize.Value, 0)) * this.StepSize.Value; 33 33 } 34 34 -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/PercentValueRange.cs
r5207 r5337 33 33 } 34 34 35 public void ApplyStepSize(PercentValue value) {36 value.Value = ((int)Math.Round(value.Value / this.StepSize.Value, 0)) * this.StepSize.Value;35 public double ApplyStepSize(double value) { 36 return ((int)Math.Round(value / this.StepSize.Value, 0)) * this.StepSize.Value; 37 37 } 38 38 … … 48 48 solutions.Add(new PercentValue(value)); 49 49 value += StepSize.Value; 50 value = ApplyStepSize(value); 50 51 } 51 52 return solutions;
Note: See TracChangeset
for help on using the changeset viewer.