Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/09/17 00:36:20 (7 years ago)
Author:
abeham
Message:

#2701:

  • Added alternating bits binary test Problem
  • Refactored MemPR to work with programmable problem in current trunk
  • fixed a bug in permutation MemPR when crossover doesn't assign an offspring
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/Binary/BinaryMemPRContext.cs

    r14450 r14552  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Algorithms.MemPR.Interfaces;
    2324using HeuristicLab.Common;
     
    3132  [Item("MemPR Population Context (binary)", "MemPR population context for binary encoded problems.")]
    3233  [StorableClass]
    33   public sealed class BinaryMemPRPopulationContext : MemPRPopulationContext<SingleObjectiveBasicProblem<BinaryVectorEncoding>, BinaryVector, BinaryMemPRPopulationContext, BinaryMemPRSolutionContext> {
     34  public sealed class BinaryMemPRPopulationContext : MemPRPopulationContext<ISingleObjectiveHeuristicOptimizationProblem, BinaryVector, BinaryMemPRPopulationContext, BinaryMemPRSolutionContext> {
    3435
    3536    [StorableConstructor]
     
    4748      return new BinaryMemPRSolutionContext(this, solution);
    4849    }
     50
     51    public override ISingleObjectiveSolutionScope<BinaryVector> ToScope(BinaryVector code, double fitness = double.NaN) {
     52      var creator = Problem.SolutionCreator as IBinaryVectorCreator;
     53      if (creator == null) throw new InvalidOperationException("MemPR (binary) context expects a problem with an IBinaryVectorCreator as solution creator.");
     54      return new SingleObjectiveSolutionScope<BinaryVector>(code, creator.BinaryVectorParameter.ActualName, fitness, Problem.Evaluator.QualityParameter.ActualName) {
     55        Parent = Scope
     56      };
     57    }
    4958  }
    5059
    5160  [Item("MemPR Solution Context (binary)", "MemPR solution context for binary encoded problems.")]
    5261  [StorableClass]
    53   public sealed class BinaryMemPRSolutionContext : MemPRSolutionContext<SingleObjectiveBasicProblem<BinaryVectorEncoding>, BinaryVector, BinaryMemPRPopulationContext, BinaryMemPRSolutionContext>, IBinaryVectorSubspaceContext {
     62  public sealed class BinaryMemPRSolutionContext : MemPRSolutionContext<ISingleObjectiveHeuristicOptimizationProblem, BinaryVector, BinaryMemPRPopulationContext, BinaryMemPRSolutionContext>, IBinaryVectorSubspaceContext {
    5463
    5564    [Storable]
Note: See TracChangeset for help on using the changeset viewer.