Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/New/Scripts/Templates/CompiledMultiObjectiveProblemDefinition.cs @ 11786

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

#2174: Changed operator parameterization in programmable problem.

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