Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11595


Ignore:
Timestamp:
11/27/14 11:42:47 (10 years ago)
Author:
mkommend
Message:

#2174: Added possibility to look up parameters of the encoding and removed them from the programmable problem.

Location:
branches/ProgrammableProblem
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/ProgrammableProblem/HeuristicLab.Optimization/3.3/Algorithms/EngineAlgorithm.cs

    r11171 r11595  
    159159      if ((engine != null) && (operatorGraph.InitialOperator != null)) {
    160160        ExecutionContext context = null;
    161         if (Problem != null) context = new ExecutionContext(context, Problem, globalScope);
     161        if (Problem != null) {
     162          foreach (var item in Problem.ExecutionContextItems)
     163            context = new ExecutionContext(context, item, globalScope);
     164        }
    162165        context = new ExecutionContext(context, this, globalScope);
    163166        context = new ExecutionContext(context, operatorGraph.InitialOperator, globalScope);
  • branches/ProgrammableProblem/HeuristicLab.Optimization/3.3/Interfaces/IProblem.cs

    r11171 r11595  
    3131    IEnumerable<IItem> Operators { get; }
    3232
     33
     34    IEnumerable<IParameterizedItem> ExecutionContextItems { get; }
    3335    event EventHandler OperatorsChanged;
    3436    event EventHandler Reset;
  • branches/ProgrammableProblem/HeuristicLab.Optimization/3.3/Problems/Problem.cs

    r11573 r11595  
    116116    IEnumerable<IItem> IProblem.Operators { get { return GetOperators(); } }
    117117
    118     protected virtual IEnumerable<IItem> GetOperators()
    119     {
     118    protected virtual IEnumerable<IItem> GetOperators() {
    120119      return Operators;
     120    }
     121
     122    public virtual IEnumerable<IParameterizedItem> ExecutionContextItems {
     123      get { yield return this; }
    121124    }
    122125    #endregion
  • branches/ProgrammableProblem/HeuristicLab.Optimization/3.3/Problems/UserDefinedProblem.cs

    r11171 r11595  
    115115      get { return OperatorsParameter.Value; }
    116116    }
     117
     118    public IEnumerable<IParameterizedItem> ExecutionContextItems {
     119      get { yield return this; }
     120    }
    117121    #endregion
    118122
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblem.cs

    r11587 r11595  
    5858    }
    5959
    60 
    6160    public ISingleObjectiveProblemDefinition ProblemDefinition {
    6261      get { return ProblemDefinitionParameter.Value; }
     
    6463    }
    6564
    66     [Storable]
    67     protected List<IParameter> DynamicEncodingParameters;
    68 
     65
     66    public override IEnumerable<IParameterizedItem> ExecutionContextItems {
     67      get { return base.ExecutionContextItems.Concat(new[] { ProblemDefinition.Encoding }); }
     68    }
    6969    protected override IEnumerable<IItem> GetOperators() {
    7070      return base.GetOperators().Concat(ProblemDefinition.Encoding.Operators);
     
    7676    protected SingleObjectiveProgrammableProblem(SingleObjectiveProgrammableProblem original, Cloner cloner)
    7777      : base(original, cloner) {
    78       DynamicEncodingParameters = original.DynamicEncodingParameters.Select(cloner.Clone).ToList();
    7978      RegisterEventHandlers();
    8079    }
     
    8483      Parameters.Add(new ValueParameter<IEncoding>("Encoding", "Describes the configuration of the encoding, what the variables are called, what type they are and their bounds if any."));
    8584
    86       DynamicEncodingParameters = new List<IParameter>();
    8785
    8886      Operators.Add(new BestScopeSolutionAnalyzer());
     
    158156        analyzeOp.ProblemDefinitionParameter.ActualName = ProblemDefinitionParameter.Name;
    159157        analyzeOp.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    160       }
    161 
    162       foreach (var param in DynamicEncodingParameters)
    163         if (Parameters.Contains(param)) Parameters.Remove(param);
    164       DynamicEncodingParameters.Clear();
    165 
    166       DynamicEncodingParameters.AddRange(encoding.Parameters);
    167       foreach (var param in DynamicEncodingParameters) {
    168         param.Hidden = true;
    169         Parameters.Add(param);
    170158      }
    171159
     
    215203      }
    216204    }
    217 
    218 
    219205  }
    220206}
Note: See TracChangeset for help on using the changeset viewer.