Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/18/19 13:42:12 (6 years ago)
Author:
mkommend
Message:

#2521: Adapted binary problems and moved to abstract base class to encoding.

Location:
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorProblem.cs

    r16805 r16814  
    2424using System;
    2525using System.Linq;
     26using HEAL.Attic;
    2627using HeuristicLab.Analysis;
    2728using HeuristicLab.Common;
    2829using HeuristicLab.Core;
    2930using HeuristicLab.Data;
    30 using HeuristicLab.Encodings.BinaryVectorEncoding;
    3131using HeuristicLab.Optimization;
    3232using HeuristicLab.Optimization.Operators;
    3333using HeuristicLab.Parameters;
    34 using HEAL.Attic;
    3534
    36 namespace HeuristicLab.Problems.Binary {
     35namespace HeuristicLab.Encodings.BinaryVectorEncoding {
    3736  [StorableType("2F6FEB34-BD19-47AF-9484-7F48565C0C43")]
    38   public abstract class BinaryProblem : SingleObjectiveProblem<BinaryVectorEncoding, BinaryVector> {
    39     public virtual int Length {
     37  public abstract class BinaryVectorProblem : SingleObjectiveProblem<BinaryVectorEncoding, BinaryVector> {
     38    public int Length {
    4039      get { return Encoding.Length; }
    4140      set { Encoding.Length = value; }
     
    4746
    4847    [StorableConstructor]
    49     protected BinaryProblem(StorableConstructorFlag _) : base(_) { }
     48    protected BinaryVectorProblem(StorableConstructorFlag _) : base(_) { }
    5049    [StorableHook(HookType.AfterDeserialization)]
    5150    private void AfterDeserialization() {
     
    5352    }
    5453
    55     protected BinaryProblem(BinaryProblem original, Cloner cloner)
     54    protected BinaryVectorProblem(BinaryVectorProblem original, Cloner cloner)
    5655      : base(original, cloner) {
    5756      RegisterEventHandlers();
    5857    }
    5958
    60     protected BinaryProblem()
    61       : base() {
     59    protected BinaryVectorProblem() : base(new BinaryVectorEncoding()) {
    6260      var lengthParameter = new FixedValueParameter<IntValue>("Length", "The length of the BinaryVector.", new IntValue(10));
    6361      Parameters.Add(lengthParameter);
    6462      Encoding.LengthParameter = lengthParameter;
     63
    6564      Operators.Add(new HammingSimilarityCalculator());
    6665      Operators.Add(new QualitySimilarityCalculator());
    6766      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
     67
    6868      Parameterize();
    6969      RegisterEventHandlers();
     
    8989    private void Parameterize() {
    9090      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
    91         // TODO: BinaryVectorParameter is no more part of ISolutionCreator<BinaryVector>
    92         similarityCalculator.SolutionVariableName = ((IBinaryVectorSolutionOperator)Encoding.SolutionCreator).BinaryVectorParameter.ActualName;
     91        similarityCalculator.SolutionVariableName = Encoding.Name;
    9392        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
    9493      }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/HeuristicLab.Encodings.BinaryVectorEncoding-3.3.csproj

    r16723 r16814  
    119119  </ItemGroup>
    120120  <ItemGroup>
     121    <Compile Include="BinaryVectorProblem.cs" />
    121122    <Compile Include="BinaryVectorEncoding.cs" />
    122123    <Compile Include="BinaryVectorEqualityComparer.cs" />
     
    158159  </ItemGroup>
    159160  <ItemGroup>
     161    <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
     162      <Project>{887425b4-4348-49ed-a457-b7d2c26ddbf9}</Project>
     163      <Name>HeuristicLab.Analysis-3.3</Name>
     164      <Private>False</Private>
     165    </ProjectReference>
    160166    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    161167      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
Note: See TracChangeset for help on using the changeset viewer.