Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2520_PersistenceReintegration/HeuristicLab.Problems.Programmable/3.3/Templates/CompiledMultiObjectiveProblemDefinition.cs @ 16605

Last change on this file since 16605 was 16462, checked in by jkarder, 6 years ago

#2520: worked on reintegration of new persistence

  • added nuget references to HEAL.Fossil
  • added StorableType attributes to many classes
  • changed signature of StorableConstructors
  • removed some classes in old persistence
  • removed some unnecessary usings
File size: 2.4 KB
Line 
1using HeuristicLab.Core;
2using HeuristicLab.Optimization;
3
4namespace HeuristicLab.Problems.Programmable {
5  public class CompiledMultiObjectiveProblemDefinition : CompiledProblemDefinition, IMultiObjectiveProblemDefinition {
6    public bool[] Maximization { get { return new[] { false, false }; } }
7
8    public override void Initialize() {
9      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
10      // Define the solution encoding which can also consist of multiple vectors, examples below
11      //Encoding = new BinaryVectorEncoding("b", length: 5);
12      //Encoding = new IntegerVectorEncoding("i", length: 5, min: 2, max: 14, step: 4);
13      //Encoding = new RealVectorEncoding("r", length: 5, min: -1.0, max: 1.0);
14      //Encoding = new PermutationEncoding("p", length: 5, type: PermutationTypes.Absolute);
15      //Encoding = new LinearLinkageEncoding("l", length: 5);
16      //Encoding = new SymbolicExpressionTreeEncoding("s", new SimpleSymbolicExpressionGrammar(), 50, 12);
17      // The encoding can also be a combination
18      //Encoding = new MultiEncoding()
19      //.Add(new BinaryVectorEncoding("b", length: 5))
20      //.Add(new IntegerVectorEncoding("i", length: 5, min: 2, max: 14, step: 4))
21      //.Add(new RealVectorEncoding("r", length: 5, min: -1.0, max: 1.0))
22      //.Add(new PermutationEncoding("p", length: 5, type: PermutationTypes.Absolute))
23      //.Add(new LinearLinkageEncoding("l", length: 5))
24      //.Add(new SymbolicExpressionTreeEncoding("s", new SimpleSymbolicExpressionGrammar(), 50, 12))
25      ;
26      // Add additional initialization code e.g. private variables that you need for evaluating
27    }
28
29    public double[] Evaluate(Individual individual, IRandom random) {
30      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
31      var qualities = new[] { 0.0, 0.0 };
32      //qualities = new [] { individual.RealVector("r").Sum(x => x * x), individual.RealVector("r").Sum(x => x * x * x) };
33      return qualities;
34    }
35
36    public void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
37      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
38      // Write or update results given the range of vectors and resulting qualities
39    }
40    // Implement further classes and methods
41  }
42}
43
Note: See TracBrowser for help on using the repository browser.