Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/24/11 01:33:29 (14 years ago)
Author:
cneumuel
Message:

#1215

  • renamed RunsAnalyzer to SolutionCacheAnalyzer
  • only most recent results will stay in cache to avoid memory problems
  • some minor tweaks and bugfixes
Location:
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/CheckedValueConfigurationCollection.cs

    r5313 r5359  
    5050
    5151    private void RegisterEvents() {
     52      this.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsAdded);
    5253      this.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsRemoved);
    5354    }
     
    5556    private void DeregisterEvents() {
    5657      this.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsRemoved);
     58      this.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsAdded);
     59    }
     60
     61    void CheckedValueConfigurationList_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) {
     62      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          item.Value.Number = maxNumber + 1;
     66        }
     67      }
    5768    }
    5869
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/ValueConfiguration.cs

    r5357 r5359  
    1515  // TODO: ItemName/Descr, storability
    1616  [StorableClass]
    17   public class ValueConfiguration : Item, IValueConfiguration {
     17  public class ValueConfiguration : NamedItem, IValueConfiguration {
     18    public override bool CanChangeName {
     19      get { return true; }
     20    }
     21
     22    public override bool CanChangeDescription {
     23      get { return true; }
     24    }
     25
    1826    [Storable]
    1927    protected bool isOptimizable;
     
    8088          rangeConstraint = value;
    8189          RegisterActualValueEvents();
     90        }
     91      }
     92    }
     93
     94    [Storable]
     95    protected int number = -1;
     96    public int Number {
     97      get { return number; }
     98      set {
     99        if (value != number) {
     100          number = value;
     101          OnToStringChanged();
    82102        }
    83103      }
     
    113133      this.isOptimizable = original.isOptimizable;
    114134      this.optimize = original.optimize;
     135      this.number = original.number;
    115136      RegisterActualValueEvents();
    116137      RegisterRangeConstraintEvents();
     
    193214    public override string ToString() {
    194215      if (ActualValue != null && ActualValue.Value != null) {
     216        string name = NumberedName;
     217
    195218        if (ActualValue.Value is IParameterizedItem) {
    196219          if (Optimize) {
    197             return string.Format("{0} (Optimize)", ActualValue.Value.ItemName);
     220            return string.Format("{0} (Optimize)", name);
    198221          } else {
    199             return string.Format("{0}", ActualValue.Value.ItemName);
     222            return string.Format("{0}", name);
    200223          }
    201224        } else {
    202225          if (Optimize) {
    203             return string.Format("{0} (Optimize: {1})", ActualValue.Value.ItemName, RangeConstraint);
     226            return string.Format("{0} (Optimize: {1})", name, RangeConstraint);
    204227          } else {
    205             return string.Format("{0}: {1}", ActualValue.Value.ItemName, ActualValue.Value);
     228            return string.Format("{0}: {1}", name, ActualValue.Value);
    206229          }
    207230        }
    208231      } else {
    209232        return base.ToString();
     233      }
     234    }
     235
     236    public string NumberedName {
     237      get {
     238        if (this.number == 0) {
     239          return ActualValue.Value.ItemName;
     240        } else {
     241          return string.Format("{0} {1}", ActualValue.Value.ItemName, number);
     242        }
    210243      }
    211244    }
     
    227260    public virtual void Parameterize(IParameterizedItem item) {
    228261      foreach (IParameterConfiguration pc in this.ParameterConfigurations) {
    229         pc.Parameterize((IValueParameter)item.Parameters[pc.ParameterName]);
     262        if(pc.Optimize) pc.Parameterize((IValueParameter)item.Parameters[pc.ParameterName]);
    230263      }
    231264    }
     
    287320      }
    288321    }
     322
     323    public IEnumerable<string> GetOptimizedParameterNames() {
     324      var list = new List<string>();
     325      this.CollectOptimizedParameterNames(list, "");
     326      return list;
     327    }
    289328  }
    290329}
Note: See TracChangeset for help on using the changeset viewer.