Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/10/11 10:44:42 (14 years ago)
Author:
cneumuel
Message:

#1215

  • evaluation operator returns operatorgraph which creates a scope and an operation for each algorithm execution (each repetition and problem)
  • split ValueConfiguration into ParameterizedValueConfiguration and RangeValueConfiguration
Location:
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3

    • Property svn:ignore
      •  

        old new  
        33obj
        44HeuristicLabProblemsMetaOptimizationPlugin.cs
         5*.vs10x
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs

    r5522 r5653  
    22using System.Collections;
    33using System.Collections.Generic;
     4using System.Drawing;
    45using System.Linq;
     6using System.Text;
     7using HeuristicLab.Collections;
    58using HeuristicLab.Common;
    69using HeuristicLab.Core;
     
    912using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    1013using HeuristicLab.PluginInfrastructure;
    11 using System.Text;
    12 using System.Reflection;
    13 using HeuristicLab.Optimization;
    14 using HeuristicLab.Collections;
    15 using System.Drawing;
    1614
    1715namespace HeuristicLab.Problems.MetaOptimization {
     
    147145      this.ActualValue = new ConstrainedValue(
    148146        valueParameter.Value != null ? valueParameter.Value : null, // don't clone here; otherwise settings of a non-optimized ValueParameter will not be synchronized with the ConstrainedValue
    149         valueParameter.DataType, 
    150         this.validValues != null ? new ItemSet<IItem>(this.validValues) : CreateValidValues(), 
     147        valueParameter.DataType,
     148        this.validValues != null ? new ItemSet<IItem>(this.validValues) : CreateValidValues(),
    151149        this.IsNullable);
    152150      if (Optimize) {
     
    200198      if (this.ActualValue != null) this.ActualValue.ToStringChanged -= new EventHandler(ActualValue_ToStringChanged);
    201199    }
    202    
     200
    203201    private void PopulateValueConfigurations() {
    204202      foreach (Type t in this.validTypes) {
     
    212210            val = CreateItem(t);
    213211          }
    214           this.ValueConfigurations.Add(new ValueConfiguration(val, val.GetType()), true);
     212          if (val is IParameterizedItem) {
     213            this.ValueConfigurations.Add(new ParameterizedValueConfiguration(val, val.GetType()), true);
     214          } else {
     215            this.ValueConfigurations.Add(new RangeValueConfiguration(val, val.GetType()), true);
     216          }
    215217        }
    216218      }
     
    224226      // return only one type for ValueTypeValues<> (Int, Double, Percent, Bool). Otherwise 2 types would be returned for DoubleValue (PercentValue which is derived)
    225227      if (IsSubclassOfRawGeneric(typeof(ValueTypeValue<>), parameter.DataType))
    226         return new List<Type> { parameter.DataType }; 
    227      
     228        return new List<Type> { parameter.DataType };
     229
    228230      if (IsSubclassOfRawGeneric(typeof(OptionalConstrainedValueParameter<>), parameter.GetType())) {
    229231        // use existing validvalues if known
     
    252254      if (type == typeof(NullValue))
    253255        return new NullValue();
    254      
     256
    255257      // copy value from ValidValues; this ensures that previously set ActualNames for a type are kept
    256258      IItem value = this.validValues.Where(v => v.GetType() == type).SingleOrDefault();
    257       if (value != null) 
     259      if (value != null)
    258260        return value;
    259261
     
    404406      if (Optimize) {
    405407        if (this.ActualValue.Value is IParameterizedItem) {
    406           this.ValueConfigurations[actualValueConfigurationIndex].Parameterize((IParameterizedItem)this.ActualValue.Value);
     408          ((ParameterizedValueConfiguration)this.ValueConfigurations[actualValueConfigurationIndex]).Parameterize((IParameterizedItem)this.ActualValue.Value);
    407409        }
    408410      }
    409411      var clonedValue = this.ActualValue.Value != null ? (IItem)this.ActualValue.Value.Clone() : null;
    410       AdaptValidValues(parameter, clonedValue);
     412      if(clonedValue != null) AdaptValidValues(parameter, clonedValue);
    411413      parameter.Value = clonedValue;
    412414    }
     
    433435        foreach (var vc in this.ValueConfigurations) {
    434436          if (this.ValueConfigurations.ItemChecked(vc)) {
    435             vc.Randomize(random);
     437            if (vc.Optimize) vc.Randomize(random);
    436438          }
    437439        }
     
    447449        foreach (var vc in this.ValueConfigurations) {
    448450          if (this.ValueConfigurations.ItemChecked(vc)) {
    449             vc.Mutate(random, mutate, intValueManipulator, doubleValueManipulator);
     451            if (vc.Optimize) vc.Mutate(random, mutate, intValueManipulator, doubleValueManipulator);
    450452          }
    451453        }
     
    459461        for (int i = 0; i < this.ValueConfigurations.Count; i++) {
    460462          if (this.ValueConfigurations.ItemChecked(this.ValueConfigurations[i])) {
    461             this.ValueConfigurations[i].Cross(random, otherPc.ValueConfigurations[i], cross, intValueCrossover, doubleValueCrossover);
     463            if (this.ValueConfigurations[i].Optimize) this.ValueConfigurations[i].Cross(random, otherPc.ValueConfigurations[i], cross, intValueCrossover, doubleValueCrossover);
    462464          }
    463465        }
Note: See TracChangeset for help on using the changeset viewer.