Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Templates/CompiledMultiObjectiveProblemDefinition.cs @ 11949

Last change on this file since 11949 was 11949, checked in by mkommend, 9 years ago

#2174: Distributed files in programmable problem branch to the correct plugins.

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