Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/28/10 23:03:05 (14 years ago)
Author:
cneumuel
Message:

#1215 worked on metaoptimization

Location:
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3
Files:
1 added
3 edited

Legend:

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

    • Property svn:ignore
      •  

        old new  
        22bin
        33obj
         4HeuristicLabProblemsMetaOptimizationPlugin.cs
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/ValueConfigurations/CheckedValueConfigurationCollection.cs

    r4981 r4982  
    44using System.Text;
    55using HeuristicLab.Core;
     6using HeuristicLab.Common;
     7using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    68
    79namespace HeuristicLab.Problems.MetaOptimization {
    810  // todo: check that at least 1 elements needs to be selected
    911  // todo: control creatable item types
     12  [StorableClass]
    1013  public class CheckedValueConfigurationCollection : CheckedItemCollection<IValueConfiguration>, ICheckedValueConfigurationCollection {
     14    [Storable]
     15    private int minItemCount = 1;
     16    public int MinItemCount {
     17      get { return minItemCount; }
     18    }
    1119
     20    [Storable]
    1221    protected Type valueDataType;
    1322    public Type ValueDataType {
     
    1726    public CheckedValueConfigurationCollection(Type valueDataType) {
    1827      this.valueDataType = valueDataType;
     28      RegisterEvents();
     29    }
     30    public CheckedValueConfigurationCollection() {
     31      RegisterEvents();
     32    }
     33    [StorableConstructor]
     34    protected CheckedValueConfigurationCollection(bool deserializing) : base(deserializing) {
     35      RegisterEvents();
     36    }
     37    protected CheckedValueConfigurationCollection(CheckedValueConfigurationCollection original, Cloner cloner) : base(original, cloner) {
     38      this.minItemCount = original.MinItemCount;
     39      this.valueDataType = original.valueDataType;
     40      RegisterEvents();
     41    }
     42    public override IDeepCloneable Clone(Cloner cloner) {
     43      return new CheckedValueConfigurationCollection(this, cloner);
     44    }
     45
     46    private void RegisterEvents() {
     47      this.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(CheckedValueConfigurationCollection_ItemsRemoved);
     48    }
     49    private void DeregisterEvents() {
     50      this.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(CheckedValueConfigurationCollection_ItemsRemoved);
     51    }
     52
     53    private void CheckedValueConfigurationCollection_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IValueConfiguration> e) {
     54      // auch collectionreset gehört berücksichtigt
     55      // funktioniert so nicht ganz, weil die view das hinzufügen nicht mitkriegt
     56      //if (this.Count < minItemCount) {
     57      //  foreach (var item in e.Items) {
     58      //    if (this.Count >= minItemCount)
     59      //      break;
     60      //    this.Add(item);
     61      //  }
     62      //}
    1963    }
    2064  }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/ValueConfigurations/ValueConfiguration.cs

    r4981 r4982  
    3030    protected IItemCollection<IParameterConfiguration> parameterConfigurations = new ItemCollection<IParameterConfiguration>();
    3131    public IItemCollection<IParameterConfiguration> ParameterConfigurations {
    32       get { return this.parameterConfigurations; }
     32      get { return new ReadOnlyItemCollection<IParameterConfiguration>(this.parameterConfigurations); }
    3333      protected set { this.parameterConfigurations = value; }
    3434    }
     
    5555    #region Constructors and Cloning
    5656    public ValueConfiguration(IItem value, Type valueDataType) {
    57       this.parameterConfigurations = new ItemList<IParameterConfiguration>();
     57      this.ParameterConfigurations = new ItemList<IParameterConfiguration>();
    5858      this.ConstrainedValue = new ConstrainedValue(value, valueDataType);
    5959      if (constrainedValue.ValueDataType == typeof(IntValue)) {
     
    8686        foreach (var childParameter in parameterizedItem.Parameters) {
    8787          var pc = ParameterConfiguration.Create(parameterizedItem, childParameter);
    88           if (pc != null) this.ParameterConfigurations.Add(pc);
     88          if (pc != null) this.parameterConfigurations.Add(pc);
    8989        }
    9090      }
    9191    }
    9292    protected virtual void ClearParameterConfigurations() {
    93       ParameterConfigurations.Clear();
     93      parameterConfigurations.Clear();
    9494    }
    9595
Note: See TracChangeset for help on using the changeset viewer.