Free cookie consent management tool by TermsFeed Policy Generator

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

#1215

  • fixed wiring with problem
  • added special treatment of the Reset event of DataAnalysisProblem
Location:
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/AlgorithmEvaluator.cs

    r5653 r5655  
    11using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
     2using System.Diagnostics;
     3using HeuristicLab.Common;
     4using HeuristicLab.Core;
     5using HeuristicLab.Data;
    56using HeuristicLab.Operators;
    6 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    7 using HeuristicLab.Core;
    8 using HeuristicLab.Common;
    97using HeuristicLab.Optimization;
    108using HeuristicLab.Parameters;
    11 using HeuristicLab.Data;
    12 using System.Diagnostics;
     9using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    1310
    1411namespace HeuristicLab.Problems.MetaOptimization {
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/HeuristicLab.Problems.MetaOptimization-3.3.csproj

    r5653 r5655  
    7373  <ItemGroup>
    7474    <Reference Include="HeuristicLab.Algorithms.GeneticAlgorithm-3.3">
    75       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll</HintPath>
     75      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll</HintPath>
    7676    </Reference>
    7777    <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    78       <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Analysis-3.3.dll</HintPath>
     78      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Analysis-3.3.dll</HintPath>
    7979    </Reference>
    8080    <Reference Include="HeuristicLab.Collections-3.3">
    81       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Collections-3.3.dll</HintPath>
     81      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Collections-3.3.dll</HintPath>
    8282    </Reference>
    8383    <Reference Include="HeuristicLab.Common-3.3">
    84       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
     84      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
    8585    </Reference>
    8686    <Reference Include="HeuristicLab.Common.Resources-3.3">
    87       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common.Resources-3.3.dll</HintPath>
     87      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Common.Resources-3.3.dll</HintPath>
    8888    </Reference>
    8989    <Reference Include="HeuristicLab.Core-3.3">
    90       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Core-3.3.dll</HintPath>
     90      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Core-3.3.dll</HintPath>
    9191    </Reference>
    9292    <Reference Include="HeuristicLab.Data-3.3">
    93       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Data-3.3.dll</HintPath>
     93      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Data-3.3.dll</HintPath>
    9494    </Reference>
    9595    <Reference Include="HeuristicLab.Encodings.BinaryVectorEncoding-3.3">
    96       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.BinaryVectorEncoding-3.3.dll</HintPath>
     96      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.BinaryVectorEncoding-3.3.dll</HintPath>
    9797    </Reference>
    9898    <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3">
    99       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.IntegerVectorEncoding-3.3.dll</HintPath>
     99      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.IntegerVectorEncoding-3.3.dll</HintPath>
    100100    </Reference>
    101101    <Reference Include="HeuristicLab.Encodings.RealVectorEncoding-3.3">
    102       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.RealVectorEncoding-3.3.dll</HintPath>
     102      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.RealVectorEncoding-3.3.dll</HintPath>
    103103    </Reference>
    104104    <Reference Include="HeuristicLab.Operators-3.3">
    105       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Operators-3.3.dll</HintPath>
     105      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Operators-3.3.dll</HintPath>
    106106    </Reference>
    107107    <Reference Include="HeuristicLab.Optimization-3.3">
    108       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Optimization-3.3.dll</HintPath>
     108      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Optimization-3.3.dll</HintPath>
    109109    </Reference>
    110110    <Reference Include="HeuristicLab.Parameters-3.3">
    111       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Parameters-3.3.dll</HintPath>
     111      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Parameters-3.3.dll</HintPath>
    112112    </Reference>
    113113    <Reference Include="HeuristicLab.Persistence-3.3">
    114       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Persistence-3.3.dll</HintPath>
     114      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Persistence-3.3.dll</HintPath>
    115115    </Reference>
    116116    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
    117       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     117      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     118    </Reference>
     119    <Reference Include="HeuristicLab.Problems.DataAnalysis-3.3">
     120      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis-3.3.dll</HintPath>
    118121    </Reference>
    119122    <Reference Include="HeuristicLab.Problems.TestFunctions-3.3">
    120       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.TestFunctions-3.3.dll</HintPath>
     123      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.TestFunctions-3.3.dll</HintPath>
    121124    </Reference>
    122125    <Reference Include="HeuristicLab.Random-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    123       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Random-3.3.dll</HintPath>
     126      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Random-3.3.dll</HintPath>
    124127    </Reference>
    125128    <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    126       <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Selection-3.3.dll</HintPath>
     129      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Selection-3.3.dll</HintPath>
    127130    </Reference>
    128131    <Reference Include="HeuristicLab.SequentialEngine-3.3">
    129       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.SequentialEngine-3.3.dll</HintPath>
     132      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.SequentialEngine-3.3.dll</HintPath>
    130133    </Reference>
    131134    <Reference Include="System" />
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/HeuristicLabProblemsMetaOptimizationPlugin.cs.frame

    r4982 r5655  
    2828  [Plugin("HeuristicLab.Problems.MetaOptimization", "3.3.2.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.MetaOptimization-3.3.dll", PluginFileType.Assembly)]
     30  [PluginDependency("HeuristicLab.Algorithms.GeneticAlgorithm", "3.3")]
     31  [PluginDependency("HeuristicLab.Analysis", "3.3")]
    3032  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3133  [PluginDependency("HeuristicLab.Common", "3.3")]
     
    4042  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    4143  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     44  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.3")]
     45  [PluginDependency("HeuristicLab.Problems.TestFunctions", "3.3")]
     46  [PluginDependency("HeuristicLab.Random", "3.3")]
     47  [PluginDependency("HeuristicLab.Selection", "3.3")]
     48  [PluginDependency("HeuristicLab.SequentialEngine", "3.3")]
    4249  public class HeuristicLabProblemsMetaOptimizationPlugin : PluginBase {
    4350  }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/MetaOptimizationProblem.cs

    r5654 r5655  
    2323using System.Linq;
    2424using HeuristicLab.Algorithms.GeneticAlgorithm;
     25using HeuristicLab.Collections;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    3031using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3132using HeuristicLab.PluginInfrastructure;
     33using HeuristicLab.Problems.DataAnalysis;
    3234using HeuristicLab.Problems.TestFunctions;
    3335
     
    7880    #region Properties
    7981    public IAlgorithm Algorithm {
    80       get { return CreateAlgorithm(AlgorithmType.Value, ProblemType.Value); }
     82      get { return CreateAlgorithm(AlgorithmType.Value, Problems.FirstOrDefault()); }
    8183    }
    8284    public ConstrainedTypeValue<IAlgorithm> AlgorithmType {
     
    174176      ProblemTypeParameter.ValueChanged += new EventHandler(ProblemTypeParameter_ValueChanged);
    175177      ProblemType.ValueChanged += new EventHandler(ProblemType_ValueChanged);
     178      Problems.ItemsAdded += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<IProblem>>(Problems_ItemsAdded);
     179      Problems.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<IProblem>>(Problems_ItemsRemoved);
    176180    }
    177181
     
    249253      this.ProblemType.ValidTypes = ApplicationManager.Manager.GetTypes(instance.ProblemType, true).ToList();
    250254      this.ProblemType.Value = this.ProblemType.ValidTypes.SingleOrDefault(t => t == typeof(SingleObjectiveTestFunctionProblem)) ?? this.ProblemType.ValidTypes.Where(t => t != typeof(MetaOptimizationProblem)).FirstOrDefault();
    251       if (ProblemType.Value != null) {
    252         ParameterConfigurationTreeParameter.ActualValue = new ParameterConfigurationTree(CreateAlgorithm(AlgorithmType.Value, ProblemType.Value));
    253         Problems.Add((IProblem)Activator.CreateInstance(this.ProblemType.Value));
    254       } else {
    255         ParameterConfigurationTreeParameter.ActualValue = null;
    256       }
     255      // ProblemType_ValueChanged will add one problem and create ParameterConfigurationTree
    257256    }
    258257
     
    264263      Problems.Clear();
    265264      Problems.Type = ProblemType.Value;
    266       ParameterConfigurationTreeParameter.ActualValue = new ParameterConfigurationTree(CreateAlgorithm(AlgorithmType.Value, ProblemType.Value));
     265      Problems.Add((IProblem)Activator.CreateInstance(this.ProblemType.Value));
     266    }
     267
     268    private void Problems_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IProblem>> e) {
     269      // the first problem in the list is always the instance for the algorithm - this way some basic wiring between problem and algorithm can be sustained
     270      if (e.Items.Single().Index == 0) {
     271        ParameterConfigurationTreeParameter.ActualValue = new ParameterConfigurationTree(CreateAlgorithm(AlgorithmType.Value, e.Items.Single().Value));
     272
     273        // special for DataAnalysisProblem: Because of wiring between algorithm and problem, ParameterConfigurationTree needs to be recreated on Reset event
     274        var dap = e.Items.Single().Value as DataAnalysisProblem;
     275        if (dap != null) {
     276          dap.Reset += new EventHandler(DataAnalysisProblem_Reset);
     277        }
     278      }
     279    }
     280
     281    private void Problems_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IProblem>> e) {
     282      if (e.Items.Single().Index == 0) {
     283        ParameterConfigurationTreeParameter.ActualValue = null;
     284
     285        var dap = e.Items.Single().Value as DataAnalysisProblem;
     286        if (dap != null) {
     287          dap.Reset -= new EventHandler(DataAnalysisProblem_Reset);
     288        }
     289      }
     290    }
     291
     292    private void DataAnalysisProblem_Reset(object sender, EventArgs e) {
     293      ParameterConfigurationTreeParameter.ActualValue = new ParameterConfigurationTree(CreateAlgorithm(AlgorithmType.Value, Problems.First()));
    267294    }
    268295    #endregion
    269296
    270     private IAlgorithm CreateAlgorithm(Type algorithmType, Type problemType) {
     297    private IAlgorithm CreateAlgorithm(Type algorithmType, IProblem problem) {
    271298      IAlgorithm algorithm = (IAlgorithm)Activator.CreateInstance(algorithmType);
    272       algorithm.Problem = (IProblem)Activator.CreateInstance(problemType);
     299      algorithm.Problem = problem;
    273300      return algorithm;
    274301    }
Note: See TracChangeset for help on using the changeset viewer.