Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/11/11 16:00:17 (14 years ago)
Author:
cneumuel
Message:

#1215

  • implemented crossover and manipulator operators for int and double values
Location:
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/Crossovers/ParameterConfigurationCrossover.cs

    r5207 r5277  
    5858      ParameterConfigurationTree child2 = (ParameterConfigurationTree)ParentsParameter.ActualValue[1];
    5959
    60       child1.Cross(RandomParameter.ActualValue, child2, Cross, this);
     60      child1.Cross(RandomParameter.ActualValue, child2, Cross, IntValueCrossoverParameter.ActualValue, DoubleValueCrossoverParameter.ActualValue);
    6161      this.ChildParameter.ActualValue = child1;
    6262
     
    6464    }
    6565
    66     private static void Cross(IRandom random, IOptimizable configuartion, ParameterConfigurationCrossover pccross) {
    67       if (configuartion is IValueConfiguration) {
    68         var vc = configuartion as IValueConfiguration;
     66    public static void Apply(IRandom random, IOptimizable configuartion, IOptimizable other, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover) {
     67      configuartion.Cross(random, other, Cross, intValueCrossover, doubleValueCrossover);
     68    }
     69
     70    private static void Cross(IRandom random, IOptimizable configuartion, IOptimizable other, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover) {
     71      var vc = configuartion as IValueConfiguration;
     72      var pc = configuartion as IParameterConfiguration;
     73      if (vc != null) {
    6974        var value = vc.ActualValue.Value;
    7075        var range = vc.RangeConstraint;
    7176
    7277        if (value is IntValue) {
    73           pccross.IntValueCrossoverParameter.ActualValue.Apply(random, (IntValue)value, (IntValueRange)range);
     78          intValueCrossover.Apply(random, (IntValue)value, (IntValue)((IValueConfiguration)other).ActualValue.Value, (IntValueRange)range);
    7479        } else if (value is PercentValue) {
    75           pccross.DoubleValueCrossoverParameter.ActualValue.Apply(random, (PercentValue)value, ((PercentValueRange)range).AsDoubleValueRange());
     80          doubleValueCrossover.Apply(random, (PercentValue)value, (DoubleValue)((IValueConfiguration)other).ActualValue.Value, ((PercentValueRange)range).AsDoubleValueRange());
    7681        } else if (value is DoubleValue) {
    77           pccross.DoubleValueCrossoverParameter.ActualValue.Apply(random, (DoubleValue)value, (DoubleValueRange)range);
     82          doubleValueCrossover.Apply(random, (DoubleValue)value, (DoubleValue)((IValueConfiguration)other).ActualValue.Value, (DoubleValueRange)range);
    7883        }
    79       } else if (configuartion is IParameterConfiguration) {
    80 
     84      } else if (pc != null) {
     85        if (random.NextDouble() > 0.5) {
     86          pc.ActualValueConfigurationIndex = ((ParameterConfiguration)other).ActualValueConfigurationIndex;
     87        }
     88        pc.ActualValue = pc.ValueConfigurations[pc.ActualValueConfigurationIndex].ActualValue;
    8189      }
    8290    }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/Manipulators/ParameterConfigurationManipulator.cs

    r5112 r5277  
    4949
    5050    public sealed override IOperation Apply() {
    51       Apply(RandomParameter.ActualValue, ParameterConfigurationTreeParameter.ActualValue, this);
     51      Apply(RandomParameter.ActualValue, ParameterConfigurationTreeParameter.ActualValue, IntValueManipulatorParameter.ActualValue, DoubleValueManipulatorParameter.ActualValue);
    5252      return base.Apply();
    5353    }
    5454
    55     public static void Apply(IRandom random, IValueConfiguration configuration, ParameterConfigurationManipulator pcmanip) {
    56       configuration.Mutate(random, Mutate, pcmanip);
     55    public static void Apply(IRandom random, IValueConfiguration configuration, IIntValueManipulator intValueManipulator, IDoubleValueManipulator doubleValueManipulator) {
     56      configuration.Mutate(random, Mutate, intValueManipulator, doubleValueManipulator);
    5757    }
    5858
    59     private static void Mutate(IRandom random, IOptimizable configuration, ParameterConfigurationManipulator pcmanip) {
    60       if (configuration is IValueConfiguration) {
    61         var vc = configuration as IValueConfiguration;
     59    private static void Mutate(IRandom random, IOptimizable configuration, IIntValueManipulator intValueManipulator, IDoubleValueManipulator doubleValueManipulator) {
     60      var vc = configuration as IValueConfiguration;
     61      var pc = configuration as IParameterConfiguration;
     62
     63      if (vc != null) {
    6264        var value = vc.ActualValue.Value;
    6365        var range = vc.RangeConstraint;
    6466        if (value is IntValue) {
    65           pcmanip.IntValueManipulatorParameter.ActualValue.Apply(random, (IntValue)value, (IntValueRange)range);
     67          intValueManipulator.Apply(random, (IntValue)value, (IntValueRange)range);
    6668        } else if (value is PercentValue) {
    67           pcmanip.DoubleValueManipulatorParameter.ActualValue.Apply(random, (PercentValue)value, ((PercentValueRange)range).AsDoubleValueRange());
     69          doubleValueManipulator.Apply(random, (PercentValue)value, ((PercentValueRange)range).AsDoubleValueRange());
    6870        } else if (value is DoubleValue) {
    69           pcmanip.DoubleValueManipulatorParameter.ActualValue.Apply(random, (DoubleValue)value, (DoubleValueRange)range);
     71          doubleValueManipulator.Apply(random, (DoubleValue)value, (DoubleValueRange)range);
    7072        }
    71       } else if (configuration is IParameterConfiguration) {
    72         var pc = configuration as IParameterConfiguration;
    73         pc.ActualValueConfigurationIndex = random.Next(pc.ValueConfigurations.CheckedItems.Count());
    74         pc.ActualValue = pc.ValueConfigurations.CheckedItems.ElementAt(pc.ActualValueConfigurationIndex).ActualValue;
     73      } else if (pc != null) {
     74        do {
     75          pc.ActualValueConfigurationIndex = random.Next(pc.ValueConfigurations.Count());
     76        } while (!pc.ValueConfigurations.ItemChecked(pc.ValueConfigurations[pc.ActualValueConfigurationIndex]));
     77        pc.ActualValue = pc.ValueConfigurations[pc.ActualValueConfigurationIndex].ActualValue;
    7578      }
    7679    }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterCombinationsEnumerator.cs

    r5184 r5277  
    8282
    8383        foreach (var valueConfiguration in pc.ValueConfigurations.CheckedItems) {
    84           if (valueConfiguration.Optimize) {
    85             var enumerator = new ParameterCombinationsEnumerator(valueConfiguration);
     84          if (valueConfiguration.Value.Optimize) {
     85            var enumerator = new ParameterCombinationsEnumerator(valueConfiguration.Value);
    8686            enumerator.Reset();
    8787            valueEnumerator.AddEnumerator(enumerator);
    8888          } else {
    89             valueEnumerator.AddEnumerator(new List<IItem> { valueConfiguration }.GetEnumerator());
     89            valueEnumerator.AddEnumerator(new List<IItem> { valueConfiguration.Value }.GetEnumerator());
    9090          }
    9191        }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs

    r5267 r5277  
    1212using System.Reflection;
    1313using HeuristicLab.Optimization;
     14using HeuristicLab.Collections;
    1415
    1516namespace HeuristicLab.Problems.MetaOptimization {
     
    7879
    7980    [Storable]
    80     protected ICheckedValueConfigurationCollection valueConfigurations;
    81     public ICheckedValueConfigurationCollection ValueConfigurations {
     81    protected ICheckedValueConfigurationList valueConfigurations;
     82    public ICheckedValueConfigurationList ValueConfigurations {
    8283      get { return this.valueConfigurations; }
    8384      protected set {
     
    135136        validTypes = new List<Type>(validTypes) { typeof(NullValue) }.ToArray();
    136137      }
    137       this.ValueConfigurations = new CheckedValueConfigurationCollection();
     138      this.ValueConfigurations = new CheckedValueConfigurationList();
    138139      this.ActualValue = new ConstrainedValue(
    139140        valueParameter.Value != null ? (IItem)valueParameter.Value.Clone() : null,
     
    173174
    174175    private void RegisterValueConfigurationEvents() {
    175       this.ValueConfigurations.CheckedItemsChanged += new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(ValueConfigurations_CheckedItemsChanged);
    176       this.ValueConfigurations.ItemsAdded += new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(ValueConfigurations_ItemsAdded);
    177       this.ValueConfigurations.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(ValueConfigurations_ItemsRemoved);
     176      this.ValueConfigurations.CheckedItemsChanged += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(ValueConfigurations_CheckedItemsChanged);
     177      this.ValueConfigurations.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(ValueConfigurations_ItemsAdded);
     178      this.ValueConfigurations.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(ValueConfigurations_ItemsRemoved);
    178179    }
    179180
    180181    private void DeregisterValueConfigurationEvents() {
    181       this.ValueConfigurations.CheckedItemsChanged -= new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(ValueConfigurations_CheckedItemsChanged);
    182       this.ValueConfigurations.ItemsAdded -= new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(ValueConfigurations_ItemsAdded);
    183       this.ValueConfigurations.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(ValueConfigurations_ItemsRemoved);
     182      this.ValueConfigurations.CheckedItemsChanged -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(ValueConfigurations_CheckedItemsChanged);
     183      this.ValueConfigurations.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(ValueConfigurations_ItemsAdded);
     184      this.ValueConfigurations.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(ValueConfigurations_ItemsRemoved);
    184185    }
    185186
     
    268269    }
    269270
    270     void ValueConfigurations_CheckedItemsChanged(object sender, Collections.CollectionItemsChangedEventArgs<IValueConfiguration> e) {
     271    void ValueConfigurations_CheckedItemsChanged(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) {
    271272      OnToStringChanged();
    272273    }
    273     void ValueConfigurations_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IValueConfiguration> e) {
     274    void ValueConfigurations_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) {
    274275      OnToStringChanged();
    275276    }
    276     void ValueConfigurations_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IValueConfiguration> e) {
     277    void ValueConfigurations_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) {
    277278      OnToStringChanged();
    278279    }
     
    360361
    361362          if (this.ActualValue.Value is IParameterizedItem) {
    362             string subParams = this.ValueConfigurations.CheckedItems.ElementAt(actualValueConfigurationIndex).ParameterInfoString;
     363            string subParams = this.ValueConfigurations[actualValueConfigurationIndex].ParameterInfoString;
    363364            if (!string.IsNullOrEmpty(subParams)) {
    364365              sb.Append(" (");
     
    383384      if (Optimize) {
    384385        if (this.ActualValue.Value is IParameterizedItem) {
    385           this.ValueConfigurations.CheckedItems.ElementAt(actualValueConfigurationIndex).Parameterize((IParameterizedItem)this.ActualValue.Value);
     386          this.ValueConfigurations[actualValueConfigurationIndex].Parameterize((IParameterizedItem)this.ActualValue.Value);
    386387        }
    387388      }
     
    410411    public void Randomize(IRandom random) {
    411412      if (Optimize) {
    412         foreach (var vc in this.ValueConfigurations.CheckedItems) {
    413           vc.Randomize(random);
    414         }
    415         actualValueConfigurationIndex = random.Next(ValueConfigurations.CheckedItems.Count());
    416         this.ActualValue = this.ValueConfigurations.CheckedItems.ElementAt(actualValueConfigurationIndex).ActualValue;
    417       }
    418     }
    419 
    420     public void Mutate(IRandom random, MutateDelegate mutate, ParameterConfigurationManipulator pcmanip) {
    421       if (Optimize) {
    422         foreach (IValueConfiguration vc in this.ValueConfigurations.CheckedItems) {
    423           vc.Mutate(random, mutate, pcmanip);
    424         }
    425         mutate(random, this, pcmanip);
    426       }
    427     }
    428 
    429     public void Cross(IRandom random, IOptimizable other, CrossDelegate cross, ParameterConfigurationCrossover pccross) {
     413        foreach (var vc in this.ValueConfigurations) {
     414          if (this.ValueConfigurations.ItemChecked(vc)) {
     415            vc.Randomize(random);
     416          }
     417        }
     418        do {
     419          actualValueConfigurationIndex = random.Next(ValueConfigurations.Count());
     420        } while (!this.ValueConfigurations.ItemChecked(this.ValueConfigurations[actualValueConfigurationIndex]));
     421        this.ActualValue = this.ValueConfigurations[actualValueConfigurationIndex].ActualValue;
     422      }
     423    }
     424
     425    public void Mutate(IRandom random, MutateDelegate mutate, IIntValueManipulator intValueManipulator, IDoubleValueManipulator doubleValueManipulator) {
     426      if (Optimize) {
     427        foreach (var vc in this.ValueConfigurations) {
     428          if (this.ValueConfigurations.ItemChecked(vc)) {
     429            vc.Mutate(random, mutate, intValueManipulator, doubleValueManipulator);
     430          }
     431        }
     432        mutate(random, this, intValueManipulator, doubleValueManipulator);
     433      }
     434    }
     435
     436    public void Cross(IRandom random, IOptimizable other, CrossDelegate cross, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover) {
    430437      if (Optimize) {
    431438        IParameterConfiguration otherPc = (IParameterConfiguration)other;
    432439        for (int i = 0; i < this.ValueConfigurations.Count; i++) {
    433           cross(random, other, pccross);
    434           //this.ValueConfigurations.ElementAt(i).Cross(otherPc.ValueConfigurations.ElementAt(i), random);
    435         }
    436         //if (random.NextDouble() > 0.5) {
    437         //  actualValueConfigurationIndex = ((ParameterConfiguration)other).actualValueConfigurationIndex;
    438         //}
    439         //this.ActualValue = this.ValueConfigurations.CheckedItems.ElementAt(actualValueConfigurationIndex).ActualValue;
     440          if (this.ValueConfigurations.ItemChecked(this.ValueConfigurations[i])) {
     441            this.ValueConfigurations[i].Cross(random, otherPc.ValueConfigurations[i], cross, intValueCrossover, doubleValueCrossover);
     442          }
     443        }
     444        cross(random, this, other, intValueCrossover, doubleValueCrossover);
    440445      }
    441446    }
    442447
    443448    public void UpdateActualValueIndexToItem(IValueConfiguration vc) {
    444       for (int i = 0; i < this.ValueConfigurations.CheckedItems.Count(); i++) {
    445         if (this.ValueConfigurations.CheckedItems.ElementAt(i) == vc) {
     449      for (int i = 0; i < this.ValueConfigurations.Count(); i++) {
     450        if (this.ValueConfigurations.ElementAt(i) == vc) {
    446451          this.actualValueConfigurationIndex = i;
    447452          return;
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/CheckedValueConfigurationCollection.cs

    r5231 r5277  
    66using HeuristicLab.Common;
    77using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     8using HeuristicLab.Collections;
    89
    910namespace HeuristicLab.Problems.MetaOptimization {
     
    1112  // todo: control creatable item types
    1213  [StorableClass]
    13   public class CheckedValueConfigurationCollection : CheckedItemCollection<IValueConfiguration>, ICheckedValueConfigurationCollection {
     14  public class CheckedValueConfigurationList : CheckedItemList<IValueConfiguration>, ICheckedValueConfigurationList {
    1415    [Storable]
    1516    private int minItemCount = 1;
     
    2425    }
    2526
    26     public CheckedValueConfigurationCollection(ItemSet<IItem> validValues) {
     27    public CheckedValueConfigurationList(ItemSet<IItem> validValues) {
    2728      this.validValues = validValues;
    2829      RegisterEvents();
    2930    }
    30     public CheckedValueConfigurationCollection() {
     31    public CheckedValueConfigurationList() {
    3132      RegisterEvents();
    3233    }
    3334    [StorableConstructor]
    34     protected CheckedValueConfigurationCollection(bool deserializing) : base(deserializing) {
     35    protected CheckedValueConfigurationList(bool deserializing) : base(deserializing) {
    3536      RegisterEvents();
    3637    }
    37     protected CheckedValueConfigurationCollection(CheckedValueConfigurationCollection original, Cloner cloner) : base(original, cloner) {
     38    protected CheckedValueConfigurationList(CheckedValueConfigurationList original, Cloner cloner) : base(original, cloner) {
    3839      this.minItemCount = original.MinItemCount;
    3940      this.validValues = original.validValues;
     
    4142    }
    4243    public override IDeepCloneable Clone(Cloner cloner) {
    43       return new CheckedValueConfigurationCollection(this, cloner);
     44      return new CheckedValueConfigurationList(this, cloner);
    4445    }
    4546    [StorableHook(HookType.AfterDeserialization)]
     
    4950
    5051    private void RegisterEvents() {
    51       this.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(CheckedValueConfigurationCollection_ItemsRemoved);
    52     }
    53     private void DeregisterEvents() {
    54       this.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(CheckedValueConfigurationCollection_ItemsRemoved);
     52      this.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsRemoved);
    5553    }
    5654
    57     private void CheckedValueConfigurationCollection_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IValueConfiguration> e) {
     55    private void DeregisterEvents() {
     56      this.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsRemoved);
     57    }
     58
     59    private void CheckedValueConfigurationList_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) {
    5860      // auch collectionreset gehört berücksichtigt
    5961      // funktioniert so nicht ganz, weil die view das hinzufügen nicht mitkriegt
     
    6668      //}
    6769    }
     70
    6871  }
    6972}
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/ValueConfiguration.cs

    r5231 r5277  
    245245    }
    246246
    247     public void Mutate(IRandom random, MutateDelegate mutate, ParameterConfigurationManipulator pcmanip) {
     247    public void Mutate(IRandom random, MutateDelegate mutate, IIntValueManipulator intValueManipulator, IDoubleValueManipulator doubleValueManipulator) {
    248248      if (Optimize) {
    249249        if (rangeConstraint != null) {
    250           mutate(random, this, pcmanip);
     250          mutate(random, this, intValueManipulator, doubleValueManipulator);
    251251        } else {
    252252          foreach (IParameterConfiguration pc in this.ParameterConfigurations) {
    253             pc.Mutate(random, mutate, pcmanip);
    254           }
    255         }
    256       }
    257     }
    258 
    259     public void Cross(IRandom random, IOptimizable other, CrossDelegate cross, ParameterConfigurationCrossover pccross) {
     253            pc.Mutate(random, mutate, intValueManipulator, doubleValueManipulator);
     254          }
     255        }
     256      }
     257    }
     258
     259    public void Cross(IRandom random, IOptimizable other, CrossDelegate cross, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover) {
    260260      if (Optimize) {
    261         IValueConfiguration otherVc = (IValueConfiguration)other;
    262261        if (rangeConstraint != null) {
    263           cross(random, this, pccross);
    264 
    265           //if (this.actualValue.ValueDataType == typeof(IntValue)) {
    266           //  //this.actualValue.Value = new IntValue((((IntValue)this.actualValue.Value).Value + ((IntValue)other.ActualValue.Value).Value) / 2);
    267 
    268           //  IntegerVector[] parents = new IntegerVector[2];
    269           //  parents[0] = new IntegerVector(new int[] { ((IntValue)this.actualValue.Value).Value });
    270           //  parents[1] = new IntegerVector(new int[] { ((IntValue)other.ActualValue.Value).Value });
    271 
    272           //  this.actualValue.Value = new IntValue(HeuristicLab.Encodings.IntegerVectorEncoding.DiscreteCrossover.Apply(random, parents[0], parents[1]).First());
    273 
    274           //} else if (this.actualValue.ValueDataType == typeof(DoubleValue)) {
    275           //  //this.actualValue.Value = new DoubleValue((((DoubleValue)this.actualValue.Value).Value + ((DoubleValue)other.ActualValue.Value).Value) / 2);
    276           //  RealVector[] parents = new RealVector[2];
    277           //  parents[0] = new RealVector(new double[] { ((DoubleValue)this.actualValue.Value).Value });
    278           //  parents[1] = new RealVector(new double[] { ((DoubleValue)other.ActualValue.Value).Value });
    279 
    280           //  if (random.NextDouble() < 0.5) {
    281           //    this.actualValue.Value = new DoubleValue(AverageCrossover.Apply(random, new ItemArray<RealVector>(parents)).First());
    282           //  } else {
    283           //    this.actualValue.Value = new DoubleValue(HeuristicLab.Encodings.RealVectorEncoding.DiscreteCrossover.Apply(random, new ItemArray<RealVector>(parents)).First());
    284           //  }
    285           //  //this.actualValue.Value = new DoubleValue(AverageCrossover.Apply(random, new ItemArray<RealVector>(parents)).First());
    286 
    287           //} else if (this.actualValue.ValueDataType == typeof(PercentValue)) {
    288           //  //this.actualValue.Value = new PercentValue((((PercentValue)this.actualValue.Value).Value + ((PercentValue)other.ActualValue.Value).Value) / 2);
    289 
    290           //  RealVector[] parents = new RealVector[2];
    291           //  parents[0] = new RealVector(new double[] { ((PercentValue)this.actualValue.Value).Value });
    292           //  parents[1] = new RealVector(new double[] { ((PercentValue)other.ActualValue.Value).Value });
    293 
    294           //  if (random.NextDouble() < 0.5) {
    295           //    this.actualValue.Value = new PercentValue(AverageCrossover.Apply(random, new ItemArray<RealVector>(parents)).First());
    296           //  } else {
    297           //    this.actualValue.Value = new PercentValue(HeuristicLab.Encodings.RealVectorEncoding.DiscreteCrossover.Apply(random, new ItemArray<RealVector>(parents)).First());
    298           //  }
    299 
    300           //} else if (this.actualValue.ValueDataType == typeof(BoolValue)) {
    301           //  if (random.NextDouble() > 0.5)
    302           //    this.actualValue.Value = this.actualValue.Value;
    303           //  else
    304           //    this.actualValue.Value = other.ActualValue.Value;
    305           //} else {
    306           //  throw new NotImplementedException();
    307           //}
    308         } else {
     262          cross(random, this, other, intValueCrossover, doubleValueCrossover);
     263        } else {
     264          IValueConfiguration otherVc = (IValueConfiguration)other;
    309265          for (int i = 0; i < this.ParameterConfigurations.Count; i++) {
    310             this.ParameterConfigurations.ElementAt(i).Cross(random, otherVc.ParameterConfigurations.ElementAt(i), cross, pccross);
     266            this.ParameterConfigurations.ElementAt(i).Cross(random, otherVc.ParameterConfigurations.ElementAt(i), cross, intValueCrossover, doubleValueCrossover);
    311267          }
    312268        }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/HeuristicLab.Problems.MetaOptimization-3.3.csproj

    r5184 r5277  
    149149    <Compile Include="Interfaces\IParameterConfigurationCrossover.cs" />
    150150    <Compile Include="Interfaces\ICheckedValueConfigurationCollection.cs" />
     151    <Compile Include="Operators\Crossovers\AverageDoubleValueCrossover.cs" />
     152    <Compile Include="Operators\Crossovers\DiscreteDoubleValueCrossover.cs" />
    151153    <Compile Include="Operators\Crossovers\DiscreteIntValueCrossover.cs" />
    152154    <Compile Include="Operators\Interfaces\IDoubleValueCrossover.cs" />
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/ICheckedValueConfigurationCollection.cs

    r5110 r5277  
    66
    77namespace HeuristicLab.Problems.MetaOptimization {
    8   public interface ICheckedValueConfigurationCollection : ICheckedItemCollection<IValueConfiguration> {
     8  public interface ICheckedValueConfigurationList : ICheckedItemList<IValueConfiguration> {
    99    int MinItemCount { get; }
    1010    IItemSet<IItem> ValidValues { get; }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/IOptimizable.cs

    r5184 r5277  
    77
    88namespace HeuristicLab.Problems.MetaOptimization {
    9   public delegate void MutateDelegate(IRandom random, IOptimizable configuartion, ParameterConfigurationManipulator pcmanip);
    10   public delegate void CrossDelegate(IRandom random, IOptimizable configuartion, ParameterConfigurationCrossover pccross);
     9  public delegate void MutateDelegate(IRandom random, IOptimizable configuartion, IIntValueManipulator intValueManipulator, IDoubleValueManipulator doubleValueManipulator);
     10  public delegate void CrossDelegate(IRandom random, IOptimizable configuartion, IOptimizable other, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover);
    1111
    1212  public interface IOptimizable : IItem {
     
    1616   
    1717    void Randomize(IRandom random);
    18     void Mutate(IRandom random, MutateDelegate mutate, ParameterConfigurationManipulator pcmanip);
    19     void Cross(IRandom random, IOptimizable other, CrossDelegate cross, ParameterConfigurationCrossover pccross);
     18    void Mutate(IRandom random, MutateDelegate mutate, IIntValueManipulator intValueManipulator, IDoubleValueManipulator doubleValueManipulator);
     19    void Cross(IRandom random, IOptimizable other, CrossDelegate cross, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover);
    2020    string ParameterInfoString { get; }
    2121
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/IParameterConfiguration.cs

    r5207 r5277  
    99    string ParameterName { get; set; }
    1010    Type ParameterDataType { get; }
    11     ICheckedValueConfigurationCollection ValueConfigurations { get; }
     11    ICheckedValueConfigurationList ValueConfigurations { get; }
    1212    Type[] ValidTypes { get; }
    1313    int ActualValueConfigurationIndex { get; set; }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/MetaOptimizationProblem.cs

    r5212 r5277  
    109109      var validIntManipulators = new ItemSet<IIntValueManipulator>( ApplicationManager.Manager.GetInstances<IIntValueManipulator>());
    110110      var validDoubleManipulators = new ItemSet<IDoubleValueManipulator>(ApplicationManager.Manager.GetInstances<IDoubleValueManipulator>());
     111      var validIntCrossovers = new ItemSet<IIntValueCrossover>(ApplicationManager.Manager.GetInstances<IIntValueCrossover>());
     112      var validDoubleCrossovers = new ItemSet<IDoubleValueCrossover>(ApplicationManager.Manager.GetInstances<IDoubleValueCrossover>());
    111113      Parameters.Add(new ConstrainedValueParameter<IIntValueManipulator>(IntValueManipulatorParameterName, "", validIntManipulators, validIntManipulators.First()));
    112114      Parameters.Add(new ConstrainedValueParameter<IDoubleValueManipulator>(DoubleValueManipulatorParameterName, "", validDoubleManipulators, validDoubleManipulators.First()));
     115      Parameters.Add(new ConstrainedValueParameter<IIntValueCrossover>(IntValueCrossoverParameterName, "", validIntCrossovers, validIntCrossovers.First()));
     116      Parameters.Add(new ConstrainedValueParameter<IDoubleValueCrossover>(DoubleValueCrossoverParameterName, "", validDoubleCrossovers, validDoubleCrossovers.Where(x => x.GetType() == typeof(AverageDoubleValueCrossover)).SingleOrDefault()));
    113117
    114118      Maximization = new BoolValue(false);
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Crossovers/DiscreteIntValueCrossover.cs

    r5111 r5277  
    2828    }
    2929
    30     public void Apply(IRandom random, IntValue value, IntValueRange range) {
    31       Apply(random, value, range);
     30    public void Apply(IRandom random, IntValue value, IntValue other, IntValueRange range) {
     31      ApplyStatic(random, value, other, range);
    3232    }
    3333
    34     public static void ApplyStatic(IRandom random, IntValue value, IntValueRange range) {
    35 
     34    public static void ApplyStatic(IRandom random, IntValue value, IntValue other, IntValueRange range) {
     35      if (random.NextDouble() > 0.5) {
     36        value.Value = other.Value;
     37      }
    3638    }
    3739  }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Interfaces/IDoubleValueCrossover.cs

    r5111 r5277  
    99namespace HeuristicLab.Problems.MetaOptimization {
    1010  public interface IDoubleValueCrossover : ICrossover {
    11     void Apply(IRandom random, DoubleValue value, DoubleValueRange range);
     11    void Apply(IRandom random, DoubleValue value, DoubleValue other, DoubleValueRange range);
    1212  }
    1313}
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Interfaces/IIntValueCrossover.cs

    r5111 r5277  
    99namespace HeuristicLab.Problems.MetaOptimization {
    1010  public interface IIntValueCrossover : ICrossover {
    11     void Apply(IRandom random, IntValue value, IntValueRange range);
     11    void Apply(IRandom random, IntValue value, IntValue other, IntValueRange range);
    1212  }
    1313}
Note: See TracChangeset for help on using the changeset viewer.