Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16948 for branches


Ignore:
Timestamp:
05/13/19 15:21:54 (5 years ago)
Author:
abeham
Message:

#2521: Added and modified encoding-specific abstract base classes

Location:
branches/2521_ProblemRefactoring
Files:
4 added
10 edited

Legend:

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

    r16876 r16948  
    2828using HeuristicLab.Common;
    2929using HeuristicLab.Core;
    30 using HeuristicLab.Data;
    3130using HeuristicLab.Optimization;
    32 using HeuristicLab.Parameters;
    3331
    3432namespace HeuristicLab.Encodings.BinaryVectorEncoding {
     
    3836      get { return Encoding.Length; }
    3937      set { Encoding.Length = value; }
    40     }
    41 
    42     private IFixedValueParameter<IntValue> LengthParameter {
    43       get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; }
    4438    }
    4539
     
    5650    }
    5751
    58     protected BinaryVectorMultiObjectiveProblem() : base(new BinaryVectorEncoding()) {
    59       var lengthParameter = new FixedValueParameter<IntValue>("Length", "The length of the BinaryVector.", new IntValue(10));
    60       Parameters.Add(lengthParameter);
    61       Encoding.LengthParameter = lengthParameter;
     52    protected BinaryVectorMultiObjectiveProblem() : this(new BinaryVectorEncoding() { Length = 10 }) { }
     53    protected BinaryVectorMultiObjectiveProblem(BinaryVectorEncoding encoding) : base(encoding) {
     54      EncodingParameter.ReadOnly = true;
    6255
    6356      Operators.Add(new HammingSimilarityCalculator());
     
    7568    protected override void OnEncodingChanged() {
    7669      base.OnEncodingChanged();
    77       Encoding.LengthParameter = LengthParameter;
    7870      Parameterize();
    7971    }
     
    8779
    8880    private void RegisterEventHandlers() {
    89       LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged;
     81      Encoding.LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged;
    9082    }
    9183
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorProblem.cs

    r16814 r16948  
    2828using HeuristicLab.Common;
    2929using HeuristicLab.Core;
    30 using HeuristicLab.Data;
    3130using HeuristicLab.Optimization;
    3231using HeuristicLab.Optimization.Operators;
    33 using HeuristicLab.Parameters;
    3432
    3533namespace HeuristicLab.Encodings.BinaryVectorEncoding {
     
    3937      get { return Encoding.Length; }
    4038      set { Encoding.Length = value; }
    41     }
    42 
    43     private IFixedValueParameter<IntValue> LengthParameter {
    44       get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; }
    4539    }
    4640
     
    5751    }
    5852
    59     protected BinaryVectorProblem() : base(new BinaryVectorEncoding()) {
    60       var lengthParameter = new FixedValueParameter<IntValue>("Length", "The length of the BinaryVector.", new IntValue(10));
    61       Parameters.Add(lengthParameter);
    62       Encoding.LengthParameter = lengthParameter;
     53    protected BinaryVectorProblem() : this(new BinaryVectorEncoding() { Length = 10 }) { }
     54    protected BinaryVectorProblem(BinaryVectorEncoding encoding) : base(encoding) {
     55      EncodingParameter.ReadOnly = true;
    6356
    6457      Operators.Add(new HammingSimilarityCalculator());
     
    7568      var best = Maximization ? orderedIndividuals.Last().Individual : orderedIndividuals.First().Individual;
    7669
    77       if (!results.ContainsKey("Best Solution")) {
    78         results.Add(new Result("Best Solution", typeof(BinaryVector)));
    79       }
    80       results["Best Solution"].Value = (IItem)best.Clone();
     70      results.AddOrUpdateResult("Best Solution", (IItem)best.Clone());
    8171    }
    8272
    8373    protected override void OnEncodingChanged() {
    8474      base.OnEncodingChanged();
    85       Encoding.LengthParameter = LengthParameter;
    8675      Parameterize();
    8776    }
     
    9584
    9685    private void RegisterEventHandlers() {
    97       LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged;
     86      Encoding.LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged;
    9887    }
    9988
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorMultiObjectiveProblem.cs

    r16876 r16948  
    2828using HeuristicLab.Common;
    2929using HeuristicLab.Core;
    30 using HeuristicLab.Data;
    3130using HeuristicLab.Optimization;
    32 using HeuristicLab.Parameters;
    3331
    3432namespace HeuristicLab.Encodings.IntegerVectorEncoding {
     
    3836      get { return Encoding.Length; }
    3937      set { Encoding.Length = value; }
    40     }
    41 
    42     private IFixedValueParameter<IntValue> LengthParameter {
    43       get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; }
    4438    }
    4539
     
    5650    }
    5751
    58     protected IntegerVectorMultiObjectiveProblem() : base(new IntegerVectorEncoding()) {
    59       var lengthParameter = new FixedValueParameter<IntValue>("Length", "The length of the IntegerVector.", new IntValue(10));
    60       Parameters.Add(lengthParameter);
    61       Encoding.LengthParameter = lengthParameter;
     52    protected IntegerVectorMultiObjectiveProblem() : this(new IntegerVectorEncoding() { Length = 10 }) { }
     53    protected IntegerVectorMultiObjectiveProblem(IntegerVectorEncoding encoding) : base(encoding) {
     54      EncodingParameter.ReadOnly = true;
    6255
    6356      Operators.Add(new HammingSimilarityCalculator());
     
    7568    protected override void OnEncodingChanged() {
    7669      base.OnEncodingChanged();
    77       Encoding.LengthParameter = LengthParameter;
    7870      Parameterize();
    7971    }
     
    8779
    8880    private void RegisterEventHandlers() {
    89       LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged;
     81      Encoding.LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged;
    9082    }
    9183
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorProblem.cs

    r16876 r16948  
    2828using HeuristicLab.Common;
    2929using HeuristicLab.Core;
    30 using HeuristicLab.Data;
    3130using HeuristicLab.Optimization;
    3231using HeuristicLab.Optimization.Operators;
    33 using HeuristicLab.Parameters;
    3432
    3533namespace HeuristicLab.Encodings.IntegerVectorEncoding {
     
    3937      get { return Encoding.Length; }
    4038      set { Encoding.Length = value; }
    41     }
    42 
    43     private IFixedValueParameter<IntValue> LengthParameter {
    44       get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; }
    4539    }
    4640
     
    5751    }
    5852
    59     protected IntegerVectorProblem() : base(new IntegerVectorEncoding()) {
    60       var lengthParameter = new FixedValueParameter<IntValue>("Length", "The length of the IntegerVector.", new IntValue(10));
    61       Parameters.Add(lengthParameter);
    62       Encoding.LengthParameter = lengthParameter;
     53    protected IntegerVectorProblem() : this(new IntegerVectorEncoding() { Length = 10 }) { }
     54    protected IntegerVectorProblem(IntegerVectorEncoding encoding) : base(encoding) {
     55      EncodingParameter.ReadOnly = true;
    6356
    6457      Operators.Add(new HammingSimilarityCalculator());
     
    7568      var best = Maximization ? orderedIndividuals.Last().Individual : orderedIndividuals.First().Individual;
    7669
    77       if (!results.ContainsKey("Best Solution")) {
    78         results.Add(new Result("Best Solution", typeof(IntegerVector)));
    79       }
    80       results["Best Solution"].Value = (IItem)best.Clone();
     70      results.AddOrUpdateResult("Best Solution", (IItem)best.Clone());
    8171    }
    8272
    8373    protected override void OnEncodingChanged() {
    8474      base.OnEncodingChanged();
    85       Encoding.LengthParameter = LengthParameter;
    8675      Parameterize();
    8776    }
     
    9584
    9685    private void RegisterEventHandlers() {
    97       LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged;
     86      Encoding.LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged;
    9887    }
    9988
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/HeuristicLab.Encodings.LinearLinkageEncoding-3.4.csproj

    r16723 r16948  
    8888  </PropertyGroup>
    8989  <ItemGroup>
     90    <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
     91      <Project>{887425b4-4348-49ed-a457-b7d2c26ddbf9}</Project>
     92      <Name>HeuristicLab.Analysis-3.3</Name>
     93      <Private>False</Private>
     94    </ProjectReference>
    9095    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    9196      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
     
    164169    <Compile Include="Crossovers\MultiLLECrossover.cs" />
    165170    <Compile Include="Crossovers\SinglePointCrossover.cs" />
     171    <Compile Include="LinearLinkageMultiObjectiveProblem.cs" />
     172    <Compile Include="LinearLinkageProblem.cs" />
    166173    <Compile Include="Interfaces\ILinearLinkageMoveOperator.cs" />
    167174    <Compile Include="Interfaces\ILinearLinkageEMSSMoveOperator.cs" />
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/HeuristicLab.Encodings.PermutationEncoding-3.3.csproj

    r16723 r16948  
    115115  </ItemGroup>
    116116  <ItemGroup>
     117    <Compile Include="PermutationMultiObjectiveProblem.cs" />
     118    <Compile Include="PermutationProblem.cs" />
    117119    <Compile Include="Creators\RandomPermutationCreator.cs" />
    118120    <Compile Include="Crossovers\CosaCrossover.cs" />
     
    218220  </ItemGroup>
    219221  <ItemGroup>
     222    <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
     223      <Project>{887425b4-4348-49ed-a457-b7d2c26ddbf9}</Project>
     224      <Name>HeuristicLab.Analysis-3.3</Name>
     225      <Private>False</Private>
     226    </ProjectReference>
    220227    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    221228      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Problem.cs

    r16946 r16948  
    9696    protected Problem()
    9797      : base() {
    98       Parameters.Add(new ValueParameter<TEncoding>("Encoding", "Describes the configuration of the encoding, what the variables are called, what type they are and their bounds if any."));
    99       Parameters.Add(new ValueParameter<TEvaluator>("Evaluator", "The operator used to evaluate a solution."));
    100 
     98      Parameters.Add(new ValueParameter<TEncoding>("Encoding", "Describes the configuration of the encoding, what the variables are called, what type they are and their bounds if any.") { Hidden = true });
     99      Parameters.Add(new ValueParameter<TEvaluator>("Evaluator", "The operator used to evaluate a solution.") { Hidden = true });
     100     
    101101      if (Encoding != null) {
    102102        oldEncoding = Encoding;
     
    107107    protected Problem(TEncoding encoding) {
    108108      if (encoding == null) throw new ArgumentNullException("encoding");
    109       Parameters.Add(new ValueParameter<TEncoding>("Encoding", "Describes the configuration of the encoding, what the variables are called, what type they are and their bounds if any.", encoding));
    110       Parameters.Add(new ValueParameter<TEvaluator>("Evaluator", "The operator used to evaluate a solution."));
     109      Parameters.Add(new ValueParameter<TEncoding>("Encoding", "Describes the configuration of the encoding, what the variables are called, what type they are and their bounds if any.", encoding) { Hidden = true });
     110      Parameters.Add(new ValueParameter<TEvaluator>("Evaluator", "The operator used to evaluate a solution.") { Hidden = true });
    111111
    112112      oldEncoding = Encoding;
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.GraphColoring/3.3/GraphColoringProblem.cs

    r16808 r16948  
    3939  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 135)]
    4040  [StorableType("007BD5F0-196C-4045-AC5D-BF287927C3DC")]
    41   public sealed class GraphColoringProblem : SingleObjectiveProblem<LinearLinkageEncoding, LinearLinkage>,
     41  public sealed class GraphColoringProblem : LinearLinkageProblem,
    4242    IProblemInstanceConsumer<GCPData>, IProblemInstanceExporter<GCPData> {
    4343
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs

    r16723 r16948  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Analysis;
    2627using HeuristicLab.Common;
     
    3132using HeuristicLab.Optimization.Operators;
    3233using HeuristicLab.Parameters;
    33 using HEAL.Attic;
    3434
    3535namespace HeuristicLab.Problems.Knapsack {
     
    3737  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 200)]
    3838  [StorableType("8CEDAFA2-6E0A-4D4B-B6C6-F85CC58B824E")]
    39   public sealed class KnapsackProblem : SingleObjectiveProblem<BinaryVectorEncoding, BinaryVector> {
     39  public sealed class KnapsackProblem : BinaryVectorProblem {
    4040    public override bool Maximization { get { return true; } }
    4141
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs

    r16723 r16948  
    2424using System.Drawing;
    2525using System.Linq;
     26using HEAL.Attic;
    2627using HeuristicLab.Analysis;
    2728using HeuristicLab.Common;
     
    3233using HeuristicLab.Optimization.Operators;
    3334using HeuristicLab.Parameters;
    34 using HEAL.Attic;
    3535using HeuristicLab.PluginInfrastructure;
    3636using HeuristicLab.Problems.Instances;
     
    4040  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 140)]
    4141  [StorableType("A86B1F49-D8E6-45E4-8EFB-8F5CCA2F9DC7")]
    42   public sealed class QuadraticAssignmentProblem : SingleObjectiveProblem<PermutationEncoding, Permutation>,
     42  public sealed class QuadraticAssignmentProblem : PermutationProblem,
    4343    IProblemInstanceConsumer<QAPData>,
    4444    IProblemInstanceConsumer<TSPData> {
Note: See TracChangeset for help on using the changeset viewer.