1 | using HeuristicLab.Core;
|
---|
2 | using HeuristicLab.Optimization;
|
---|
3 |
|
---|
4 | namespace 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 | // Define the solution encoding which can also consist of multiple vectors, examples below
|
---|
10 | //Encoding = new BinaryEncoding("b", length: 5);
|
---|
11 | //Encoding = new IntegerEncoding("i", length: 5, min: 2, max: 14, step: 4);
|
---|
12 | //Encoding = new RealEncoding("r", length: 5, min: -1.0, max: 1.0);
|
---|
13 | //Encoding = new PermutationEncoding("p", length: 5, type: PermutationTypes.Absolute);
|
---|
14 |
|
---|
15 | //Encoding = new MultiEncoding()
|
---|
16 | //.Add(new BinaryEncoding("b", length: 5))
|
---|
17 | //.Add(new IntegerEncoding("i", length: 5, min: 2, max: 14, step: 4))
|
---|
18 | //.Add(new RealEncoding("r", length: 5, min: -1.0, max: 1.0))
|
---|
19 | //.Add(new PermutationEncoding("p", length: 5, type: PermutationTypes.Absolute))
|
---|
20 | ;
|
---|
21 | }
|
---|
22 |
|
---|
23 | public double[] Evaluate(Individual individual, IRandom random) {
|
---|
24 | var qualities = new[] { 0.0, 0.0 };
|
---|
25 | // use vars.yourVariable to access variables in the variable store i.e. yourVariable
|
---|
26 | // qualities = new [] { individual.RealVector(""r"").Sum(x => x * x), individual.RealVector(""r"").Sum(x => x * x * x) };
|
---|
27 | return qualities;
|
---|
28 | }
|
---|
29 |
|
---|
30 | public void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results) {
|
---|
31 | // write or update results given the range of vectors and resulting qualities
|
---|
32 | // use e.g. vars.yourVariable to access variables in the variable store i.e. yourVariable
|
---|
33 | }
|
---|
34 | // implement further classes and methods
|
---|
35 | }
|
---|
36 | }
|
---|
37 |
|
---|