Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7153


Ignore:
Timestamp:
12/07/11 21:09:40 (13 years ago)
Author:
ascheibe
Message:

#1215

  • removed storing of valid types and valid values. This leads to wrong plugin discovery by the Persistence and Hive. Previously references to types of all available algorithms and problems were saved and needed by Hive for deserializing a MetaOpt task. Now only the actual values are saved and valid types and values are discovered after deserialization.
  • added missing license headers
  • added missing plugin references to plugin file
Location:
branches/HeuristicLab.MetaOptimization
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.HiveEngine/3.3/Exceptions/HiveEngineException.cs

    r6984 r7153  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223
    324namespace HeuristicLab.HiveEngine {
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.HiveEngine/3.3/Exceptions/ScopeMergeException.cs

    r6984 r7153  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Runtime.Serialization;
    324
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/ConstrainedTypeValue.cs

    r5337 r7153  
    22using System.Collections.Generic;
    33using System.Linq;
    4 using System.Text;
     4using HeuristicLab.Common;
    55using HeuristicLab.Core;
    6 using HeuristicLab.Data;
    7 using System.Drawing;
    86using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    9 using HeuristicLab.Common;
    107using HeuristicLab.PluginInfrastructure;
    118
     
    1512  public class ConstrainedTypeValue : TypeValue {
    1613
    17     [Storable]
    1814    private IEnumerable<Type> validTypes;
    1915    public IEnumerable<Type> ValidTypes {
     
    2925    }
    3026
    31     public ConstrainedTypeValue() : base() {
     27    public ConstrainedTypeValue()
     28      : base() {
    3229      this.readOnly = false;
    3330    }
    34     public ConstrainedTypeValue(Type value) : this() {
     31    public ConstrainedTypeValue(Type value)
     32      : this() {
    3533      this.Value = value;
    3634    }
     
    5149  public class ConstrainedTypeValue<T> : ConstrainedTypeValue where T : class, IItem {
    5250
    53     public ConstrainedTypeValue() : base() {
     51    public ConstrainedTypeValue()
     52      : base() {
    5453      this.ValidTypes = ApplicationManager.Manager.GetTypes(typeof(T), true).ToList();
    5554      this.Value = ValidTypes.First();
    5655    }
    57     public ConstrainedTypeValue(Type value) : base() {
     56    public ConstrainedTypeValue(Type value)
     57      : base() {
    5858      this.ValidTypes = ApplicationManager.Manager.GetTypes(typeof(T), true).ToList();
    5959      this.Value = value;
    6060    }
     61
    6162    [StorableConstructor]
    62     protected ConstrainedTypeValue(bool deserializing) : base(deserializing) { }
     63    protected ConstrainedTypeValue(bool deserializing)
     64      : base(deserializing) {
     65      if (deserializing) {
     66        this.ValidTypes = ApplicationManager.Manager.GetTypes(typeof(T), true).ToList();
     67      }
     68    }
     69
    6370    protected ConstrainedTypeValue(ConstrainedTypeValue original, Cloner cloner) : base(original, cloner) { }
    6471    public override IDeepCloneable Clone(Cloner cloner) {
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs

    r6489 r7153  
    2121    }
    2222
    23     [Storable]
    2423    public string Filename { get; set; }
    2524
     
    6665    }
    6766
    68     [Storable]
    6967    protected Type[] validTypes;
    7068    public Type[] ValidTypes {
     
    136134    }
    137135
    138     [Storable]
    139136    protected IItemSet<IItem> validValues;
    140137
     
    216213    [StorableConstructor]
    217214    protected ParameterConfiguration(bool deserializing) { }
     215
    218216    protected ParameterConfiguration(ParameterConfiguration original, Cloner cloner)
    219217      : base(original, cloner) {
     
    236234    }
    237235
    238 
    239236    public override IDeepCloneable Clone(Cloner cloner) {
    240237      return new ParameterConfiguration(this, cloner);
     
    242239    [StorableHook(HookType.AfterDeserialization)]
    243240    protected virtual void AfterDeserialization() {
     241      this.validTypes = GetValidTypes(parameterDataType).ToArray();
     242
     243      if (IsNullable) {
     244        validTypes = new List<Type>(validTypes) { typeof(NullValue) }.ToArray();
     245      }
     246      this.validValues = CreateValidValues();
     247
    244248      if (this.valueConfigurations != null) RegisterValueConfigurationEvents();
    245249      if (this.actualValue != null) RegisterActualValueEvents();
     
    323327    }
    324328
     329    private static IEnumerable<Type> GetValidTypes(Type parameter) {
     330      // in case of IOperator return empty list, otherwise hundreds of types would be returned. this mostly occurs for Successor which will never be optimized
     331      if (parameter == typeof(IOperator))
     332        return new List<Type>();
     333
     334      // return only one type for ValueTypeValues<> (Int, Double, Percent, Bool). Otherwise 2 types would be returned for DoubleValue (PercentValue which is derived)
     335      if (IsSubclassOfRawGeneric(typeof(ValueTypeValue<>), parameter))
     336        return new List<Type> { parameter };
     337
     338      //TODO: not sure if this if makes sense; maybe only leave else branch here
     339      if (IsSubclassOfRawGeneric(typeof(OptionalConstrainedValueParameter<>), parameter.GetType())) {
     340        // use existing validvalues if known
     341        var parameterValidValues = (IEnumerable)parameter.GetType().GetProperty("ValidValues").GetValue(parameter, new object[] { });
     342        return parameterValidValues.Cast<object>().Select(x => x.GetType());
     343      } else {
     344        // otherwise use all assignable types
     345        return ApplicationManager.Manager.GetTypes(parameter, true);
     346      }
     347    }
     348
    325349    private IItemSet<IItem> GetValidValues(IValueParameter parameter) {
    326350      if (IsSubclassOfRawGeneric(typeof(OptionalConstrainedValueParameter<>), parameter.GetType())) {
     
    330354        return null;
    331355      }
    332      
    333356    }
    334357
     
    612635    private void KeepActualValueConfigurationIndexConsistent() {
    613636      if (this.valueConfigurations != null && this.valueConfigurations.CheckedItems.Count() > 0) {
    614         if(this.valueConfigurations.Count <= this.actualValueConfigurationIndex &&
     637        if (this.valueConfigurations.Count <= this.actualValueConfigurationIndex &&
    615638           this.valueConfigurations.CheckedItems.Count(x => x.Index == this.actualValueConfigurationIndex) == 1) {
    616639          // everything is ok; do nothing
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Plugin.cs.frame

    r7101 r7153  
    2828  [Plugin("HeuristicLab.Problems.MetaOptimization", "3.3.2.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.MetaOptimization-3.3.dll", PluginFileType.Assembly)]
    30   [PluginDependency("HeuristicLab.Algorithms.GeneticAlgorithm", "3.3")]
     30 [PluginDependency("HeuristicLab.Algorithms.GeneticAlgorithm", "3.3")]
    3131  [PluginDependency("HeuristicLab.Analysis", "3.3")]
    3232  [PluginDependency("HeuristicLab.Collections", "3.3")]
     
    3838  [PluginDependency("HeuristicLab.Encodings.IntegerVectorEncoding", "3.3")]
    3939  [PluginDependency("HeuristicLab.Encodings.RealVectorEncoding", "3.3")]
     40  [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.4")]
    4041  [PluginDependency("HeuristicLab.Operators", "3.3")]
    4142  [PluginDependency("HeuristicLab.Optimization", "3.3")]
    4243  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    4344  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    44   [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.3")]
     45  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
     46  [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic", "3.4")]
     47  [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression", "3.4")]
    4548  [PluginDependency("HeuristicLab.Problems.TestFunctions", "3.3")]
    4649  [PluginDependency("HeuristicLab.Random", "3.3")]
Note: See TracChangeset for help on using the changeset viewer.