Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/21/14 18:49:05 (9 years ago)
Author:
abeham
Message:

#2174: Major refactoring

  • Removed ProblemDefinitionHosts
  • Renamed ParameterVector to Individual
  • Renamed Configuration to Encoding
  • Changed handling of existing operators that they will not be removed and recreated, but only rewired
Location:
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Operators
Files:
7 added
7 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Operators/MultiObjectiveAnalyzer.cs

    r11400 r11484  
    1111
    1212namespace HeuristicLab.Problems.Programmable {
    13   [Item("Multi-objective Analyzer", "Calls the script's Analyze method to be able to write into the results collection.")]
     13  [Item("Multi-objective Analyzer", "Calls the Analyze method of the problem definition.")]
    1414  [StorableClass]
    1515  public class MultiObjectiveAnalyzer : SingleSuccessorOperator, IMultiObjectiveProgrammableProblemAnalyzer {
    1616    public bool EnabledByDefault { get { return true; } }
    1717
    18     public ILookupParameter<IMultiObjectiveProblemDefinitionHost> ProblemDefinitionParameter {
    19       get { return (ILookupParameter<IMultiObjectiveProblemDefinitionHost>)Parameters["ProblemDefinition"]; }
     18    public ILookupParameter<IMultiObjectiveProblemDefinition> ProblemDefinitionParameter {
     19      get { return (ILookupParameter<IMultiObjectiveProblemDefinition>)Parameters["ProblemDefinition"]; }
    2020    }
    2121
    22     public ILookupParameter<Configuration> ConfigurationParameter {
    23       get { return (ILookupParameter<Configuration>)Parameters["Configuration"]; }
     22    public ILookupParameter<Encoding> EncodingParameter {
     23      get { return (ILookupParameter<Encoding>)Parameters["Encoding"]; }
    2424    }
    2525
     
    3737    public MultiObjectiveAnalyzer() {
    3838      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    39       Parameters.Add(new LookupParameter<IMultiObjectiveProblemDefinitionHost>("ProblemDefinition", "The host that holds the problem definition."));
    40       Parameters.Add(new LookupParameter<Configuration>("Configuration", "An item that holds the problem's configuration."));
     39      Parameters.Add(new LookupParameter<IMultiObjectiveProblemDefinition>("ProblemDefinition", "The host that holds the problem definition."));
     40      Parameters.Add(new LookupParameter<Encoding>("Encoding", "An item that holds the problem's encoding."));
    4141      Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>("Qualities", "The qualities of the parameter vector."));
    4242      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The results collection to write to."));
     
    4848
    4949    public override IOperation Apply() {
    50       var host = ProblemDefinitionParameter.ActualValue;
    51       if (host.Instance == null) throw new InvalidOperationException("Script instance is null, maybe the code doesn't compile.");
    52       var config = ConfigurationParameter.ActualValue;
     50      var definition = ProblemDefinitionParameter.ActualValue;
     51      if (definition == null) throw new InvalidOperationException("Problem definition is null.");
     52      var config = EncodingParameter.ActualValue;
    5353      var results = ResultsParameter.ActualValue;
    5454
     
    5858
    5959      var vectors = scopes.Select(scope => Helper.Extract(scope, config)).ToArray();
    60       host.Instance.Analyze(vectors, QualitiesParameter.ActualValue.Select(x => x.ToArray()).ToArray(), results);
     60      definition.Analyze(vectors, QualitiesParameter.ActualValue.Select(x => x.ToArray()).ToArray(), results);
    6161      return base.Apply();
    6262    }
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Operators/MultiObjectiveEvaluator.cs

    r11400 r11484  
    3030
    3131namespace HeuristicLab.Problems.Programmable {
    32   [Item("Multi-objective Evaluator", "Calls the script's Evaluate method to get the quality values of the parameter vector.")]
     32  [Item("Multi-objective Evaluator", "Calls the Evaluate method of the problem definition and writes the return value into the scope.")]
    3333  [StorableClass]
    3434  public class MultiObjectiveEvaluator : SingleSuccessorOperator, IMultiObjectiveProgrammableProblemEvaluator, IStochasticOperator {
     
    3838    }
    3939
    40     public ILookupParameter<IMultiObjectiveProblemDefinitionHost> ProblemDefinitionParameter {
    41       get { return (ILookupParameter<IMultiObjectiveProblemDefinitionHost>)Parameters["ProblemDefinition"]; }
     40    public ILookupParameter<IMultiObjectiveProblemDefinition> ProblemDefinitionParameter {
     41      get { return (ILookupParameter<IMultiObjectiveProblemDefinition>)Parameters["ProblemDefinition"]; }
    4242    }
    4343
    44     public ILookupParameter<Configuration> ConfigurationParameter {
    45       get { return (ILookupParameter<Configuration>)Parameters["Configuration"]; }
     44    public ILookupParameter<Encoding> EncodingParameter {
     45      get { return (ILookupParameter<Encoding>)Parameters["Encoding"]; }
    4646    }
    4747
     
    5555    public MultiObjectiveEvaluator() {
    5656      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    57       Parameters.Add(new LookupParameter<IMultiObjectiveProblemDefinitionHost>("ProblemDefinition", "The host that holds the problem definition."));
    58       Parameters.Add(new LookupParameter<Configuration>("Configuration", "An item that holds the problem's configuration."));
     57      Parameters.Add(new LookupParameter<IMultiObjectiveProblemDefinition>("ProblemDefinition", "The host that holds the problem definition."));
     58      Parameters.Add(new LookupParameter<Encoding>("Encoding", "An item that holds the problem's encoding."));
    5959      Parameters.Add(new LookupParameter<DoubleArray>("Qualities", "The qualities of the parameter vector."));
    6060    }
     
    6666    public override IOperation Apply() {
    6767      var random = RandomParameter.ActualValue;
    68       var host = ProblemDefinitionParameter.ActualValue;
    69       if (host.Instance == null) throw new InvalidOperationException("Script instance is null, maybe the code doesn't compile.");
    70       var config = ConfigurationParameter.ActualValue;
     68      var definition = ProblemDefinitionParameter.ActualValue;
     69      if (definition == null) throw new InvalidOperationException("Problem definition is null.");
     70      var config = EncodingParameter.ActualValue;
    7171      var vector = Helper.Extract(ExecutionContext.Scope, config);
    72       QualitiesParameter.ActualValue = new DoubleArray(host.Instance.Evaluate(random, vector));
     72      QualitiesParameter.ActualValue = new DoubleArray(definition.Evaluate(random, vector));
    7373      return base.Apply();
    7474    }
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Operators/SingleObjectiveAnalyzer.cs

    r11405 r11484  
    1616    public bool EnabledByDefault { get { return true; } }
    1717
    18     public ILookupParameter<ISingleObjectiveProblemDefinitionHost> ProblemDefinitionParameter {
    19       get { return (ILookupParameter<ISingleObjectiveProblemDefinitionHost>)Parameters["ProblemDefinition"]; }
     18    public ILookupParameter<ISingleObjectiveProblemDefinition> ProblemDefinitionParameter {
     19      get { return (ILookupParameter<ISingleObjectiveProblemDefinition>)Parameters["ProblemDefinition"]; }
    2020    }
    2121
    22     public ILookupParameter<Configuration> ConfigurationParameter {
    23       get { return (ILookupParameter<Configuration>)Parameters["Configuration"]; }
     22    public ILookupParameter<Encoding> EncodingParameter {
     23      get { return (ILookupParameter<Encoding>)Parameters["Encoding"]; }
    2424    }
    2525
     
    3737    public SingleObjectiveAnalyzer() {
    3838      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    39       Parameters.Add(new LookupParameter<ISingleObjectiveProblemDefinitionHost>("ProblemDefinition", "The host that holds the problem definition."));
    40       Parameters.Add(new LookupParameter<Configuration>("Configuration", "An item that holds the problem's configuration."));
     39      Parameters.Add(new LookupParameter<ISingleObjectiveProblemDefinition>("ProblemDefinition", "The host that holds the problem definition."));
     40      Parameters.Add(new LookupParameter<Encoding>("Encoding", "An item that holds the problem's encoding."));
    4141      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The quality of the parameter vector."));
    4242      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The results collection to write to."));
     
    4848
    4949    public override IOperation Apply() {
    50       var host = ProblemDefinitionParameter.ActualValue;
    51       if (host.Instance == null) throw new InvalidOperationException("Problem definition is not available.");
    52       var config = ConfigurationParameter.ActualValue;
     50      var definition = ProblemDefinitionParameter.ActualValue;
     51      if (definition == null) throw new InvalidOperationException("Problem definition is null");
     52      var config = EncodingParameter.ActualValue;
    5353      var results = ResultsParameter.ActualValue;
    5454
     
    5858
    5959      var vectors = scopes.Select(scope => Helper.Extract(scope, config)).ToArray();
    60       host.Instance.Analyze(vectors, QualityParameter.ActualValue.Select(x => x.Value).ToArray(), results);
     60      definition.Analyze(vectors, QualityParameter.ActualValue.Select(x => x.Value).ToArray(), results);
    6161      return base.Apply();
    6262    }
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Operators/SingleObjectiveEvaluator.cs

    r11405 r11484  
    3838    }
    3939
    40     public ILookupParameter<ISingleObjectiveProblemDefinitionHost> ProblemDefinitionParameter {
    41       get { return (ILookupParameter<ISingleObjectiveProblemDefinitionHost>)Parameters["ProblemDefinition"]; }
     40    public ILookupParameter<ISingleObjectiveProblemDefinition> ProblemDefinitionParameter {
     41      get { return (ILookupParameter<ISingleObjectiveProblemDefinition>)Parameters["ProblemDefinition"]; }
    4242    }
    4343
    44     public ILookupParameter<Configuration> ConfigurationParameter {
    45       get { return (ILookupParameter<Configuration>)Parameters["Configuration"]; }
     44    public ILookupParameter<Encoding> EncodingParameter {
     45      get { return (ILookupParameter<Encoding>)Parameters["Encoding"]; }
    4646    }
    4747
     
    5555    public SingleObjectiveEvaluator() {
    5656      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    57       Parameters.Add(new LookupParameter<ISingleObjectiveProblemDefinitionHost>("ProblemDefinition", "The host that holds the problem definition."));
    58       Parameters.Add(new LookupParameter<Configuration>("Configuration", "An item that holds the problem's configuration."));
     57      Parameters.Add(new LookupParameter<ISingleObjectiveProblemDefinition>("ProblemDefinition", "The host that holds the problem definition."));
     58      Parameters.Add(new LookupParameter<Encoding>("Encoding", "An item that holds the problem's encoding."));
    5959      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the parameter vector."));
    6060    }
     
    6666    public override IOperation Apply() {
    6767      var random = RandomParameter.ActualValue;
    68       var host = ProblemDefinitionParameter.ActualValue;
    69       if (host.Instance == null) throw new InvalidOperationException("Problem definition is not available.");
    70       var config = ConfigurationParameter.ActualValue;
     68      var definition = ProblemDefinitionParameter.ActualValue;
     69      if (definition == null) throw new InvalidOperationException("Problem definition is null.");
     70      var config = EncodingParameter.ActualValue;
    7171      var vector = Helper.Extract(ExecutionContext.Scope, config);
    72       QualityParameter.ActualValue = new DoubleValue(host.Instance.Evaluate(random, vector));
     72      QualityParameter.ActualValue = new DoubleValue(definition.Evaluate(random, vector));
    7373      return base.Apply();
    7474    }
Note: See TracChangeset for help on using the changeset viewer.