Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.Problems.Programmable/3.3/Templates/CompiledMultiObjectiveProblemDefinition.cs @ 16565

Last change on this file since 16565 was 16565, checked in by gkronber, 5 years ago

#2520: merged changes from PersistenceOverhaul branch (r16451:16564) into trunk

File size: 2.4 KB
RevLine 
[16565]1using HeuristicLab.Core;
[11753]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() {
[11880]9      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
[11753]10      // Define the solution encoding which can also consist of multiple vectors, examples below
[11900]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);
[11753]14      //Encoding = new PermutationEncoding("p", length: 5, type: PermutationTypes.Absolute);
[12724]15      //Encoding = new LinearLinkageEncoding("l", length: 5);
16      //Encoding = new SymbolicExpressionTreeEncoding("s", new SimpleSymbolicExpressionGrammar(), 50, 12);
[11880]17      // The encoding can also be a combination
[11753]18      //Encoding = new MultiEncoding()
[11900]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))
[11753]22      //.Add(new PermutationEncoding("p", length: 5, type: PermutationTypes.Absolute))
[12731]23      //.Add(new LinearLinkageEncoding("l", length: 5))
24      //.Add(new SymbolicExpressionTreeEncoding("s", new SimpleSymbolicExpressionGrammar(), 50, 12))
[11753]25      ;
[11880]26      // Add additional initialization code e.g. private variables that you need for evaluating
[11753]27    }
28
29    public double[] Evaluate(Individual individual, IRandom random) {
[11880]30      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
[11753]31      var qualities = new[] { 0.0, 0.0 };
[11880]32      //qualities = new [] { individual.RealVector("r").Sum(x => x * x), individual.RealVector("r").Sum(x => x * x * x) };
[11753]33      return qualities;
34    }
35
[11880]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
[11753]39    }
[11880]40    // Implement further classes and methods
[11753]41  }
42}
43
Note: See TracBrowser for help on using the repository browser.