Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4997


Ignore:
Timestamp:
11/30/10 01:08:19 (12 years ago)
Author:
cneumuel
Message:

#1215 worked on metaoptimization

Location:
branches/HeuristicLab.MetaOptimization
Files:
9 added
16 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization

    • Property svn:ignore
      •  

        old new  
        11HeuristicLab.MetaOptimization.suo
        22HeuristicLab.MetaOptimization.Test
         3HeuristicLab.MetaOptimization.Tests
         4TestResults
         5HeuristicLab.MetaOptimization.vsmdi
         6Local.testsettings
         7TraceAndTestImpact.testsettings
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.sln

    r4982 r4997  
    1010Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F96C8DD1-9B68-4F2D-AD4F-1A174F596041}"
    1111  ProjectSection(SolutionItems) = preProject
     12    HeuristicLab.MetaOptimization.vsmdi = HeuristicLab.MetaOptimization.vsmdi
     13    Local.testsettings = Local.testsettings
    1214    PreBuildEvent.cmd = PreBuildEvent.cmd
     15    TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings
    1316  EndProjectSection
    1417EndProject
     18Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.MetaOptimization.Tests", "HeuristicLab.MetaOptimization.Tests\HeuristicLab.MetaOptimization.Tests.csproj", "{7978A3C0-5166-4392-B00F-58AA3C31E107}"
     19EndProject
    1520Global
     21  GlobalSection(TestCaseManagementSettings) = postSolution
     22    CategoryFile = HeuristicLab.MetaOptimization.vsmdi
     23  EndGlobalSection
    1624  GlobalSection(SolutionConfigurationPlatforms) = preSolution
    1725    Debug|Any CPU = Debug|Any CPU
     
    5361    {0E232F46-FD0B-4FEA-8C22-AF18DE0D151E}.Release|x86.ActiveCfg = Release|x86
    5462    {0E232F46-FD0B-4FEA-8C22-AF18DE0D151E}.Release|x86.Build.0 = Release|x86
     63    {7978A3C0-5166-4392-B00F-58AA3C31E107}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     64    {7978A3C0-5166-4392-B00F-58AA3C31E107}.Debug|Any CPU.Build.0 = Debug|Any CPU
     65    {7978A3C0-5166-4392-B00F-58AA3C31E107}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
     66    {7978A3C0-5166-4392-B00F-58AA3C31E107}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
     67    {7978A3C0-5166-4392-B00F-58AA3C31E107}.Debug|x86.ActiveCfg = Debug|Any CPU
     68    {7978A3C0-5166-4392-B00F-58AA3C31E107}.Release|Any CPU.ActiveCfg = Release|Any CPU
     69    {7978A3C0-5166-4392-B00F-58AA3C31E107}.Release|Any CPU.Build.0 = Release|Any CPU
     70    {7978A3C0-5166-4392-B00F-58AA3C31E107}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
     71    {7978A3C0-5166-4392-B00F-58AA3C31E107}.Release|Mixed Platforms.Build.0 = Release|Any CPU
     72    {7978A3C0-5166-4392-B00F-58AA3C31E107}.Release|x86.ActiveCfg = Release|Any CPU
    5573  EndGlobalSection
    5674  GlobalSection(SolutionProperties) = preSolution
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/OptimizableView.cs

    r4984 r4997  
    5050            this.viewHost.Content = ((IParameterConfiguration)Content).ValueConfigurations;
    5151          } else if (Content is IValueConfiguration) {
    52             if (Content.ConstrainedValue.ValueDataType == typeof(IntValue) ||
    53                 Content.ConstrainedValue.ValueDataType == typeof(DoubleValue) ||
    54                 Content.ConstrainedValue.ValueDataType == typeof(PercentValue)) {
     52            if (Content.ActualValue.ValueDataType == typeof(IntValue) ||
     53                Content.ActualValue.ValueDataType == typeof(DoubleValue) ||
     54                Content.ActualValue.ValueDataType == typeof(PercentValue)) {
    5555              this.viewHost.Content = ((IValueConfiguration)Content).RangeConstraint;
    56             } else if(Content.ConstrainedValue.ValueDataType == typeof(BoolValue)) {
     56            } else if(Content.ActualValue.ValueDataType == typeof(BoolValue)) {
    5757              this.viewHost.Content = null; // no configuration required
    5858            } else {
     
    6363          }
    6464        } else {
    65           this.viewHost.Content = Content.ConstrainedValue;
     65          this.viewHost.Content = Content.ActualValue;
    6666        }
    6767      }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Creators/RandomParameterConfigurationCreator.cs

    r4839 r4997  
    2020      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    2121    }
    22     public ILookupParameter<IParameterConfiguration> ParameterConfigurationParameter {
    23       get { return (ILookupParameter<IParameterConfiguration>)Parameters["ParameterConfiguration"]; }
     22    public ILookupParameter<IValueConfiguration> ValueConfigurationParameter {
     23      get { return (ILookupParameter<IValueConfiguration>)Parameters["ValueConfiguration"]; }
    2424    }
    2525
    26     public ILookupParameter<IParameterConfiguration> NewParameterConfigurationParameter {
    27       get { return (ILookupParameter<IParameterConfiguration>)Parameters["NewParameterConfiguration"]; }
     26    public ILookupParameter<IValueConfiguration> NewValueConfigurationParameter {
     27      get { return (ILookupParameter<IValueConfiguration>)Parameters["NewValueConfiguration"]; }
    2828    }
    2929
     
    3131    private RandomParameterConfigurationCreator(bool deserializing) : base(deserializing) { }
    3232    private RandomParameterConfigurationCreator(RandomParameterConfigurationCreator original, Cloner cloner) : base(original, cloner) { }
    33     public RandomParameterConfigurationCreator()
    34       : base() {
    35         Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used to initialize the new random permutation."));
    36         Parameters.Add(new LookupParameter<IParameterConfiguration>("ParameterConfiguration", "The new random parameter set."));
     33    public RandomParameterConfigurationCreator() : base() {
     34      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used to initialize the new random permutation."));
     35      Parameters.Add(new LookupParameter<IValueConfiguration>("ValueConfiguration", "The new random parameter set."));
    3736    }
    3837    public override IDeepCloneable Clone(Cloner cloner) {
     
    4140
    4241    public override IOperation Apply() {
    43       NewParameterConfigurationParameter.ActualValue = (IParameterConfiguration)ParameterConfigurationParameter.ActualValue.Clone();
    44       //NewParameterConfigurationParameter.ActualValue.Randomize();
     42      NewValueConfigurationParameter.ActualValue = (IValueConfiguration)ValueConfigurationParameter.ActualValue.Clone();
     43      NewValueConfigurationParameter.ActualValue.Randomize();
     44      NewValueConfigurationParameter.ActualValue.Parameterize();
    4545      return base.Apply();
    4646    }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/Crossovers/ParameterConfigurationCrossover.cs

    r4839 r4997  
    7373      IntegerVector integerChild = HeuristicLab.Encodings.IntegerVectorEncoding.DiscreteCrossover.Apply(
    7474        RandomParameter.ActualValue,
    75         new IntegerVector(new IntArray(new int[] { ((IntValue)parameter1.ActualValueConfiguration).Value })),
    76         new IntegerVector(new IntArray(new int[] { ((IntValue)parameter2.ActualValueConfiguration).Value })));
     75        new IntegerVector(new IntArray(new int[] { ((IntValue)parameter1.ActualValue.Value).Value })),
     76        new IntegerVector(new IntArray(new int[] { ((IntValue)parameter2.ActualValue.Value).Value })));
    7777      return new IntValue(integerChild[0]);
    7878    }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/ParameterConfigurations/ParameterConfiguration.cs

    r4984 r4997  
    8080    }
    8181
    82     // todo: chooses one of the parameter configurations as actual value
    83     protected IValueConfiguration actualValueConfiguration;
    84     public IValueConfiguration ActualValueConfiguration {
    85       get { return this.actualValueConfiguration; }
    86       set { this.actualValueConfiguration = value; }
    87     }
    88 
    89     public ConstrainedValue ConstrainedValue {
    90       get { return actualValueConfiguration.ConstrainedValue; }
    91       set { actualValueConfiguration.ConstrainedValue = value; }
     82    protected int actualValueConfigurationIndex = 0;
     83
     84    protected ConstrainedValue actualValue;
     85    public ConstrainedValue ActualValue {
     86      get { return actualValue; }
     87      set { actualValue = value; }
    9288    }
    9389   
     
    10399      this.validValues = GetValidValues();
    104100      this.ValueConfigurations = new CheckedValueConfigurationCollection(this.valueDataType);
    105       this.ActualValueConfiguration = new ValueConfiguration(valueParameter.Value, valueParameter.DataType);
     101      this.ActualValue = new ConstrainedValue(valueParameter.Value, valueParameter.DataType);
    106102      if (Optimize) {
    107103        PopulateValueConfigurations();
     
    112108    [StorableConstructor]
    113109    protected ParameterConfiguration(bool deserializing) { }
    114     protected ParameterConfiguration(ParameterConfiguration original, Cloner cloner)
    115       : base(original, cloner) {
    116       this.ParameterName = original.ParameterName;
     110    protected ParameterConfiguration(ParameterConfiguration original, Cloner cloner) : base(original, cloner) {
     111      this.parameterName = original.ParameterName;
    117112      this.parameterDataType = original.parameterDataType;
    118113      this.parameter = cloner.Clone(original.parameter);
    119       this.ValueDataType = original.ValueDataType;
    120       this.ValidValues = original.ValidValues.Select(x => cloner.Clone(x));
     114      this.valueDataType = original.ValueDataType;
     115      this.validValues = original.ValidValues.Select(x => cloner.Clone(x));
    121116      this.ValueConfigurations = cloner.Clone(original.ValueConfigurations);
    122       this.ActualValueConfiguration = cloner.Clone(original.ActualValueConfiguration);
    123       this.Optimize = original.optimize;
     117      this.ActualValue = cloner.Clone(original.ActualValue);
     118      this.optimize = original.optimize;
    124119    }
    125120    public override IDeepCloneable Clone(Cloner cloner) {
     
    143138      foreach (IItem validValue in this.validValues) {
    144139        IItem val;
    145         if (actualValueConfiguration.ConstrainedValue.Value != null && actualValueConfiguration.ConstrainedValue.ValueDataType == validValue.GetType()) {
    146           val = actualValueConfiguration.ConstrainedValue.Value; // use existing value for that type (if available)
     140        if (ActualValue.Value != null && ActualValue.ValueDataType == validValue.GetType()) {
     141          val = ActualValue.Value; // use existing value for that type (if available)
    147142        } else {
    148143          val = validValue;
     
    228223        return string.Format("{0}: (Optimize: {1})", ParameterName, ValueConfigurations.CheckedItems.Count());
    229224      } else {
    230         return string.Format("{0}: {1}", ParameterName, ConstrainedValue.Value);
     225        return string.Format("{0}: {1}", ParameterName, ActualValue.Value);
    231226      }
    232227    }
     
    239234      return null;
    240235    }
     236
     237    public void Parameterize() {
     238      this.parameter.ActualValue = this.ActualValue.Value;
     239    }
     240
     241    public void Randomize() {
     242      if (Optimize) {
     243        Random rand = new Random(); // todo: use global random
     244        actualValueConfigurationIndex = rand.Next(ValueConfigurations.CheckedItems.Count());
     245        this.ValueConfigurations.CheckedItems.ElementAt(actualValueConfigurationIndex).Randomize();
     246        this.ActualValue = this.ValueConfigurations.CheckedItems.ElementAt(actualValueConfigurationIndex).ActualValue;
     247      }
     248    }
     249
     250    public void Mutate() {
     251      if (Optimize) {
     252        foreach (IValueConfiguration vc in this.ValueConfigurations.CheckedItems) {
     253          vc.Mutate();
     254        }
     255        this.ActualValue = this.ValueConfigurations.CheckedItems.ElementAt(actualValueConfigurationIndex).ActualValue;
     256      }
     257    }
     258
     259    public void Cross(IOptimizable other) {
     260      if (Optimize) {
     261        IParameterConfiguration otherPc = (IParameterConfiguration)other;
     262        for (int i = 0; i < this.ValueConfigurations.Count; i++) {
     263          this.ValueConfigurations.ElementAt(i).Cross(otherPc.ValueConfigurations.ElementAt(i));
     264        }
     265        this.ActualValue = this.ValueConfigurations.CheckedItems.ElementAt(actualValueConfigurationIndex).ActualValue;
     266      }
     267    }
    241268  }
    242269}
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/RangeConstraints/ConstrainedValue.cs

    r4981 r4997  
    4646    protected ConstrainedValue(ConstrainedValue original, Cloner cloner) : base(original, cloner) {
    4747      this.valueDataType = original.valueDataType;
    48       this.value = cloner.Clone(value);
     48      this.Value = cloner.Clone(original.value);
    4949    }
    5050    public override IDeepCloneable Clone(Cloner cloner) {
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/RangeConstraints/Range.cs

    r4981 r4997  
    77namespace HeuristicLab.Problems.MetaOptimization {
    88  [StorableClass]
    9   public class Range<T> : Item, IRange<T> where T : class, IStringConvertibleValue, IDeepCloneable {
     9  public abstract class Range<T> : Item, IRange<T> where T : class, IItem, IStringConvertibleValue, IDeepCloneable {
    1010    [Storable]
    1111    private T lowerBound;
     
    8484    }
    8585
     86    public Range() { }
    8687    [StorableConstructor]
    8788    protected Range(bool deserializing) : base(deserializing) { }
    88     protected Range(Range<T> original, Cloner cloner)
    89       : base(original, cloner) {
     89    protected Range(Range<T> original, Cloner cloner) : base(original, cloner) {
    9090      this.LowerBound = cloner.Clone(original.LowerBound);
    9191      this.UpperBound = cloner.Clone(original.UpperBound);
    9292      this.StepSize = cloner.Clone(original.StepSize);
    93     }
    94     public override IDeepCloneable Clone(Cloner cloner) {
    95       return new Range<T>(this, cloner);
    9693    }
    9794    #endregion
     
    193190
    194191    #endregion
     192
     193
     194
     195    public abstract T GetRandomValue();
     196
     197    #region IRange Members
     198
     199
     200    IItem IRange.GetRandomValue() {
     201      return GetRandomValue();
     202    }
     203
     204    #endregion
    195205  }
    196206}
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/ValueConfigurations/ValueConfiguration.cs

    r4984 r4997  
    4545    }
    4646
    47     protected ConstrainedValue constrainedValue;
    48     public ConstrainedValue ConstrainedValue {
    49       get { return constrainedValue; }
     47    protected ConstrainedValue actualValue;
     48    public ConstrainedValue ActualValue {
     49      get { return actualValue; }
    5050      set {
    51         if (this.constrainedValue != value) {
     51        if (this.actualValue != value) {
    5252          ClearParameterConfigurations();
    53           this.constrainedValue = value;
     53          this.actualValue = value;
    5454          PopulateParameterConfigurations();
    5555          OnValueChanged();
     
    6767    public ValueConfiguration(IItem value, Type valueDataType) {
    6868      this.ParameterConfigurations = new ItemList<IParameterConfiguration>();
    69       this.ConstrainedValue = new ConstrainedValue(value, valueDataType);
     69      this.ActualValue = new ConstrainedValue(value, valueDataType);
    7070      this.IsOptimizable = true;
    71       if (constrainedValue.ValueDataType == typeof(IntValue)) {
    72         rangeConstraint = new Range<IntValue>(new IntValue(0), (IntValue)value, new IntValue(1));
    73       } else if (constrainedValue.ValueDataType == typeof(DoubleValue)) {
    74         rangeConstraint = new Range<DoubleValue>(new DoubleValue(0), (DoubleValue)value, new DoubleValue(0.01));
    75       } else if (constrainedValue.ValueDataType == typeof(PercentValue)) {
    76         rangeConstraint = new Range<PercentValue>(new PercentValue(0), new PercentValue(1), new PercentValue(0.001));
    77       } else if (constrainedValue.ValueDataType == typeof(BoolValue)) {
     71      if (actualValue.ValueDataType == typeof(IntValue)) {
     72        rangeConstraint = new IntValueRange(new IntValue(0), (IntValue)value, new IntValue(1));
     73      } else if (actualValue.ValueDataType == typeof(DoubleValue)) {
     74        rangeConstraint = new DoubleValueRange(new DoubleValue(0), (DoubleValue)value, new DoubleValue(0.01));
     75      } else if (actualValue.ValueDataType == typeof(PercentValue)) {
     76        rangeConstraint = new PercentValueRange(new PercentValue(0), new PercentValue(1), new PercentValue(0.001));
     77      } else if (actualValue.ValueDataType == typeof(BoolValue)) {
    7878        this.IsOptimizable = false; // there is nothing to configure for bools
    7979      } else {
     
    8787    protected ValueConfiguration(bool deserializing) { }
    8888    protected ValueConfiguration(ValueConfiguration original, Cloner cloner) : base(original, cloner) {
    89       this.ParameterConfigurations = cloner.Clone(original.ParameterConfigurations);
    90       this.ConstrainedValue = cloner.Clone(original.ConstrainedValue);
     89      this.ParameterConfigurations = cloner.Clone(original.parameterConfigurations);
     90      this.actualValue = cloner.Clone(original.ActualValue);
    9191      this.rangeConstraint = cloner.Clone(original.RangeConstraint);
    92       this.IsOptimizable = original.IsOptimizable;
     92      this.isOptimizable = original.isOptimizable;
     93      this.optimize = original.optimize;
    9394      RegisterEvents();
    9495    }
     
    99100
    100101    protected virtual void PopulateParameterConfigurations() {
    101       if (this.constrainedValue.Value is IParameterizedNamedItem) {
    102         var parameterizedItem = this.constrainedValue.Value as IParameterizedNamedItem;
     102      if (this.actualValue.Value is IParameterizedNamedItem) {
     103        var parameterizedItem = this.actualValue.Value as IParameterizedNamedItem;
    103104        foreach (var childParameter in parameterizedItem.Parameters) {
    104105          var pc = ParameterConfiguration.Create(parameterizedItem, childParameter);
     
    113114    private void RegisterEvents() {
    114115      if (this.RangeConstraint != null) this.RangeConstraint.ToStringChanged += new EventHandler(RangeConstraint_ToStringChanged);
    115       if (this.ConstrainedValue != null) this.ConstrainedValue.ToStringChanged += new EventHandler(ConstrainedValue_ToStringChanged);
     116      if (this.ActualValue != null) this.ActualValue.ToStringChanged += new EventHandler(ConstrainedValue_ToStringChanged);
    116117    }
    117118    private void DeregisterEvents() {
    118119      if (this.RangeConstraint != null) this.RangeConstraint.ToStringChanged += new EventHandler(RangeConstraint_ToStringChanged);
    119       if (this.ConstrainedValue != null) this.ConstrainedValue.ToStringChanged += new EventHandler(ConstrainedValue_ToStringChanged);
     120      if (this.ActualValue != null) this.ActualValue.ToStringChanged += new EventHandler(ConstrainedValue_ToStringChanged);
    120121    }
    121122
     
    129130    #region IItem Members
    130131    public override string ItemDescription {
    131       get { return (constrainedValue != null && constrainedValue.Value != null) ? constrainedValue.Value.ItemDescription : base.ItemDescription; }
     132      get { return (actualValue != null && actualValue.Value != null) ? actualValue.Value.ItemDescription : base.ItemDescription; }
    132133    }
    133134
    134135    public override Image ItemImage {
    135       get { return (constrainedValue != null && constrainedValue.Value != null) ? constrainedValue.Value.ItemImage : base.ItemImage; }
     136      get { return (actualValue != null && actualValue.Value != null) ? actualValue.Value.ItemImage : base.ItemImage; }
    136137    }
    137138
    138139    public override string ItemName {
    139       get { return (constrainedValue != null && constrainedValue.Value != null) ? constrainedValue.Value.ItemDescription : base.ItemName; }
     140      get { return (actualValue != null && actualValue.Value != null) ? actualValue.Value.ItemDescription : base.ItemName; }
    140141    }
    141142    #endregion
     
    162163
    163164    public override string ToString() {
    164       if (ConstrainedValue != null && ConstrainedValue.Value != null) {
    165         if (ConstrainedValue.Value is IParameterizedItem) {
     165      if (ActualValue != null && ActualValue.Value != null) {
     166        if (ActualValue.Value is IParameterizedItem) {
    166167          if (Optimize) {
    167             return string.Format("{0} (Optimize)", ConstrainedValue.Value.ItemName);
    168           } else {
    169             return string.Format("{0}", ConstrainedValue.Value.ItemName);
     168            return string.Format("{0} (Optimize)", ActualValue.Value.ItemName);
     169          } else {
     170            return string.Format("{0}", ActualValue.Value.ItemName);
    170171          }
    171172        } else {
    172173          if (Optimize) {
    173             return string.Format("{0} (Optimize: {1})", ConstrainedValue.Value.ItemName, RangeConstraint);
    174           } else {
    175             return string.Format("{0}: {1}", ConstrainedValue.Value.ItemName, ConstrainedValue.Value);
     174            return string.Format("{0} (Optimize: {1})", ActualValue.Value.ItemName, RangeConstraint);
     175          } else {
     176            return string.Format("{0}: {1}", ActualValue.Value.ItemName, ActualValue.Value);
    176177          }
    177178        }
     
    180181      }
    181182    }
     183   
     184    public void Parameterize() {
     185      foreach (IParameterConfiguration pc in this.ParameterConfigurations) {
     186        pc.Parameterize();
     187      }
     188    }
     189
     190    public void Randomize() {
     191      if (Optimize) {
     192        if (rangeConstraint != null) {
     193          this.actualValue.Value = rangeConstraint.GetRandomValue();
     194        } else {
     195          foreach (IParameterConfiguration pc in this.ParameterConfigurations) {
     196            pc.Randomize();
     197          }
     198        }
     199      }
     200    }
     201
     202    public void Mutate() {
     203      if (Optimize) {
     204        if (rangeConstraint != null) {
     205          Random rand = new Random(); // todo: use common random
     206          // mutate every other value. todo: use some kind of mutation operator which is exchangable
     207          if(rand.NextDouble() > 0.5)
     208            this.actualValue.Value = rangeConstraint.GetRandomValue();
     209        } else {
     210          foreach (IParameterConfiguration pc in this.ParameterConfigurations) {
     211            pc.Mutate();
     212          }
     213        }
     214      }
     215    }
     216
     217    public void Cross(IOptimizable other) {
     218      if (Optimize) {
     219        IValueConfiguration otherVc = (IValueConfiguration)other;
     220        if (rangeConstraint != null) {
     221          if (this.actualValue.ValueDataType == typeof(IntValue)) {
     222            this.actualValue.Value = new IntValue((((IntValue)this.actualValue.Value).Value + ((IntValue)other.ActualValue.Value).Value) / 2);
     223          } else if (this.actualValue.ValueDataType == typeof(DoubleValue)) {
     224            this.actualValue.Value = new DoubleValue((((DoubleValue)this.actualValue.Value).Value + ((DoubleValue)other.ActualValue.Value).Value) / 2);
     225          } else if (this.actualValue.ValueDataType == typeof(PercentValue)) {
     226            this.actualValue.Value = new PercentValue((((PercentValue)this.actualValue.Value).Value + ((PercentValue)other.ActualValue.Value).Value) / 2);
     227          } else if (this.actualValue.ValueDataType == typeof(BoolValue)) {
     228            bool first = ((BoolValue)this.actualValue.Value).Value;
     229            bool second = ((BoolValue)other.ActualValue.Value).Value;
     230            if (first && second) {
     231              this.actualValue.Value = new BoolValue(true);
     232            } else if (!first && !second) {
     233              this.actualValue.Value = new BoolValue(false);
     234            } else {
     235              Random rand = new Random(); // todo: use common random
     236              if(rand.NextDouble() > 0.5)
     237                this.actualValue.Value = new BoolValue(true);
     238              else
     239                this.actualValue.Value = new BoolValue(false);
     240            }
     241          } else {
     242            throw new NotImplementedException();
     243          }
     244        } else {
     245          for (int i = 0; i < this.ParameterConfigurations.Count; i++) {
     246            this.ParameterConfigurations.ElementAt(i).Cross(otherVc.ParameterConfigurations.ElementAt(i));
     247          }
     248        }
     249      }
     250    }
    182251  }
    183252}
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/MetaOptimizationEvaluator.cs

    r4839 r4997  
    2929      get { return (ILookupParameter<IItemList<IProblem>>)Parameters["Problems"]; }
    3030    }
    31     public ILookupParameter<IParameterConfiguration> ParameterConfigurationParameter {
    32       get { return (ILookupParameter<IParameterConfiguration>)Parameters["ParameterConfiguration"]; }
     31    public ILookupParameter<IValueConfiguration> ParameterConfigurationParameter {
     32      get { return (ILookupParameter<IValueConfiguration>)Parameters["ValueConfiguration"]; }
    3333    }
    3434    public ValueParameter<IntValue> RepetitionsParameter {
     
    4545      Parameters.Add(new LookupParameter<IAlgorithm>("Algorithm", "Missing description."));
    4646      Parameters.Add(new LookupParameter<IItemList<IProblem>>("Problems", "Missing description."));
    47       Parameters.Add(new LookupParameter<IParameterConfiguration>("ParameterConfiguration", "Missing description."));
     47      Parameters.Add(new LookupParameter<IValueConfiguration>("ValueConfiguration", "Missing description."));
    4848      Parameters.Add(new ValueParameter<IntValue>(RepetitionsParameterName, "Number of evaluations for one individual.", new IntValue(3)));
    4949    }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/HeuristicLab.Problems.MetaOptimization-3.3.csproj

    r4982 r4997  
    9393      <SubType>Code</SubType>
    9494    </Compile>
     95    <Compile Include="Encodings\RangeConstraints\PercentValueRange.cs" />
     96    <Compile Include="Encodings\RangeConstraints\DoubleValueRange.cs" />
     97    <Compile Include="Encodings\RangeConstraints\IntValueRange.cs" />
    9598    <Compile Include="Encodings\ValueConfigurations\RootValueConfiguration.cs" />
    9699    <Compile Include="Encodings\ValueConfigurations\ValueConfiguration.cs" />
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/IOptimizable.cs

    r4984 r4997  
    1010    bool IsOptimizable { get; }
    1111    bool Optimize { get; set; }
    12     ConstrainedValue ConstrainedValue { get; set; }
     12    ConstrainedValue ActualValue { get; set; }
     13
     14    void Parameterize();
     15    void Randomize();
     16    void Mutate();
     17    void Cross(IOptimizable other);
    1318
    1419    event EventHandler IsOptimizableChanged;
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/IParameterConfiguration.cs

    r4981 r4997  
    1010    Type ParameterDataType { get; }
    1111    ICheckedValueConfigurationCollection ValueConfigurations { get; }
    12     IValueConfiguration ActualValueConfiguration { get; set; }
    1312    IEnumerable<IItem> ValidValues { get; }
    1413  }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/IRange.cs

    r4981 r4997  
    1313    event EventHandler UpperBoundChanged;
    1414    event EventHandler StepSizeChanged;
     15
     16    IItem GetRandomValue();
    1517  }
    1618
     
    1921    new T UpperBound { get; set; }
    2022    new T StepSize { get; set; }
     23    new T GetRandomValue();
    2124  }
    2225}
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/IValueConfiguration.cs

    r4981 r4997  
    88    IRange RangeConstraint { get; }
    99    event EventHandler ValueChanged;
     10
    1011  }
    1112}
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/MetaOptimizationProblem.cs

    r4982 r4997  
    119119    private void ParameterizeSolutionCreator() {
    120120      //SolutionCreator.ParametersToOptimize = this.ParametersToOptimize;
     121     
    121122    }
    122123    private void ParameterizeEvaluator() {
    123       ((MetaOptimizationEvaluator)Evaluator).ParameterConfigurationParameter.ActualName = ((RandomParameterConfigurationCreator)SolutionCreator).ParameterConfigurationParameter.ActualName;
     124      ((MetaOptimizationEvaluator)Evaluator).ParameterConfigurationParameter.ActualName = ((RandomParameterConfigurationCreator)SolutionCreator).ValueConfigurationParameter.ActualName;
    124125    }
    125126    private void ParameterizeAnalyzer() {
Note: See TracChangeset for help on using the changeset viewer.