Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/15/10 15:43:43 (13 years ago)
Author:
cneumuel
Message:

#1215

  • optional parameter values now can be null
  • problem type can now be set specifically
  • values are constrained to the encoding of the Problem
  • moved repetitions parameter to MetaOptimizationProblem
File:
1 edited

Legend:

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

    r5087 r5110  
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3030using HeuristicLab.PluginInfrastructure;
     31using HeuristicLab.Algorithms.GeneticAlgorithm;
     32using HeuristicLab.Problems.TestFunctions;
    3133
    3234namespace HeuristicLab.Problems.MetaOptimization {
     
    3537  [StorableClass]
    3638  public sealed class MetaOptimizationProblem : SingleObjectiveProblem<IMetaOptimizationEvaluator, IParameterConfigurationCreator> {
    37     private const string AlgorithmParameterName = "Algorithm";
    38     private const string ProblemsParameterName = "Problems";
    39     private const string AlgorithmParameterConfigurationParameterName = "InitialParameterConfigurationTree";
    40     //private const string ProblemParametersConfigurationParameterName = "ProblemParametersConfiguration";
     39    public const string AlgorithmTypeParameterName = "AlgorithmType";
     40    public const string ProblemTypeParameterName = "ProblemType";
     41    public const string ProblemsParameterName = "Problems";
     42    public const string ParameterConfigurationParameterName = "InitialParameterConfigurationTree";
     43    public const string RepetitionsParameterName = "Repetitions";
    4144
    4245    #region Parameter Properties
    43     public IValueParameter<EngineAlgorithm> AlgorithmParameter {
    44       get { return (ValueParameter<EngineAlgorithm>)Parameters[AlgorithmParameterName]; }
     46    public IValueParameter<EngineAlgorithm> AlgorithmTypeParameter {
     47      get { return (ValueParameter<EngineAlgorithm>)Parameters[AlgorithmTypeParameterName]; }
    4548    }
    46     public IValueParameter<IItemList<ISingleObjectiveProblem>> ProblemsParameter {
    47       get { return (ValueParameter<IItemList<ISingleObjectiveProblem>>)Parameters[ProblemsParameterName]; }
     49    public IValueParameter<ISingleObjectiveProblem> ProblemTypeParameter {
     50      get { return (ValueParameter<ISingleObjectiveProblem>)Parameters[ProblemTypeParameterName]; }
    4851    }
    49     public IValueParameter<ParameterConfigurationTree> AlgorithmParameterConfigurationParameter {
    50       get { return (ValueParameter<ParameterConfigurationTree>)Parameters[AlgorithmParameterConfigurationParameterName]; }
     52    public IValueParameter<ConstrainedItemList<ISingleObjectiveProblem>> ProblemsParameter {
     53      get { return (ValueParameter<ConstrainedItemList<ISingleObjectiveProblem>>)Parameters[ProblemsParameterName]; }
    5154    }
    52     //public ValueParameter<IItemList<IParameterConfiguration>> ProblemParametersConfigurationParameter {
    53     //  get { return (ValueParameter<IItemList<IParameterConfiguration>>)Parameters[ProblemParametersConfigurationParameterName]; }
    54     //}
     55    public IValueParameter<ParameterConfigurationTree> ParameterConfigurationParameter {
     56      get { return (ValueParameter<ParameterConfigurationTree>)Parameters[ParameterConfigurationParameterName]; }
     57    }
     58    public IValueParameter<IntValue> RepetitionsParameter {
     59      get { return (ValueParameter<IntValue>)Parameters[RepetitionsParameterName]; }
     60    }
    5561    #endregion
    5662
    5763    #region Properties
    5864    public EngineAlgorithm Algorithm {
    59       get { return AlgorithmParameter.Value; }
    60       set { AlgorithmParameter.Value = value; }
     65      get { return AlgorithmTypeParameter.Value; }
     66      set { AlgorithmTypeParameter.Value = value; }
    6167    }
    62     public IItemList<ISingleObjectiveProblem> Problems {
     68    public ISingleObjectiveProblem Problem {
     69      get { return ProblemTypeParameter.Value; }
     70      set { ProblemTypeParameter.Value = value; }
     71    }
     72    public ConstrainedItemList<ISingleObjectiveProblem> Problems {
    6373      get { return ProblemsParameter.Value; }
    6474      set { ProblemsParameter.Value = value; }
    6575    }
    6676    public ParameterConfigurationTree AlgorithmParameterConfiguration {
    67       get { return AlgorithmParameterConfigurationParameter.Value; }
    68       set { AlgorithmParameterConfigurationParameter.Value = value; }
     77      get { return ParameterConfigurationParameter.Value; }
     78      set { ParameterConfigurationParameter.Value = value; }
    6979    }
    70     //public IItemList<IParameterConfiguration> ProblemParametersConfiguration {
    71     //  get { return ProblemParametersConfigurationParameter.Value; }
    72     //  set { ProblemParametersConfigurationParameter.Value = value; }
    73     //}
     80    public IntValue Repetitions {
     81      get { return RepetitionsParameter.Value; }
     82      set { RepetitionsParameter.Value = value; }
     83    }
    7484    #endregion
    7585
    7686    public MetaOptimizationProblem() : base() {
    77       Parameters.Add(new ValueParameter<EngineAlgorithm>(AlgorithmParameterName, "The algorithm which's parameters should be optimized."));
    78       Parameters.Add(new ValueParameter<IItemList<ISingleObjectiveProblem>>(ProblemsParameterName, "The problems that should be evaluated.", new ItemList<ISingleObjectiveProblem>()));
    79       Parameters.Add(new ValueParameter<ParameterConfigurationTree>(AlgorithmParameterConfigurationParameterName, "List of algorithm parameters that should be optimized."));
    80       //Parameters.Add(new ValueParameter<IItemList<IParameterConfiguration>>(ProblemParametersConfigurationParameterName, "List of problem parameters that should be optimized.", new ItemList<IParameterConfiguration>()));
    81      
     87      Parameters.Add(new ValueParameter<EngineAlgorithm>(AlgorithmTypeParameterName, "The algorithm which's parameters should be optimized.", new GeneticAlgorithm()));
     88      Parameters.Add(new ValueParameter<ISingleObjectiveProblem>(ProblemTypeParameterName, "The problem type.", new SingleObjectiveTestFunctionProblem()));
     89      Parameters.Add(new ValueParameter<ConstrainedItemList<ISingleObjectiveProblem>>(ProblemsParameterName, "The problems that should be evaluated.", new ConstrainedItemList<ISingleObjectiveProblem>()));
     90      Parameters.Add(new ValueParameter<ParameterConfigurationTree>(ParameterConfigurationParameterName, "List of algorithm parameters that should be optimized."));
     91      Parameters.Add(new ValueParameter<IntValue>(RepetitionsParameterName, "The number of evaluations for each problem.", new IntValue(3)));
     92
    8293      Maximization = new BoolValue(false);
    8394      SolutionCreator = new RandomParameterConfigurationCreator();
     
    89100      ParameterizeEvaluator();
    90101      ParameterizeOperators();
     102
     103      Problems.Type = Problem.GetType();
     104      Algorithm.Problem = Problem;
     105      ParameterConfigurationParameter.ActualValue = new ParameterConfigurationTree(Algorithm);
    91106    }
    92107
     
    110125      EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
    111126      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    112       AlgorithmParameter.ValueChanged += new EventHandler(BaseLevelAlgorithmParameter_ValueChanged);
     127      AlgorithmTypeParameter.ValueChanged += new EventHandler(AlgorithmTypeParameter_ValueChanged);
     128      ProblemTypeParameter.ValueChanged += new EventHandler(ProblemTypeParameter_ValueChanged);
    113129    }
     130   
    114131    private void InitializeOperators() {
    115132      Operators.AddRange(ApplicationManager.Manager.GetInstances<IParameterConfigurationOperator>().Cast<IOperator>());
     
    117134    }
    118135    private void ParameterizeSolutionCreator() {
    119       //SolutionCreator.ParametersToOptimize = this.ParametersToOptimize;
    120      
    121136    }
    122137    private void ParameterizeEvaluator() {
     
    124139    }
    125140    private void ParameterizeAnalyzer() {
    126       //BestQualityAnalyzer.ResultsParameter.ActualName = "Results";
    127141    }
    128142    private void ParameterizeOperators() {
     
    150164      ParameterizeAnalyzer();
    151165    }
    152     void BaseLevelAlgorithmParameter_ValueChanged(object sender, EventArgs e) {
    153       AlgorithmParameterConfiguration = new ParameterConfigurationTree(Algorithm);
    154 
    155       //Algorithm.ProblemChanged += new EventHandler(BaseLevelAlgorithm_ProblemChanged); // when to deregister?
    156       //BaseLevelAlgorithm_ProblemChanged(sender, e);
     166    void AlgorithmTypeParameter_ValueChanged(object sender, EventArgs e) {
     167      Algorithm.Problem = Problem;
     168      ParameterConfigurationParameter.ActualValue = new ParameterConfigurationTree(Algorithm);
    157169    }
    158 
    159     void BaseLevelAlgorithm_ProblemChanged(object sender, EventArgs e) {
    160       //if (Algorithm != null && Algorithm.Problem != null) {
    161       //  AlgorithmParameterConfiguration = new ParameterConfigurationTree(Algorithm);
    162       //}
     170    void ProblemTypeParameter_ValueChanged(object sender, EventArgs e) {
     171      Problems.Type = Problem.GetType();
     172      Algorithm.Problem = Problem;
     173      ParameterConfigurationParameter.ActualValue = new ParameterConfigurationTree(Algorithm);
    163174    }
    164175    #endregion
Note: See TracChangeset for help on using the changeset viewer.