Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5361 for branches


Ignore:
Timestamp:
01/24/11 10:12:39 (14 years ago)
Author:
cneumuel
Message:

#1215

  • minor bugfixes
Location:
branches/HeuristicLab.MetaOptimization
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/Program.cs

    r5357 r5361  
    5151      //TestCombinations3();
    5252      //TestEnumeratorCollectionEnumerator();
    53       //TestCombinations4(); return;
     53      TestCombinations4(); return;
    5454      //TestAlgorithmPerformanceIssue();
    5555      //TestWaitAny();
     
    406406      ConfigurePopulationSize(vc, 20, 100, 20);
    407407      //ConfigureMutationRate(vc, 0.10, 0.60, 0.10);
    408       //ConfigureMutationOperator(vc);
    409       ConfigureSelectionOperator(vc, true);
     408      ConfigureMutationOperator(vc);
     409      //ConfigureSelectionOperator(vc, true);
    410410
    411411      int count = 0;
     
    653653        mutationOperator.ValueConfigurations.SetItemCheckedState(multiMutator, false);
    654654      }
     655
     656      // add another normal
     657      mutationOperator.ValueConfigurations.Add(new ValueConfiguration(new NormalAllPositionsManipulator(), typeof(NormalAllPositionsManipulator)), true);
    655658    }
    656659
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs

    r5359 r5361  
    146146      this.ValueConfigurations = new CheckedValueConfigurationList(this.validValues ?? CreateValidValues());
    147147      this.ActualValue = new ConstrainedValue(
    148         valueParameter.Value != null ? (IItem)valueParameter.Value.Clone() : null,
     148        valueParameter.Value != null ? valueParameter.Value : null, // don't clone here; otherwise settings of a non-optimized ValueParameter will not be synchronized with the ConstrainedValue
    149149        valueParameter.DataType,
    150150        this.validValues != null ? new ItemSet<IItem>(this.validValues) : CreateValidValues(),
     
    200200      if (this.ActualValue != null) this.ActualValue.ToStringChanged -= new EventHandler(ActualValue_ToStringChanged);
    201201    }
    202 
     202   
    203203    private void PopulateValueConfigurations() {
    204204      foreach (Type t in this.validTypes) {
     
    370370        if (this.Optimize) {
    371371          var vc = this.ValueConfigurations[actualValueConfigurationIndex];
    372           if (IsSubclassOfRawGeneric(typeof(ValueTypeValue<>), vc.GetType())) {
     372          if (vc.ActualValue == null || vc.ActualValue.Value == null) {
     373            sb.Append(string.Format("{0}: null", parameterName));
     374          } else if (IsSubclassOfRawGeneric(typeof(ValueTypeValue<>), vc.ActualValue.Value.GetType())) {
    373375            // for int, double, bool use the value directly
    374             sb.Append(string.Format("{0}: {1}", parameterName, this.ActualValue.Value != null ? this.ActualValue.Value.ToString() : "null"));
     376            sb.Append(string.Format("{0}: {1}", parameterName, this.ActualValue.Value.ToString()));
    375377          } else {
    376378            // for other types use NumberedName (this also uses the Number-Property for otherwise ambiguous ValueConfigurations)
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/CheckedValueConfigurationCollection.cs

    r5359 r5361  
    1515    [Storable]
    1616    private int minItemCount = 1;
    17     public int MinItemCount { 
    18       get { return minItemCount; } 
     17    public int MinItemCount {
     18      get { return minItemCount; }
    1919    }
    2020
     
    3333    }
    3434    [StorableConstructor]
    35     protected CheckedValueConfigurationList(bool deserializing) : base(deserializing) {
     35    protected CheckedValueConfigurationList(bool deserializing)
     36      : base(deserializing) {
    3637      RegisterEvents();
    3738    }
    38     protected CheckedValueConfigurationList(CheckedValueConfigurationList original, Cloner cloner) : base(original, cloner) {
     39    protected CheckedValueConfigurationList(CheckedValueConfigurationList original, Cloner cloner)
     40      : base(original, cloner) {
    3941      this.minItemCount = original.MinItemCount;
    4042      this.validValues = original.validValues;
     
    6163    void CheckedValueConfigurationList_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) {
    6264      foreach (var item in e.Items) {
    63         if(this.Where(x => x.ItemName == item.Value.ItemName).Count() > 0) {
    64           int maxNumber = this.Where(x => x.ItemName == item.Value.ItemName).Select(x => x.Number).Max();
     65        var matchingItems = this.Where(x => x != item.Value && x.ActualValue.ValueDataType == item.Value.ActualValue.ValueDataType);
     66        if (matchingItems.Count() > 0) {
     67          int maxNumber = matchingItems.Select(x => x.Number).Max();
    6568          item.Value.Number = maxNumber + 1;
    6669        }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/ValueConfiguration.cs

    r5359 r5361  
    9393
    9494    [Storable]
    95     protected int number = -1;
     95    protected int number = 0;
    9696    public int Number {
    9797      get { return number; }
     
    237237      get {
    238238        if (this.number == 0) {
    239           return ActualValue.Value.ItemName;
     239          return (ActualValue != null && ActualValue.Value != null) ? ActualValue.Value.ItemName : base.ToString();
    240240        } else {
    241241          return string.Format("{0} {1}", ActualValue.Value.ItemName, number);
     
    260260    public virtual void Parameterize(IParameterizedItem item) {
    261261      foreach (IParameterConfiguration pc in this.ParameterConfigurations) {
    262         if(pc.Optimize) pc.Parameterize((IValueParameter)item.Parameters[pc.ParameterName]);
     262        pc.Parameterize((IValueParameter)item.Parameters[pc.ParameterName]);
    263263      }
    264264    }
Note: See TracChangeset for help on using the changeset viewer.