Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/20/11 01:30:44 (14 years ago)
Author:
cneumuel
Message:

#1215

  • made all IAlgorithm types compatible to be loaded into MetaOptimization.
  • valid problem types are now automatically set
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs

    r5313 r5337  
    217217    }
    218218
    219     private IEnumerable<Type> GetValidTypes(IValueParameter parameter) {
     219    private static IEnumerable<Type> GetValidTypes(IValueParameter parameter) {
    220220      // in case of IOperator return empty list, otherwise hundreds of types would be returned. this mostly occurs for Successor which will never be optimized
    221221      if (parameter.DataType == typeof(IOperator))
    222222        return new List<Type>();
    223223
     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     
    224228      if (IsSubclassOfRawGeneric(typeof(OptionalConstrainedValueParameter<>), parameter.GetType())) {
     229        // use existing validvalues if known
    225230        var parameterValidValues = (IEnumerable)parameter.GetType().GetProperty("ValidValues").GetValue(parameter, new object[] { });
    226231        return parameterValidValues.Cast<object>().Select(x => x.GetType());
    227232      } else {
    228         return ApplicationManager.Manager.GetTypes(valueDataType, true);
     233        // otherwise use all assignable types
     234        return ApplicationManager.Manager.GetTypes(parameter.DataType, true);
    229235      }
    230236    }
     
    273279          return true;
    274280        }
    275         toCheck = toCheck.BaseType;
     281        toCheck = toCheck.BaseType; // baseType is null when toCheck is an Interface
     282        if (toCheck == null)
     283          return false;
    276284      }
    277285      return false;
Note: See TracChangeset for help on using the changeset viewer.