Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4982


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

#1215 worked on metaoptimization

Location:
branches/HeuristicLab.MetaOptimization
Files:
8 added
7 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.sln

    r4981 r4982  
    77EndProject
    88Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.MetaOptimization.Test", "HeuristicLab.MetaOptimization.Test\HeuristicLab.MetaOptimization.Test.csproj", "{0E232F46-FD0B-4FEA-8C22-AF18DE0D151E}"
     9EndProject
     10Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F96C8DD1-9B68-4F2D-AD4F-1A174F596041}"
     11  ProjectSection(SolutionItems) = preProject
     12    PreBuildEvent.cmd = PreBuildEvent.cmd
     13  EndProjectSection
    914EndProject
    1015Global
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3

    • Property svn:ignore
      •  

        old new  
        22obj
        33HeuristicLab.Problems.MetaOptimization.Views-3.3.csproj.user
         4HeuristicLabProblemsMetaOptimizationViewsPlugin.cs
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/HeuristicLab.Problems.MetaOptimization.Views-3.3.csproj

    r4981 r4982  
    8585  </ItemGroup>
    8686  <ItemGroup>
     87    <None Include="HeuristicLabProblemsMetaOptimizationViewsPlugin.cs.frame" />
    8788    <Compile Include="OptimizableView.cs">
    8889      <SubType>UserControl</SubType>
     
    9091    <Compile Include="OptimizableView.Designer.cs">
    9192      <DependentUpon>OptimizableView.cs</DependentUpon>
     93    </Compile>
     94    <None Include="Properties\AssemblyInfo.cs.frame" />
     95    <Compile Include="RootValueConfigurationView.cs">
     96      <SubType>UserControl</SubType>
     97    </Compile>
     98    <Compile Include="RootValueConfigurationView.Designer.cs">
     99      <DependentUpon>RootValueConfigurationView.cs</DependentUpon>
    92100    </Compile>
    93101    <Compile Include="ValueConfigurationViews\ValueConfigurationCheckedItemList.cs">
     
    126134      <DependentUpon>OptimizableView.cs</DependentUpon>
    127135    </EmbeddedResource>
     136    <EmbeddedResource Include="RootValueConfigurationView.resx">
     137      <DependentUpon>RootValueConfigurationView.cs</DependentUpon>
     138    </EmbeddedResource>
    128139    <EmbeddedResource Include="ValueConfigurationViews\NumericRangeView.resx">
    129140      <DependentUpon>NumericRangeView.cs</DependentUpon>
     
    150161set ProjectDir=$(ProjectDir)
    151162set SolutionDir=$(SolutionDir)
    152 set Outdir=$(Outdir)</PreBuildEvent>
     163set Outdir=$(Outdir)
     164
     165call PreBuildEvent.cmd</PreBuildEvent>
    153166  </PropertyGroup>
    154167  <PropertyGroup>
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/Properties

    • Property svn:ignore set to
      AssemblyInfo.cs
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/ValueConfigurationViews/ValueConfigurationCheckedItemList.cs

    r4981 r4982  
    1111using System.Windows.Forms;
    1212using HeuristicLab.PluginInfrastructure;
     13using HeuristicLab.Collections;
    1314
    1415namespace HeuristicLab.Problems.MetaOptimization.Views {
     
    2627
    2728    protected override void DeregisterContentEvents() {
    28       // TODO: Deregister your event handlers here
     29      Content.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(Content_ItemsRemoved);
    2930      base.DeregisterContentEvents();
    3031    }
     
    3233    protected override void RegisterContentEvents() {
    3334      base.RegisterContentEvents();
    34       // TODO: Register your event handlers here
     35      Content.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(Content_ItemsRemoved);
    3536    }
    3637
    3738    #region Event Handlers (Content)
    38     // TODO: Put event handlers of the content here
     39    private new void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IValueConfiguration> e) {
     40      if (InvokeRequired) {
     41        Invoke(new EventHandler<CollectionItemsChangedEventArgs<IValueConfiguration>>(Content_ItemsRemoved), sender, e);
     42      } else {
     43        base.Content_ItemsRemoved(sender, e);
     44        SetEnabledStateOfControls();
     45      }
     46    }
    3947    #endregion
    4048
    4149    protected override void OnContentChanged() {
    4250      base.OnContentChanged();
    43       if (Content == null) {
    44         // TODO: Add code when content has been changed and is null
     51      if (Content != null) {
     52        SetEnabledStateOfControls();
    4553      } else {
    46         // TODO: Add code when content has been changed and is not null
    4754      }
    4855    }
    4956
    50 
    5157    protected override void SetEnabledStateOfControls() {
    5258      base.SetEnabledStateOfControls();
    53       // TODO: Enable or disable controls based on whether the content is null or the view is set readonly
     59      if(Content != null) this.removeButton.Enabled = Content.Count > Content.MinItemCount;
     60    }
     61
     62    protected override void itemsListView_SelectedIndexChanged(object sender, EventArgs e) {
     63      base.itemsListView_SelectedIndexChanged(sender, e);
     64      this.removeButton.Enabled = removeButton.Enabled && (Content.Count > Content.MinItemCount);
    5465    }
    5566
    5667    #region Event Handlers (child controls)
    57     // TODO: Put event handlers of child controls here.
    5868    #endregion
    5969
  • 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/ParameterConfigurations/ParameterConfiguration.cs

    r4981 r4982  
    117117
    118118    private void PopulateValueConfigurations() {
    119       foreach (IItem item in this.validValues) {
    120         this.ValueConfigurations.Add(new ValueConfiguration(item, item.GetType()), false);
     119      foreach (IItem validValue in this.validValues) {
     120        IItem val;
     121        if (actualValueConfiguration.ConstrainedValue.Value != null && actualValueConfiguration.ConstrainedValue.ValueDataType == validValue.GetType()) {
     122          val = actualValueConfiguration.ConstrainedValue.Value; // use existing value for that type (if available)
     123        } else {
     124          val = validValue;
     125        }
     126        this.ValueConfigurations.Add(new ValueConfiguration(val, val.GetType()), true);
    121127      }
    122128    }
  • 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
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/HeuristicLab.Problems.MetaOptimization-3.3.csproj

    r4981 r4982  
    8888  <ItemGroup>
    8989    <Compile Include="Analyzers\BestParameterConfigurationAnalyzer.cs" />
     90    <None Include="Properties\AssemblyInfo.cs.frame" />
     91    <None Include="HeuristicLabProblemsMetaOptimizationPlugin.cs.frame" />
    9092    <Compile Include="Encodings\RangeConstraints\ConstrainedValue.cs">
    9193      <SubType>Code</SubType>
    9294    </Compile>
     95    <Compile Include="Encodings\ValueConfigurations\RootValueConfiguration.cs" />
    9396    <Compile Include="Encodings\ValueConfigurations\ValueConfiguration.cs" />
    9497    <Compile Include="Encodings\ValueConfigurations\CheckedValueConfigurationCollection.cs" />
     
    120123set ProjectDir=$(ProjectDir)
    121124set SolutionDir=$(SolutionDir)
    122 set Outdir=$(Outdir)</PreBuildEvent>
     125set Outdir=$(Outdir)
     126
     127call PreBuildEvent.cmd</PreBuildEvent>
    123128  </PropertyGroup>
    124129  <PropertyGroup>
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/ICheckedValueConfigurationCollection.cs

    r4981 r4982  
    77namespace HeuristicLab.Problems.MetaOptimization {
    88  public interface ICheckedValueConfigurationCollection : ICheckedItemCollection<IValueConfiguration> {
     9    int MinItemCount { get; }
    910    Type ValueDataType { get; }
    1011  }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/MetaOptimizationProblem.cs

    r4839 r4982  
    153153      if (Algorithm != null) {
    154154        Algorithm.ProblemChanged += new EventHandler(BaseLevelAlgorithm_ProblemChanged);
    155         AlgorithmParameterConfiguration = new ValueConfiguration(Algorithm, Algorithm.GetType());
     155        AlgorithmParameterConfiguration = new RootValueConfiguration(Algorithm, Algorithm.GetType());
    156156      }
    157157      BaseLevelAlgorithm_ProblemChanged(sender, e);
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Properties

    • Property svn:ignore set to
      AssemblyInfo.cs
      AssemblyInfo.cs
  • branches/HeuristicLab.MetaOptimization/PreBuildEvent.cmd

    r4516 r4982  
    1 SubWCRev "%ProjectDir%\" "%ProjectDir%\Properties\AssemblyInfo.frame" "%ProjectDir%\Properties\AssemblyInfo.cs"
     1cd %ProjectDir%
     2for /r %%i in (*.cs.frame) do SubWCRev . %%i %%~dpi%%~ni
Note: See TracChangeset for help on using the changeset viewer.