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 ENCODING_NAMESPACE;
|
---|
8 | using HeuristicLab.Optimization;
|
---|
9 | using HeuristicLab.Problems.Programmable;
|
---|
10 |
|
---|
11 | namespace HeuristicLab.Problems.Programmable {
|
---|
12 | public class CompiledMultiObjectiveProblemDefinition : CompiledMultiObjectiveProblemDefinition<ENCODING_CLASS, SOLUTION_CLASS> {
|
---|
13 | public override bool[] Maximization { get { return new[] { false, false }; } }
|
---|
14 | public override double[] ReferencePoint { get { return null; } }
|
---|
15 | public override IReadOnlyList<double[]> BestKnownFront { get { return null; } }
|
---|
16 |
|
---|
17 | public override void Initialize() {
|
---|
18 | // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
|
---|
19 | // Define e.g. the length of the solution encoding or the solution creator by modifying the Encoding property
|
---|
20 | // Encoding.Length = 100;
|
---|
21 | // Add additional initialization code e.g. private variables that you need for evaluating
|
---|
22 | }
|
---|
23 |
|
---|
24 | public override double[] Evaluate(SOLUTION_CLASS solution, IRandom random) {
|
---|
25 | // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
|
---|
26 | var quality = new[] { 0.0, 0.0 };
|
---|
27 | return quality;
|
---|
28 | }
|
---|
29 |
|
---|
30 | public override void Analyze(SOLUTION_CLASS[] solutions, double[][] qualities, ResultCollection results, IRandom random) {
|
---|
31 | // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
|
---|
32 | // Write or update results given the range of vectors and resulting qualities
|
---|
33 | }
|
---|
34 |
|
---|
35 | public override IEnumerable<SOLUTION_CLASS> GetNeighbors(SOLUTION_CLASS solution, IRandom random) {
|
---|
36 | // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
|
---|
37 | // Create new vectors, based on the given one that represent small changes
|
---|
38 | // This method is only called from move-based algorithms (Local Search, Simulated Annealing, etc.)
|
---|
39 | while (true) {
|
---|
40 | // Algorithm will draw only a finite amount of samples
|
---|
41 | // Change to a for-loop to return a concrete amount of neighbors
|
---|
42 | var neighbor = (SOLUTION_CLASS)solution.Clone();
|
---|
43 | // modify the solution specified as neighbor
|
---|
44 | yield return neighbor;
|
---|
45 | }
|
---|
46 | }
|
---|
47 |
|
---|
48 | // Implement further classes and methods
|
---|
49 | }
|
---|
50 | }
|
---|
51 |
|
---|