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.PermutationEncoding;
|
---|
10 | using HeuristicLab.Encodings.RealVectorEncoding;
|
---|
11 | using HeuristicLab.Optimization;
|
---|
12 | using HeuristicLab.Problems.Programmable;
|
---|
13 |
|
---|
14 | namespace 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 |
|
---|