Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/17/19 16:03:57 (5 years ago)
Author:
mkommend
Message:

#2521: Merged trunk changes and adapted programmable problem templates for combined solutions.

Location:
branches/2521_ProblemRefactoring
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring

  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/SingleObjectiveCombinedEncodingProblem_Template.cs

    r16723 r16801  
    1 using System.Collections.Generic;
     1using System;
     2using System.Linq;
     3using System.Collections.Generic;
     4using HeuristicLab.Common;
    25using HeuristicLab.Core;
    36using HeuristicLab.Data;
    47using HeuristicLab.Optimization;
    5 //using HeuristicLab.Encodings.BinaryVectorEncoding;
    6 //using HeuristicLab.Encodings.IntegerVectorEncoding;
    7 //using HeuristicLab.Encodings.RealVectorEncoding;
    8 //using HeuristicLab.Encodings.PermutationEncoding;
    9 //using HeuristicLab.Encodings.LinearLinkageEncoding;
     8using HeuristicLab.Encodings.BinaryVectorEncoding;
     9using HeuristicLab.Encodings.IntegerVectorEncoding;
     10using HeuristicLab.Encodings.RealVectorEncoding;
     11using HeuristicLab.Encodings.PermutationEncoding;
     12using HeuristicLab.Encodings.LinearLinkageEncoding;
     13using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    1014
    1115namespace HeuristicLab.Problems.Programmable {
     
    1721      // Define e.g. the length of the solution encoding or the solution creator by modifying the Encoding property
    1822      // Add additional initialization code e.g. private variables that you need for evaluating
    19       //Encoding.Add(new BinaryVectorEncoding("b") { Length = 10 });
     23      Encoding.Add(new BinaryVectorEncoding("b") { Length = 10 });
    2024      //Encoding.Add(new IntegerVectorEncoding("i") { Length = 10, Bounds = new IntMatrix(new int[,] { { -100, 100 } }) });
    21       //Encoding.Add(new RealVectorEncoding("r") { Length = 10, Bounds = new DoubleMatrix(new double[,] { { -100, 100 } }) });
     25      Encoding.Add(new RealVectorEncoding("r") { Length = 10, Bounds = new DoubleMatrix(new double[,] { { -100, 100 } }) });
    2226      //Encoding.Add(new PermutationEncoding("p") { Length = 20, Type = PermutationTypes.Absolute });
    2327      //Encoding.Add(new LinearLinkageEncoding("lle") { Length = 30 });
     
    2731      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    2832      var quality = 0.0;
    29       //var b = solution.GetSolution<BinaryVector>("b");
    30       //quality = b.Count(x => x); // one max!
    31       //var r = solution.GetSolution<RealVector>("r");
    32       //quality += r.Sum(x => -x * x); // sphere
     33      var b = solution.GetEncodedSolution<BinaryVector>("b");
     34      quality = b.Count(x => x); // one max!
     35      var r = solution.GetEncodedSolution<RealVector>("r");
     36      quality += r.Sum(x => -x * x); // sphere
    3337
    3438      // NOTE: Check the Maximization property above (true or false)!
     
    4549
    4650      //if (!results.ContainsKey("Best Solution")) {
    47       //  results.Add(new Result("Best Solution", typeof(SOLUTION_CLASS)));
     51      //  results.Add(new Result("Best Solution", typeof(CombinedSolution)));
    4852      //}
    4953      //results["Best Solution"].Value = (IItem)best.Clone();
Note: See TracChangeset for help on using the changeset viewer.