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