Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/MultiObjectiveProblem_Template.cs @ 16386

Last change on this file since 16386 was 13373, checked in by abeham, 9 years ago

#2521: adapted templates, fixed missing reference in outdated plugin lawnmower

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