Ignore:
Timestamp:
07/20/16 14:02:36 (5 years ago)
Author:
gkronber
Message:

#1966: refactoring of bin packing implementation

File:
1 edited

Legend:

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

    r14064 r14128  
    3333  [Item("PackingSequenceCreator", "Creator class used to create PackingSequence solutions for bin packing problems.")]
    3434  [StorableClass]
    35   public class PackingSequenceRandomCreator : PackingSolutionCreator, IStochasticOperator {
     35  public class PackingSequenceRandomCreator : PackingSolutionCreator, IPackingSequenceCreator, IStochasticOperator {
    3636
    3737    public ILookupParameter<IRandom> RandomParameter {
    3838      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    3939    }
    40     public IValueLookupParameter<IntValue> PackingItemsParameter {
    41       get { return (IValueLookupParameter<IntValue>)Parameters["PackingItems"]; }
     40    public ILookupParameter<IntValue> NumberOfPackingItemsParameter {
     41      get { return (ILookupParameter<IntValue>)Parameters["NumberOfItems"]; }
    4242    }
    4343
    44     public ILookupParameter<PackingSequence> SolutionParameter {
    45       get { return (ILookupParameter<PackingSequence>)Parameters["PackingItems"]; }
     44    public ILookupParameter<Permutation> SolutionParameter {
     45      get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; }
    4646    }
    4747
     
    5858      : base() {
    5959      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<PackingSequence>("PackingSequence"));
    62 
    63       SolutionParameter.ActualName = "PackingSequence";
     60      Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfPackingItems", "The number of packing-items handled in this problem instance."));
     61      Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The randomly created solution candidate."));
    6462    }
    6563
    6664    public override IOperation Apply() {
    67       Apply(PackingItemsParameter.ActualValue.Value, RandomParameter.ActualValue);
     65      Apply(NumberOfPackingItemsParameter.ActualValue.Value, RandomParameter.ActualValue);
    6866      return base.Apply();
    6967    }
    7068
    71     public static PackingSequenceEncoding Apply(int items, IRandom random) {
    72       var solution = new PackingSequenceEncoding();
    73       solution.PackingSequence = new Permutation(PermutationTypes.Absolute, items, random);
    74       return solution;
     69    public static Permutation Apply(int items, IRandom random) {
     70      return new Permutation(PermutationTypes.Absolute, items, random);
    7571    }
    7672    protected override IItem CreateSolution() {
    77       return Apply(PackingItemsParameter.ActualValue.Value, RandomParameter.ActualValue);
     73      return Apply(NumberOfPackingItemsParameter.ActualValue.Value, RandomParameter.ActualValue);
    7874    }
    7975  }
Note: See TracChangeset for help on using the changeset viewer.