Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/08/16 21:54:26 (9 years ago)
Author:
gkronber
Message:

#1966: started work on PackingSequenceEncoding

Location:
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceEncoding.cs

    r13032 r13613  
    2525using HeuristicLab.Core;
    2626using HeuristicLab.Encodings.PermutationEncoding;
     27using HeuristicLab.Optimization;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2829using HeuristicLab.Problems.BinPacking.Interfaces;
     
    3132  [Item("Packing Sequence Encoding", "Represents an encoding for a bin packing problem using permutation of item-indexes to define the packing sequence.")]
    3233  [StorableClass]
    33   public class PackingSequenceEncoding : Item, IPackingSolutionEncoding {
     34  public class PackingSequenceEncoding : Encoding<PackingSequenceRandomCreator> {
    3435
    3536    [Storable]
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceRandomCreator.cs

    r13032 r13613  
    2525using HeuristicLab.Data;
    2626using HeuristicLab.Encodings.PermutationEncoding;
     27using HeuristicLab.Operators;
    2728using HeuristicLab.Optimization;
    2829using HeuristicLab.Parameters;
     
    3031
    3132namespace HeuristicLab.Encodings.PackingEncoding.PackingSequence {
    32   [Item("PackingSequenceCreator", "Creator class used to create PackingSequence solutions for bin packing problems.")]
    33   [StorableClass]
    34   public class PackingSequenceRandomCreator : PackingSolutionCreator, IStochasticOperator {
     33  [Item("PackingSequenceCreator", "Creator class used to create PackingSequence solutions for bin packing problems.")]
     34  [StorableClass]
     35  public class PackingSequenceRandomCreator : SingleSuccessorOperator, IPackingSequenceCreator, IStochasticOperator {
    3536
    36     public ILookupParameter<IRandom> RandomParameter {
    37       get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    38     }
    39     public IValueLookupParameter<IntValue> PackingItemsParameter {
    40       get { return (IValueLookupParameter<IntValue>)Parameters["PackingItems"]; }
    41     }
     37    public ILookupParameter<IRandom> RandomParameter {
     38      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     39    }
     40    public IValueLookupParameter<IntValue> PackingItemsParameter {
     41      get { return (IValueLookupParameter<IntValue>)Parameters["PackingItems"]; }
     42    }
    4243
    43     [StorableConstructor]
    44     protected PackingSequenceRandomCreator(bool deserializing) : base(deserializing) { }
    45     protected PackingSequenceRandomCreator(PackingSequenceRandomCreator original, Cloner cloner) : base(original, cloner) {
    46     }
    47     public override IDeepCloneable Clone(Cloner cloner) {
    48       return new PackingSequenceRandomCreator(this, cloner);
    49     }
     44    public ILookupParameter<Problems.BinPacking.Encodings.PackingSequence.PackingSequence> SolutionParameter {
     45      get { return (ILookupParameter<Problems.BinPacking.Encodings.PackingSequence.PackingSequence>)Parameters["PackingItems"]; }
     46    }
     47
     48    [StorableConstructor]
     49    protected PackingSequenceRandomCreator(bool deserializing) : base(deserializing) { }
     50    protected PackingSequenceRandomCreator(PackingSequenceRandomCreator original, Cloner cloner)
     51      : base(original, cloner) {
     52    }
     53    public override IDeepCloneable Clone(Cloner cloner) {
     54      return new PackingSequenceRandomCreator(this, cloner);
     55    }
    5056
    5157    public PackingSequenceRandomCreator()
    52       : base() {
    53       Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator."));
    54       Parameters.Add(new ValueLookupParameter<IntValue>("PackingItems", "The number of packing-items handled in this problem instance."));
     58      : base() {
     59      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator."));
     60      Parameters.Add(new ValueLookupParameter<IntValue>("PackingItems", "The number of packing-items handled in this problem instance."));
     61      Parameters.Add(new LookupParameter<Problems.BinPacking.Encodings.PackingSequence.PackingSequence>("PackingSequence"));
    5562
    56       EncodedSolutionParameter.ActualName = "PackingSequence";
    57     }
     63      SolutionParameter.ActualName = "PackingSequence";
     64    }
    5865
     66    public override IOperation Apply() {
     67      Apply(PackingItemsParameter.ActualValue.Value, RandomParameter.ActualValue);
     68      return base.Apply();
     69    }
    5970
    6071    public static PackingSequenceEncoding Apply(int items, IRandom random) {
     
    6475    }
    6576
    66     protected override IItem CreateSolution() {
    67       return Apply(PackingItemsParameter.ActualValue.Value, RandomParameter.ActualValue);
    68     }
    69   }
     77  }
    7078}
Note: See TracChangeset for help on using the changeset viewer.