Free cookie consent management tool by TermsFeed Policy Generator

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

#1966: refactoring of bin packing implementation

Location:
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3
Files:
38 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Analyzers/BestBinPackingSolutionAnalyzer.cs

    r14050 r14128  
    9393      }
    9494      string binUtilKey = "Overall Bin Utilization";
    95       DoubleValue binUtil = BinUtilizationEvaluator<D, B, I>.CalculateBinUtilization(bestSolution);
     95      var binUtil = new DoubleValue(BinUtilizationEvaluator<D, B, I>.CalculateBinUtilization(bestSolution));
    9696      if (!results.ContainsKey(binUtilKey))
    9797        results.Add(new Result(binUtilKey, binUtil));
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking.cs

    r14048 r14128  
    4040
    4141    [Storable]
    42     public ObservableDictionary<int, I> ItemMeasures { get; private set; } // TODO: renamed to item
     42    public ObservableDictionary<int, I> ItemMeasures { get; private set; } // TODO: rename to items
    4343
    4444    [Storable]
    45     public B BinMeasures { get; private set; }
     45    public B BinMeasures { get; private set; } 
    4646
    4747    [Storable]
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs

    r14050 r14128  
    2828using HeuristicLab.Data;
    2929using HeuristicLab.Collections;
    30 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector;
    31 using HeuristicLab.Encodings.PackingEncoding.GroupingVector;
    32 using HeuristicLab.Encodings.PackingEncoding.PackingSequence;
    3330using HeuristicLab.Encodings.IntegerVectorEncoding;
    3431using HeuristicLab.Problems.BinPacking;
     32using HeuristicLab.Encodings.PermutationEncoding;
    3533
    3634namespace HeuristicLab.Encodings.PackingEncoding {
     
    9896    }
    9997
     98    /*
    10099    public void Pack(MultiComponentVectorEncoding solution, ItemList<I> itemMeasures) {
    101100      var sequenceMatrix = solution.GenerateSequenceMatrix();
     
    197196      solution.GroupingVector = new IntegerVector(newSolution);
    198197    }
    199     public void Pack(PackingSequenceEncoding solution, ItemList<I> itemMeasures) {
    200       List<int> remainingIDs = new List<int>(solution.PackingSequence);
     198     *
     199     
     200    public void Pack(Permutation solution, ItemList<I> itemMeasures) {
     201      List<int> remainingIDs = new List<int>(solution);
    201202      while (remainingIDs.Count > 0) {
    202203        var bp = NewBinPacking();
     
    210211    }
    211212
    212 
     213    */
    213214    #region Events
    214215    public event EventHandler QualityChanged;
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Encoding.cs

    r14064 r14128  
    66using HeuristicLab.Common;
    77using HeuristicLab.Core;
     8using HeuristicLab.Encodings.PermutationEncoding;
    89using HeuristicLab.Optimization;
    910using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    1314namespace HeuristicLab.Encodings.PackingEncoding.PackingSequence {
    1415  [StorableClass]
    15   internal class Encoding : HeuristicLab.Optimization.Encoding<PackingSolutionCreator> {
     16  public class Encoding : HeuristicLab.Optimization.Encoding<IPackingSolutionCreator> {
    1617    [StorableConstructor]
    1718    private Encoding(bool deserializing) : base(deserializing) { }
    18     public Encoding() : base("PackingSequence") {
     19    public Encoding()
     20      : base("PackingSequence") {
    1921      SolutionCreator = new PackingSequenceRandomCreator();
    2022      RegisterParameterEvents();
     
    6466
    6567  public static class IndividualExtensionMethods {
    66     public static PackingSequence PackingSequence(this Individual individual) {
     68    public static Permutation PackingSequence(this Individual individual) {
    6769      var encoding = individual.GetEncoding<Encoding>();
    6870      return individual.PackingSequence(encoding.Name);
    6971    }
    7072
    71     public static PackingSequence PackingSequence(this Individual individual, string name) {
    72       return (PackingSequence)individual[name];
     73    public static Permutation PackingSequence(this Individual individual, string name) {
     74      return (Permutation)individual[name];
    7375    }
    7476  }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/IPackingSequenceCreator.cs

    r14064 r14128  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Data;
     25using HeuristicLab.Encodings.PermutationEncoding;
    2526using HeuristicLab.Optimization;
    2627using HeuristicLab.Problems.BinPacking;
     
    2829namespace HeuristicLab.Encodings.PackingEncoding.PackingSequence {
    2930  interface IPackingSequenceCreator : ISolutionCreator, IPackingSequenceOperator {
    30     IValueLookupParameter<IntValue> PackingItemsParameter { get; }
    31     ILookupParameter<PackingSequence> SolutionParameter { get; }
    32 
     31    ILookupParameter<IntValue> NumberOfPackingItemsParameter { get; }
     32    ILookupParameter<Permutation> SolutionParameter { get; }
    3333  }
    3434}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/GroupingMoveHardTabuCriterion.cs

    r14046 r14128  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Data;
     26using HeuristicLab.Encodings.PermutationEncoding;
    2627using HeuristicLab.Operators;
    2728using HeuristicLab.Optimization;
     
    3738      get { return false; }
    3839    }
    39     public ILookupParameter<IPackingMove> PackingMoveParameter {
    40       get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; }
     40    public ILookupParameter<IPackingMove<Permutation>> PackingMoveParameter {
     41      get { return (ILookupParameter<IPackingMove<Permutation>>)Parameters["PackingMove"]; }
    4142    }
    42     public ILookupParameter<PackingSequenceEncoding> PackingSequenceParameter {
    43       get { return (ILookupParameter<PackingSequenceEncoding>)Parameters["PackingSequence"]; }
     43    public ILookupParameter<Permutation> PackingSequenceParameter {
     44      get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; }
    4445    }
    4546    public ILookupParameter<ItemList<IItem>> TabuListParameter {
     
    6465    public SequenceMoveHardTabuCriterion()
    6566      : base() {
    66       Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate."));
    67       Parameters.Add(new LookupParameter<PackingSequenceEncoding>("PackingSequence", "The solution to evaluate."));
     67      Parameters.Add(new LookupParameter<IPackingMove<Permutation>>("PackingMove", "The move to evaluate."));
     68      Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The solution candidate to evaluate."));
    6869      Parameters.Add(new LookupParameter<BoolValue>("MoveTabu", "The variable to store if a move was tabu."));
    6970      Parameters.Add(new LookupParameter<ItemList<IItem>>("TabuList", "The tabu list."));
     
    8081      ItemList<IItem> tabuList = TabuListParameter.ActualValue;
    8182      SequenceMove move = PackingMoveParameter.ActualValue as SequenceMove;
    82       PackingSequenceEncoding PackingSequence = PackingSequenceParameter.ActualValue;
    83       int length = PackingSequence.PackingSequence.Length;
    8483      double moveQuality = MoveQualityParameter.ActualValue.Value;
    8584      bool maximization = MaximizationParameter.ActualValue.Value;
    8685      bool useAspiration = UseAspirationCriterionParameter.Value.Value;
    87       bool isTabu = IsMoveTabu(tabuList, move, PackingSequence, moveQuality, maximization, useAspiration);
     86      bool isTabu = IsMoveTabu(tabuList, move, moveQuality, maximization, useAspiration);
    8887
    8988      MoveTabuParameter.ActualValue = new BoolValue(isTabu);
     
    9190    }
    9291
    93     private bool IsMoveTabu(ItemList<IItem> tabuList, SequenceMove move, PackingSequenceEncoding PackingSequence, double moveQuality, bool maximization, bool useAspiration) {
     92    private bool IsMoveTabu(ItemList<IItem> tabuList, SequenceMove move, double moveQuality, bool maximization, bool useAspiration) {
    9493      bool isTabu = false;
    95       var attributes = tabuList.FindAll(ta => ta.GetType().Equals(move.GetMoveAttributeType()));
     94      var attributes = tabuList.FindAll(ta => ta.GetType() == move.GetMoveAttributeType());
    9695
    9796      foreach (IItem attr in attributes) {
     
    102101              || !maximization && moveQuality >= gvAttr.MoveQuality)) {
    103102
    104           isTabu = move.BelongsToAttribute(gvAttr, true);
     103          isTabu = move.BelongsToAttribute(gvAttr, true); // only difference to soft tabu criterion
    105104        }
    106105        if (isTabu) break;
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/GroupingMoveMaker.cs

    r14046 r14128  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Data;
     26using HeuristicLab.Encodings.PermutationEncoding;
    2627using HeuristicLab.Operators;
    2728using HeuristicLab.Optimization;
     
    4344      get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; }
    4445    }
    45     public ILookupParameter<IPackingMove> PackingMoveParameter {
    46       get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; }
     46    public ILookupParameter<IPackingMove<Permutation>> PackingMoveParameter {
     47      get { return (ILookupParameter<IPackingMove<Permutation>>)Parameters["PackingMove"]; }
    4748    }
    48     public ILookupParameter<PackingSequenceEncoding> PackingSequenceParameter {
    49       get { return (ILookupParameter<PackingSequenceEncoding>)Parameters["PackingSequence"]; }
     49    public ILookupParameter<Permutation> PackingSequenceParameter {
     50      get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; }
    5051    }
    5152    public ILookupParameter<IPackingPlan> PackingPlanParameter {
     
    6263      : base() {
    6364      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the solution."));
    64       Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate."));
     65      Parameters.Add(new LookupParameter<IPackingMove<Permutation>>("PackingMove", "The move to evaluate."));
    6566      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move."));
    66       Parameters.Add(new LookupParameter<PackingSequenceEncoding>("PackingSequence", "The solution as Sequence vector."));
     67      Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The solution as Sequence vector."));
    6768      Parameters.Add(new LookupParameter<IPackingPlan>("PackingPlan", "The currently best performing, decoded bin-packing solution represented as generalized packing-plan."));
    6869      Parameters.Add(new LookupParameter<IPackingPlan>("PackingPlanAfterMove", "The moved and decoded bin-packing solution represented as generalized packing-plan."));
     
    7475
    7576    public override IOperation Apply() {
    76       IPackingMove move = PackingMoveParameter.ActualValue;
    77       PackingSequenceEncoding PackingSequence = PackingSequenceParameter.ActualValue;
    7877      DoubleValue moveQuality = MoveQualityParameter.ActualValue;
    7978      DoubleValue quality = QualityParameter.ActualValue;
    8079
    81       PackingSequence.PackingSequence = (move.GetSolutionAfterMove() as PackingSequenceEncoding).PackingSequence;
    8280      PackingPlanParameter.ActualValue = PackingPlanAfterMoveParameter.ActualValue;
    8381
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/GroupingMoveSoftTabuCriterion.cs

    r14046 r14128  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Data;
     26using HeuristicLab.Encodings.PermutationEncoding;
    2627using HeuristicLab.Operators;
    2728using HeuristicLab.Optimization;
     
    3839      get { return false; }
    3940    }
    40     public ILookupParameter<IPackingMove> PackingMoveParameter {
    41       get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; }
     41    public ILookupParameter<IPackingMove<Permutation>> PackingMoveParameter {
     42      get { return (ILookupParameter<IPackingMove<Permutation>>)Parameters["PackingMove"]; }
    4243    }
    43     public ILookupParameter<PackingSequenceEncoding> PackingSequenceParameter {
    44       get { return (ILookupParameter<PackingSequenceEncoding>)Parameters["PackingSequence"]; }
     44    public ILookupParameter<Permutation> PackingSequenceParameter {
     45      get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; }
    4546    }
    4647    public ILookupParameter<ItemList<IItem>> TabuListParameter {
     
    6566    public SequenceMoveSoftTabuCriterion()
    6667      : base() {
    67       Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate."));
    68       Parameters.Add(new LookupParameter<PackingSequenceEncoding>("PackingSequence", "The solution to evaluate."));
     68      Parameters.Add(new LookupParameter<IPackingMove<Permutation>>("PackingMove", "The move to evaluate."));
     69      Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The solution to evaluate."));
    6970      Parameters.Add(new LookupParameter<BoolValue>("MoveTabu", "The variable to store if a move was tabu."));
    7071      Parameters.Add(new LookupParameter<ItemList<IItem>>("TabuList", "The tabu list."));
     
    8182      ItemList<IItem> tabuList = TabuListParameter.ActualValue;
    8283      SequenceMove move = PackingMoveParameter.ActualValue as SequenceMove;
    83       PackingSequenceEncoding PackingSequence = PackingSequenceParameter.ActualValue;
    84       int length = PackingSequence.PackingSequence.Length;
    8584      double moveQuality = MoveQualityParameter.ActualValue.Value;
    86       bool maximization = MaximizationParameter.ActualValue.Value;   
     85      bool maximization = MaximizationParameter.ActualValue.Value;
    8786      bool useAspiration = UseAspirationCriterionParameter.Value.Value;
    88       bool isTabu = IsMoveTabu(tabuList, move, PackingSequence, moveQuality, maximization, useAspiration);
     87      bool isTabu = IsMoveTabu(tabuList, move, moveQuality, maximization, useAspiration);
    8988
    9089      MoveTabuParameter.ActualValue = new BoolValue(isTabu);
     
    9291    }
    9392
    94     private bool IsMoveTabu(ItemList<IItem> tabuList, SequenceMove move, PackingSequenceEncoding PackingSequence, double moveQuality, bool maximization, bool useAspiration) {
     93    private bool IsMoveTabu(ItemList<IItem> tabuList, SequenceMove move, double moveQuality, bool maximization, bool useAspiration) {
    9594      bool isTabu = false;
    96       var attributes = tabuList.FindAll(ta => ta.GetType().Equals(move.GetMoveAttributeType()));
     95      var attributes = tabuList.FindAll(ta => ta.GetType() == move.GetMoveAttributeType());
    9796
    9897      foreach (IItem attr in attributes) {
     
    103102              || !maximization && moveQuality >= gvAttr.MoveQuality)) {
    104103
    105           isTabu = move.BelongsToAttribute(gvAttr, false);
     104          isTabu = move.BelongsToAttribute(gvAttr, false); // only difference to hard tabu criterion
    106105        }
    107106        if (isTabu) break;
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Insertion/ExhaustiveInsertionMoveGenerator.cs

    r13032 r14128  
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Core;
     26using HeuristicLab.Encodings.PermutationEncoding;
    2627using HeuristicLab.Optimization;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3940      return new ExhaustiveInsertionMoveGenerator(this, cloner);
    4041    }
    41     public static IEnumerable<InsertionMove> Generate(PackingSequenceEncoding PackingSequence, int nrOfBins) {
    42       for (int i = 0; i < PackingSequence.PackingSequence.Length - 1; i++)
    43         for (int j = i + 1; j < PackingSequence.PackingSequence.Length; j++) {
     42    public static IEnumerable<InsertionMove> Generate(Permutation packingSequence, int nrOfBins) {
     43      for (int i = 0; i < packingSequence.Length - 1; i++)
     44        for (int j = i + 1; j < packingSequence.Length; j++) {
    4445          if (j != i)
    45             yield return new InsertionMove(i, j, PackingSequence);
     46            yield return new InsertionMove(i, j, packingSequence);
    4647        }
    4748    }
    4849
    49     public static InsertionMove[] Apply(PackingSequenceEncoding PackingSequence) {
     50    public static InsertionMove[] Apply(Permutation packingSequence) {
    5051      int nrOfBins = 0;
    51       foreach (int binNr in PackingSequence.PackingSequence) {
     52      foreach (int binNr in packingSequence) {
    5253        if (binNr > nrOfBins)
    5354          nrOfBins = binNr;
     
    5556      nrOfBins++;
    5657
    57       int totalMoves = (PackingSequence.PackingSequence.Length * (PackingSequence.PackingSequence.Length - 1)) / 2;
     58      int totalMoves = (packingSequence.Length * (packingSequence.Length - 1)) / 2;
    5859      InsertionMove[] moves = new InsertionMove[totalMoves];
    5960      int count = 0;
    60       foreach (InsertionMove move in Generate(PackingSequence, nrOfBins)) {
     61      foreach (InsertionMove move in Generate(packingSequence, nrOfBins)) {
    6162        moves[count++] = move;
    6263      }
     
    6465    }
    6566
    66     protected override InsertionMove[] GenerateMoves(PackingSequenceEncoding PackingSequence) {
    67       return Apply(PackingSequence);
     67    protected override InsertionMove[] GenerateMoves(Permutation packingSequence) {
     68      return Apply(packingSequence);
    6869    }
    6970  }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Insertion/InsertionMove.cs

    r14046 r14128  
    3232  [Item("Insertion Move", "A move on a Sequence vector that is specified by two group-assignment-indexes.")]
    3333  [StorableClass]
    34   public class InsertionMove : SequenceMove, IPackingMove {
     34  public class InsertionMove : SequenceMove {
    3535    [Storable]
    3636    public int Index1 { get; protected set; }
     
    4545      this.Index2 = original.Index2;
    4646    }
    47     public InsertionMove(int index1, int index2, PackingSequenceEncoding PackingSequence)
    48       : base(PackingSequence) {
     47    public InsertionMove(int index1, int index2, Permutation packingSequence)
     48      : base(packingSequence) {
    4949      Index1 = index1;
    5050      Index2 = index2;
     
    5555    }
    5656
    57     public override IPackingSolutionEncoding GetSolutionAfterMove() {
    58       PackingSequenceEncoding newSolution = new PackingSequenceEncoding();
    59 
    60       Permutation original = PackingSequence.PackingSequence;
    61       Permutation resultingPermutation = (Permutation)PackingSequence.PackingSequence.Clone();
     57    public override Permutation GetSolutionAfterMove() {
     58      Permutation original = PackingSequence;
     59      Permutation resultingPermutation = (Permutation)PackingSequence.Clone();
    6260      int cutIndex, insertIndex, number;
    6361
     
    6866      int i = 0;  // index in new permutation
    6967      int j = 0;  // index in old permutation
    70       while (i < PackingSequence.PackingSequence.Length) {
     68      while (i < PackingSequence.Length) {
    7169        if (j == cutIndex) {
    7270          j++;
     
    8381      }
    8482
    85       newSolution.PackingSequence = resultingPermutation;
    86       return newSolution;
     83      return resultingPermutation;
    8784    }
    8885
     
    9289
    9390    public override SequenceMoveAttribute GetAttribute(double quality) {
    94       return new InsertionMoveAttribute(Index1, Index2, PackingSequence.PackingSequence[Index1], PackingSequence.PackingSequence[Index2], quality);
     91      return new InsertionMoveAttribute(Index1, Index2, PackingSequence[Index1], PackingSequence[Index2], quality);
    9592    }
    9693
     
    103100        } else
    104101          if (Index1 == attr.Index1 && Index2 == attr.Index2)
    105           return true;
     102            return true;
    106103      }
    107104      return false;
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Insertion/InsertionMoveGenerator.cs

    r14046 r14128  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
     25using HeuristicLab.Encodings.PermutationEncoding;
    2526using HeuristicLab.Operators;
    2627using HeuristicLab.Optimization;
     
    3738      get { return false; }
    3839    }
    39     public ILookupParameter<PackingSequenceEncoding> PackingSequenceParameter {
    40       get { return (ILookupParameter<PackingSequenceEncoding>)Parameters["PackingSequence"]; }
     40    public ILookupParameter<Permutation> PackingSequenceParameter {
     41      get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; }
    4142    }
    42     public ILookupParameter<IPackingMove> PackingMoveParameter {
    43       get { return (LookupParameter<IPackingMove>)Parameters["PackingMove"]; }
     43    public ILookupParameter<IPackingMove<Permutation>> PackingMoveParameter {
     44      get { return (LookupParameter<IPackingMove<Permutation>>)Parameters["PackingMove"]; }
    4445    }
    4546    protected ScopeParameter CurrentScopeParameter {
     
    5253    public InsertionMoveGenerator()
    5354      : base() {
    54       Parameters.Add(new LookupParameter<PackingSequenceEncoding>("PackingSequence", "The Sequence vector for which moves should be generated."));
    55       Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The moves that should be generated in subscopes."));
     55      Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The Sequence vector for which moves should be generated."));
     56      Parameters.Add(new LookupParameter<IPackingMove<Permutation>>("PackingMove", "The moves that should be generated in subscopes."));
    5657      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the moves should be added as subscopes."));
    5758    }
    5859
    5960    public override IOperation Apply() {
    60       PackingSequenceEncoding ps = PackingSequenceParameter.ActualValue;
     61      Permutation ps = PackingSequenceParameter.ActualValue;
    6162      InsertionMove[] moves = GenerateMoves(ps);
    6263      Scope[] moveScopes = new Scope[moves.Length];
     
    6970    }
    7071
    71     protected abstract InsertionMove[] GenerateMoves(PackingSequenceEncoding PackingSequence);
     72    protected abstract InsertionMove[] GenerateMoves(Permutation packingSequence);
    7273  }
    7374}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Insertion/StochasticInsertionMoveGenerator.cs

    r13032 r14128  
    2525using HeuristicLab.Core;
    2626using HeuristicLab.Data;
     27using HeuristicLab.Encodings.PermutationEncoding;
    2728using HeuristicLab.Optimization;
    2829using HeuristicLab.Parameters;
     
    5859    }
    5960
    60     public static InsertionMove[] Apply(PackingSequenceEncoding PackingSequence, IRandom random, int sampleSize) {
     61    public static InsertionMove[] Apply(Permutation packingSequence, IRandom random, int sampleSize) {
    6162
    6263      int nrOfBins = 0;
    63       foreach (int binNr in PackingSequence.PackingSequence) {
     64      foreach (int binNr in packingSequence) {
    6465        if (binNr > nrOfBins)
    6566          nrOfBins = binNr;
     
    6768      nrOfBins++;
    6869      var generatedMoves = new List<InsertionMove>();
    69       var moves = new List<InsertionMove>(ExhaustiveInsertionMoveGenerator.Generate(PackingSequence, nrOfBins));
     70      var moves = new List<InsertionMove>(ExhaustiveInsertionMoveGenerator.Generate(packingSequence, nrOfBins));
    7071      int moveCount = moves.Count;
    7172      for (int i = 0; i < sampleSize; i++) {
     
    7677    }
    7778
    78     protected override InsertionMove[] GenerateMoves(PackingSequenceEncoding SwapSequence) {
     79    protected override InsertionMove[] GenerateMoves(Permutation packingSequence) {
    7980      IRandom random = RandomParameter.ActualValue;
    80       return Apply(SwapSequence, random, SampleSizeParameter.ActualValue.Value);
     81      return Apply(packingSequence, random, SampleSizeParameter.ActualValue.Value);
    8182    }
    8283  }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/SequenceMove.cs

    r14046 r14128  
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Core;
     26using HeuristicLab.Encodings.PermutationEncoding;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2728using HeuristicLab.Problems.BinPacking;
    2829
    2930namespace HeuristicLab.Encodings.PackingEncoding.PackingSequence {
    30   [Item("SequenceMove", "An abstract move for a packingSequence encoded solution.")]
     31  [Item("SequenceMove", "An abstract move for a packing sequence encoded solution.")]
    3132  [StorableClass]
    32   public abstract class SequenceMove : Item, IPackingMove {
     33  public abstract class SequenceMove : Item, IPackingMove<Permutation> {
    3334    [Storable]
    34     public PackingSequenceEncoding PackingSequence { get; protected set; }
     35    public Permutation PackingSequence { get; protected set; }
    3536
    3637    [StorableConstructor]
     
    4142          this.PackingSequence = cloner.Clone(original.PackingSequence);
    4243    }
    43     public SequenceMove(PackingSequenceEncoding packingSequence)
     44    public SequenceMove(Permutation packingSequence)
    4445      : base() {
    4546        PackingSequence = packingSequence;
    4647    }
    4748
    48     public abstract IPackingSolutionEncoding GetSolutionAfterMove();
     49    public abstract Permutation GetSolutionAfterMove();
    4950    public abstract Type GetMoveAttributeType();
    5051    public abstract SequenceMoveAttribute GetAttribute(double quality);
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/SequenceTabuMaker.cs

    r14046 r14128  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
     25using HeuristicLab.Encodings.PermutationEncoding;
    2526using HeuristicLab.Optimization.Operators;
    2627using HeuristicLab.Parameters;
     
    3233  [StorableClass]
    3334  public class SequenceTabuMaker : TabuMaker, IPackingSequenceMoveOperator {
    34     public ILookupParameter<IPackingMove> PackingMoveParameter {
    35       get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; }
     35    public ILookupParameter<IPackingMove<Permutation>> PackingMoveParameter {
     36      get { return (ILookupParameter<IPackingMove<Permutation>>)Parameters["PackingMove"]; }
    3637    }
    37     public ILookupParameter<PackingSequenceEncoding> PackingSequenceParameter {
    38       get { return (ILookupParameter<PackingSequenceEncoding>)Parameters["PackingSequence"]; }
     38    public ILookupParameter<Permutation> PackingSequenceParameter {
     39      get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; }
    3940    }
    4041
     
    4445    public SequenceTabuMaker()
    4546      : base() {
    46       Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate."));
    47       Parameters.Add(new LookupParameter<PackingSequenceEncoding>("PackingSequence", "The solution to evaluate."));
     47      Parameters.Add(new LookupParameter<IPackingMove<Permutation>>("PackingMove", "The move to evaluate."));
     48      Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The solution to evaluate."));
    4849    }
    4950
     
    5354
    5455    protected override IItem GetTabuAttribute(bool maximization, double quality, double moveQuality) {
    55       IPackingMove move = PackingMoveParameter.ActualValue;
    56       PackingSequenceEncoding PackingSequence = PackingSequenceParameter.ActualValue;
     56      var move = PackingMoveParameter.ActualValue;
    5757      double baseQuality = moveQuality;
    5858      if (maximization && quality > moveQuality || !maximization && quality < moveQuality)
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Swap2/ExhaustiveSwap2MoveGenerator.cs

    r13032 r14128  
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Core;
     26using HeuristicLab.Encodings.PermutationEncoding;
    2627using HeuristicLab.Optimization;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3940      return new ExhaustiveSwap2MoveGenerator(this, cloner);
    4041    }
    41     public static IEnumerable<Swap2Move> Generate(PackingSequenceEncoding PackingSequence, int nrOfBins) {
    42       for (int i = 0; i < PackingSequence.PackingSequence.Length - 1; i++)
    43         for (int j = i + 1; j < PackingSequence.PackingSequence.Length; j++) {
     42    public static IEnumerable<Swap2Move> Generate(Permutation packingSequence, int nrOfBins) {
     43      for (int i = 0; i < packingSequence.Length - 1; i++)
     44        for (int j = i + 1; j < packingSequence.Length; j++) {
    4445          if (j != i)
    45             yield return new Swap2Move(i, j, PackingSequence);
     46            yield return new Swap2Move(i, j, packingSequence);
    4647        }
    4748    }
    4849
    49     public static Swap2Move[] Apply(PackingSequenceEncoding PackingSequence) {
     50    public static Swap2Move[] Apply(Permutation packingSequence) {
    5051      int nrOfBins = 0;
    51       foreach (int binNr in PackingSequence.PackingSequence) {
     52      foreach (int binNr in packingSequence) {
    5253        if (binNr > nrOfBins)
    5354          nrOfBins = binNr;
     
    5556      nrOfBins++;
    5657
    57       int totalMoves = (PackingSequence.PackingSequence.Length * (PackingSequence.PackingSequence.Length - 1)) / 2;
     58      int totalMoves = (packingSequence.Length * (packingSequence.Length - 1)) / 2;
    5859      Swap2Move[] moves = new Swap2Move[totalMoves];
    5960      int count = 0;
    60       foreach (Swap2Move move in Generate(PackingSequence, nrOfBins)) {
     61      foreach (Swap2Move move in Generate(packingSequence, nrOfBins)) {
    6162        moves[count++] = move;
    6263      }
     
    6465    }
    6566
    66     protected override Swap2Move[] GenerateMoves(PackingSequenceEncoding PackingSequence) {
    67       return Apply(PackingSequence);
     67    protected override Swap2Move[] GenerateMoves(Permutation packingSequence) {
     68      return Apply(packingSequence);
    6869    }
    6970  }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Swap2/StochasticSwap2MoveGenerator.cs

    r13032 r14128  
    2525using HeuristicLab.Core;
    2626using HeuristicLab.Data;
     27using HeuristicLab.Encodings.PermutationEncoding;
    2728using HeuristicLab.Optimization;
    2829using HeuristicLab.Parameters;
     
    5859    }
    5960
    60     public static Swap2Move[] Apply(PackingSequenceEncoding PackingSequence, IRandom random, int sampleSize) {
     61    public static Swap2Move[] Apply(Permutation packingSequence, IRandom random, int sampleSize) {
    6162
    6263      int nrOfBins = 0;
    63       foreach (int binNr in PackingSequence.PackingSequence) {
     64      foreach (int binNr in packingSequence) {
    6465        if (binNr > nrOfBins)
    6566          nrOfBins = binNr;
     
    6768      nrOfBins++;
    6869      var generatedMoves = new List<Swap2Move>();
    69       var moves = new List<Swap2Move>(ExhaustiveSwap2MoveGenerator.Generate(PackingSequence, nrOfBins));
     70      var moves = new List<Swap2Move>(ExhaustiveSwap2MoveGenerator.Generate(packingSequence, nrOfBins));
    7071      int moveCount = moves.Count;
    7172      for (int i = 0; i < sampleSize; i++) {
     
    7677    }
    7778
    78     protected override Swap2Move[] GenerateMoves(PackingSequenceEncoding SwapSequence) {
     79    protected override Swap2Move[] GenerateMoves(Permutation packingSequence) {
    7980      IRandom random = RandomParameter.ActualValue;
    80       return Apply(SwapSequence, random, SampleSizeParameter.ActualValue.Value);
     81      return Apply(packingSequence, random, SampleSizeParameter.ActualValue.Value);
    8182    }
    8283  }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Swap2/Swap2Move.cs

    r14046 r14128  
    3232  [Item("Swap2 Move", "A move on a Sequence vector that is specified by two group-assignment-indexes.")]
    3333  [StorableClass]
    34   public class Swap2Move : SequenceMove, IPackingMove {
     34  public class Swap2Move : SequenceMove, IPackingMove<Permutation> {
    3535    [Storable]
    3636    public int Index1 { get; protected set; }
     
    4545      this.Index2 = original.Index2;
    4646    }
    47     public Swap2Move(int index1, int index2, PackingSequenceEncoding PackingSequence)
    48       : base(PackingSequence) {
     47    public Swap2Move(int index1, int index2, Permutation packingSequence)
     48      : base(packingSequence) {
    4949      Index1 = index1;
    5050      Index2 = index2;
     
    5555    }
    5656
    57     public override IPackingSolutionEncoding GetSolutionAfterMove() {
    58       PackingSequenceEncoding newSolution = new PackingSequenceEncoding();
    59       newSolution.PackingSequence = (Permutation)PackingSequence.PackingSequence.Clone(new Cloner());
    60       newSolution.PackingSequence[Index1] = PackingSequence.PackingSequence[Index2];
    61       newSolution.PackingSequence[Index2] = PackingSequence.PackingSequence[Index1];
     57    public override Permutation GetSolutionAfterMove() {
     58      Permutation newSolution = (Permutation)PackingSequence.Clone(new Cloner());
     59      newSolution[Index1] = PackingSequence[Index2];
     60      newSolution[Index2] = PackingSequence[Index1];
    6261      return newSolution;
    6362    }
     
    6867
    6968    public override SequenceMoveAttribute GetAttribute(double quality) {
    70       return new Swap2MoveAttribute(Index1, Index2, PackingSequence.PackingSequence[Index1], PackingSequence.PackingSequence[Index2], quality);
     69      return new Swap2MoveAttribute(Index1, Index2, PackingSequence[Index1], PackingSequence[Index2], quality);
    7170    }
    7271
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Swap2/Swap2MoveGenerator.cs

    r14046 r14128  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
     25using HeuristicLab.Encodings.PermutationEncoding;
    2526using HeuristicLab.Operators;
    2627using HeuristicLab.Optimization;
     
    3637      get { return false; }
    3738    }
    38     public ILookupParameter<PackingSequenceEncoding> PackingSequenceParameter {
    39       get { return (ILookupParameter<PackingSequenceEncoding>)Parameters["PackingSequence"]; }
     39    public ILookupParameter<Permutation> PackingSequenceParameter {
     40      get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; }
    4041    }
    41     public ILookupParameter<IPackingMove> PackingMoveParameter {
    42       get { return (LookupParameter<IPackingMove>)Parameters["PackingMove"]; }
     42    public ILookupParameter<IPackingMove<Permutation>> PackingMoveParameter {
     43      get { return (LookupParameter<IPackingMove<Permutation>>)Parameters["PackingMove"]; }
    4344    }
    4445    protected ScopeParameter CurrentScopeParameter {
     
    5152    public Swap2MoveGenerator()
    5253      : base() {
    53       Parameters.Add(new LookupParameter<PackingSequenceEncoding>("PackingSequence", "The Sequence vector for which moves should be generated."));
    54       Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The moves that should be generated in subscopes."));
     54      Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The Sequence vector for which moves should be generated."));
     55      Parameters.Add(new LookupParameter<IPackingMove<Permutation>>("PackingMove", "The moves that should be generated in subscopes."));
    5556      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the moves should be added as subscopes."));
    5657    }
    5758
    5859    public override IOperation Apply() {
    59       PackingSequenceEncoding ps = PackingSequenceParameter.ActualValue;
     60      Permutation ps = PackingSequenceParameter.ActualValue;
    6061      Swap2Move[] moves = GenerateMoves(ps);
    6162      Scope[] moveScopes = new Scope[moves.Length];
     
    6869    }
    6970
    70     protected abstract Swap2Move[] GenerateMoves(PackingSequenceEncoding PackingSequence);
     71    protected abstract Swap2Move[] GenerateMoves(Permutation packingSequence);
    7172  }
    7273}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceCrossover.cs

    r14046 r14128  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
     25using HeuristicLab.Encodings.PermutationEncoding;
    2526using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2627using HeuristicLab.Problems.BinPacking;
     
    2930  [Item("PackingSequenceCrossover", "An operator which crosses two PackingSequence representations.")]
    3031  [StorableClass]
    31   public abstract class PackingSequenceCrossover : PackingSolutionCrossover, IPackingSequenceOperator {
     32  public abstract class PackingSequenceCrossover : PackingSolutionCrossover<Permutation>, IPackingSequenceOperator {
    3233
    3334    [StorableConstructor]
     
    3637    public PackingSequenceCrossover()
    3738      : base() {
    38         ParentsParameter.ActualName = "PackingSequence";
    39         ChildParameter.ActualName = "PackingSequence";
     39      ParentsParameter.ActualName = "PackingSequence";
     40      ChildParameter.ActualName = "PackingSequence";
    4041    }
    4142
    42     public abstract PackingSequenceEncoding Cross(IRandom random, PackingSequenceEncoding parent1, PackingSequenceEncoding parent2);
     43    public abstract Permutation Cross(IRandom random, Permutation parent1, Permutation parent2);
    4344
    4445    public override IOperation Apply() {
     
    4647
    4748      ChildParameter.ActualValue =
    48         Cross(RandomParameter.ActualValue, parents[0] as PackingSequenceEncoding, parents[1] as PackingSequenceEncoding);
     49        Cross(RandomParameter.ActualValue, parents[0], parents[1]);
    4950
    5051      return base.Apply();
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceInversionManipulator.cs

    r14046 r14128  
    4343    }
    4444
    45     protected override void Manipulate(IRandom random, PackingSequenceEncoding individual) {
    46       InversionManipulator.Apply(random, individual.PackingSequence);
     45    protected override void Manipulate(IRandom random, Permutation individual) {
     46      InversionManipulator.Apply(random, individual);
    4747    }
    4848  }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceManipulator.cs

    r14046 r14128  
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Core;
     26using HeuristicLab.Encodings.PermutationEncoding;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2728using HeuristicLab.Problems.BinPacking;
     
    3031  [Item("PackingSequenceManipulator", "An operator which manipulates a PackingSequence representation.")]
    3132  [StorableClass]
    32   public abstract class PackingSequenceManipulator : PackingSolutionManipulator, IPackingSequenceOperator {
     33  public abstract class PackingSequenceManipulator : PackingSolutionManipulator<Permutation>, IPackingSequenceOperator {
    3334    [StorableConstructor]
    3435    protected PackingSequenceManipulator(bool deserializing) : base(deserializing) { }
     
    3940    }
    4041
    41     protected abstract void Manipulate(IRandom random, PackingSequenceEncoding individual);
     42    protected abstract void Manipulate(IRandom random, Permutation individual);
    4243
    4344    public override IOperation Apply() {
    44       var solution = EncodedSolutionParameter.ActualValue as PackingSequenceEncoding;
     45      var solution = EncodedSolutionParameter.ActualValue;
    4546      if (solution == null) throw new InvalidOperationException("PackingSolutionEncoding was not found or is not of type PackingSequenceEncoding.");
    4647      Manipulate(RandomParameter.ActualValue, solution);
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceOrderCrossover.cs

    r14046 r14128  
    3030  [Item("PackingSequence OX", "An operator which crosses two PackingSequence representations using the OX-strategy.")]
    3131  [StorableClass]
    32   public class PackingSequenceOrderCrossover : PackingSequenceCrossover, IPackingSequenceOperator {
     32  public class PackingSequenceOrderCrossover : PackingSequenceCrossover {
    3333
    3434    [StorableConstructor]
     
    4242    }
    4343
    44     public override PackingSequenceEncoding Cross(IRandom random, PackingSequenceEncoding parent1, PackingSequenceEncoding parent2) {
    45       PackingSequenceEncoding result = new PackingSequenceEncoding();
    46       result.PackingSequence = OrderCrossover.Apply(random, parent1.PackingSequence, parent2.PackingSequence);
    47       return result;
     44    public override Permutation Cross(IRandom random, Permutation parent1, Permutation parent2) {
     45      return OrderCrossover.Apply(random, parent1, parent2);
    4846    }
    4947  }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequencePartiallyMatchedCrossover.cs

    r14046 r14128  
    3131  [Item("PackingSequence PMX", "An operator which crosses two PackingSequence representations using the OX-strategy.")]
    3232  [StorableClass]
    33   public class PackingSequencePartiallyMatchedCrossover : PackingSequenceCrossover, IPackingSequenceOperator {
     33  public class PackingSequencePartiallyMatchedCrossover : PackingSequenceCrossover {
    3434
    3535    [StorableConstructor]
     
    4343    }
    4444
    45     public override PackingSequenceEncoding Cross(IRandom random, PackingSequenceEncoding parent1, PackingSequenceEncoding parent2) {
    46       PackingSequenceEncoding result = new PackingSequenceEncoding();
    47       result.PackingSequence = PartiallyMatchedCrossover.Apply(random, parent1.PackingSequence, parent2.PackingSequence);
    48       return result;
     45    public override Permutation Cross(IRandom random, Permutation parent1, Permutation parent2) {
     46      return PartiallyMatchedCrossover.Apply(random, parent1, parent2);
    4947    }
    5048  }
  • 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  }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceScrambleManipulator.cs

    r14046 r14128  
    4141    }
    4242
    43     protected override void Manipulate(IRandom random, PackingSequenceEncoding individual) {
    44       ScrambleManipulator.Apply(random, individual.PackingSequence);
     43    protected override void Manipulate(IRandom random, Permutation individual) {
     44      ScrambleManipulator.Apply(random, individual);
    4545    }
    4646  }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSolutionCrossover.cs

    r14046 r14128  
    3232  [Item("PackingSolutionCrossover", "A bin packing crossover operation.")]
    3333  [StorableClass]
    34   public abstract class PackingSolutionCrossover : SingleSuccessorOperator, IPackingSolutionCrossover, IStochasticOperator {
     34  public abstract class PackingSolutionCrossover<T> : SingleSuccessorOperator, IPackingSolutionCrossover<T>, IStochasticOperator
     35  where T : class, IItem {
    3536
    36     public ILookupParameter<IPackingSolutionEncoding> ChildParameter {
    37       get { return (ILookupParameter<IPackingSolutionEncoding>)Parameters["Child"]; }
     37    public ILookupParameter<T> ChildParameter {
     38      get { return (ILookupParameter<T>)Parameters["Child"]; }
    3839    }
    39     public IScopeTreeLookupParameter<IPackingSolutionEncoding> ParentsParameter {
    40       get { return (IScopeTreeLookupParameter<IPackingSolutionEncoding>)Parameters["Parents"]; }
     40    public IScopeTreeLookupParameter<T> ParentsParameter {
     41      get { return (IScopeTreeLookupParameter<T>)Parameters["Parents"]; }
    4142    }
    4243    public ILookupParameter<IRandom> RandomParameter {
     
    4647    [StorableConstructor]
    4748    protected PackingSolutionCrossover(bool deserializing) : base(deserializing) { }
    48     protected PackingSolutionCrossover(PackingSolutionCrossover original, Cloner cloner) : base(original, cloner) { }
     49    protected PackingSolutionCrossover(PackingSolutionCrossover<T> original, Cloner cloner) : base(original, cloner) { }
    4950    public PackingSolutionCrossover()
    5051      : base() {
    5152      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    52       Parameters.Add(new LookupParameter<IPackingSolutionEncoding>("Child", "The child solution resulting from the crossover."));
     53      Parameters.Add(new LookupParameter<T>("Child", "The child solution resulting from the crossover."));
    5354      ChildParameter.ActualName = "EncodedSolution";
    54       Parameters.Add(new ScopeTreeLookupParameter<IPackingSolutionEncoding>("Parents", "The parent solution which should be crossed."));
     55      Parameters.Add(new ScopeTreeLookupParameter<T>("Parents", "The parent solution which should be crossed."));
    5556      ParentsParameter.ActualName = "EncodedSolution";
    5657    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSolutionManipulator.cs

    r14046 r14128  
    3232  [Item("PackingSolutionManipulator", "A bin packing manipulation operation.")]
    3333  [StorableClass]
    34   public abstract class PackingSolutionManipulator : SingleSuccessorOperator, IPackingSolutionManipulator, IStochasticOperator {
     34  public abstract class PackingSolutionManipulator<T> : SingleSuccessorOperator, IPackingSolutionManipulator<T>, IStochasticOperator
     35  where T : class, IItem {
    3536
    36     public ILookupParameter<IPackingSolutionEncoding> EncodedSolutionParameter {
    37       get { return (ILookupParameter<IPackingSolutionEncoding>)Parameters["EncodedSolution"]; }
     37    public ILookupParameter<T> EncodedSolutionParameter {
     38      get { return (ILookupParameter<T>)Parameters["EncodedSolution"]; }
    3839    }
    3940
     
    4445    [StorableConstructor]
    4546    protected PackingSolutionManipulator(bool deserializing) : base(deserializing) { }
    46     protected PackingSolutionManipulator(PackingSolutionManipulator original, Cloner cloner) : base(original, cloner) { }
     47    protected PackingSolutionManipulator(PackingSolutionManipulator<T> original, Cloner cloner) : base(original, cloner) { }
    4748    public PackingSolutionManipulator()
    4849      : base() {
    49       Parameters.Add(new LookupParameter<IPackingSolutionEncoding>("EncodedSolution", "The bin packing solution to be manipulated."));
     50      Parameters.Add(new LookupParameter<T>("EncodedSolution", "The bin packing solution to be manipulated."));
    5051      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    5152    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/BinUtilizationEvaluator.cs

    r14051 r14128  
    4242    public BinUtilizationEvaluator() : base() { }
    4343
    44     protected override DoubleValue Evaluate() {
     44    protected override double Evaluate() {
    4545      DoubleValue quality = new DoubleValue(0);
    4646
     
    6767    }
    6868
    69     public static DoubleValue CalculateBinUtilization(PackingPlan<D, B, I> plan) {
     69    public static double CalculateBinUtilization(PackingPlan<D, B, I> plan) {
    7070      int nrOfBins = plan.NrOfBins;
    7171      double result = 0;
     
    9797
    9898      result = totalUsedSpace / totalUsableSpace;
    99       return new DoubleValue(result);
     99      return result;
    100100    }
    101101  }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/EvaluatorBase.cs

    r14052 r14128  
    7575    }
    7676
    77     protected abstract DoubleValue Evaluate();                                                                       
     77    protected abstract double Evaluate();                                                                       
    7878    public override IOperation Apply() {
    79       QualityParameter.ActualValue = Evaluate();
     79      QualityParameter.ActualValue = new DoubleValue(Evaluate());
    8080      return base.Apply();
    8181    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/PackingRatioEvaluator.cs

    r14050 r14128  
    4141    public PackingRatioEvaluator() : base() { }
    4242
    43     protected override DoubleValue Evaluate() {
     43    protected override double Evaluate() {
    4444      DoubleValue quality = new DoubleValue(0);
    4545
     
    7474        k.......a constant, k>1.
    7575     */
    76     public static DoubleValue CalculatePackingRatio(PackingPlan<D, B, I> plan) {
     76    public static double CalculatePackingRatio(PackingPlan<D, B, I> plan) {
    7777      int nrOfBins = plan.NrOfBins;
    7878      double result = 0;
     
    9090        //k = 2 --> (Fi/C)*(Fi/C)
    9191        //result += (((usedSpaceInThisBin) / (usableSpace)) * ((usedSpaceInThisBin) / (usableSpace))) / (i*i + 1);
    92         var PD = plan.BinPackings[i].PackingDensity;
    93         result += (PD * PD) / (i + 1);
     92        var pd = plan.BinPackings[i].PackingDensity;
     93        result += (pd * pd) / (i + 1);
    9494      }
    9595
    9696      result = result / nrOfBins;
    97       return new DoubleValue(result);
     97      return result;
    9898    }
    9999  }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj

    r14064 r14128  
    160160    <Compile Include="Analyzers\BestBinPackingSolutionAnalyzer.cs" />
    161161    <Compile Include="Analyzers\BinPackingAnalyzer.cs" />
    162     <Compile Include="Encodings\GroupingVector\GroupingVectorSwap2Manipulator.cs" />
    163     <Compile Include="Encodings\GroupingVector\GroupingVectorSinglePointCrossover.cs" />
    164     <Compile Include="Encodings\GroupingVector\GroupingVectorDiscreteCrossover.cs" />
    165     <Compile Include="Encodings\GroupingVector\Moves\GroupingMove.cs" />
    166     <Compile Include="Encodings\GroupingVector\Moves\GroupingMoveAttribute.cs" />
    167     <Compile Include="Encodings\GroupingVector\Moves\SwapGrouping\ExhaustiveSwapGroupingMoveGenerator.cs" />
    168     <Compile Include="Encodings\GroupingVector\Moves\SwapGrouping\SwapGroupingMove.cs" />
    169     <Compile Include="Encodings\GroupingVector\Moves\SwapGrouping\SwapGroupingMoveAttribute.cs" />
    170     <Compile Include="Encodings\GroupingVector\Moves\SwapGrouping\SwapGroupingMoveGenerator.cs" />
    171     <Compile Include="Encodings\GroupingVector\Moves\GroupingMoveMaker.cs" />
    172     <Compile Include="Encodings\GroupingVector\Moves\GroupingTabuMaker.cs" />
    173     <Compile Include="Encodings\GroupingVector\Moves\SwapGrouping\StochasticSwapGroupingMoveGenerator.cs" />
    174     <Compile Include="Encodings\GroupingVector\Moves\GroupingMoveSoftTabuCriterion.cs" />
    175     <Compile Include="Encodings\GroupingVector\Moves\ChangeGrouping\ExhaustiveChangeGroupingMoveGenerator.cs" />
    176     <Compile Include="Encodings\GroupingVector\Moves\ChangeGrouping\ChangeGroupingMove.cs" />
    177     <Compile Include="Encodings\GroupingVector\Moves\ChangeGrouping\ChangeGroupingMoveAttribute.cs" />
    178     <Compile Include="Encodings\GroupingVector\Moves\ChangeGrouping\ChangeGroupingMoveGenerator.cs" />
    179     <Compile Include="Encodings\GroupingVector\Moves\GroupingMoveHardTabuCriterion.cs" />
    180     <Compile Include="Encodings\GroupingVector\Moves\ChangeGrouping\StochasticChangeGroupingMoveGenerator.cs" />
    181     <Compile Include="Encodings\GroupingVector\GroupingVectorOnePositionManipulator.cs" />
    182     <Compile Include="Encodings\GroupingVector\GroupingVectorCrossover.cs" />
    183     <Compile Include="Encodings\GroupingVector\GroupingVectorEncoding.cs" />
    184     <Compile Include="Encodings\GroupingVector\GroupingVectorManipulator.cs" />
    185     <Compile Include="Encodings\GroupingVector\GroupingVectorRandomCreator.cs" />
    186     <Compile Include="Encodings\MultiComponentVector\SequenceBasedMultiComponentVectorCrossover.cs" />
    187     <Compile Include="Encodings\MultiComponentVector\BinBasedMultiComponentVectorCrossover.cs" />
    188     <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Attributes\ChangePositionMoveAttribute.cs" />
    189     <Compile Include="Encodings\MultiComponentVector\Moves\Triple\Attributes\MCVTripleMoveAttribute.cs" />
    190     <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Attributes\SwapPositionMoveAttribute.cs" />
    191     <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Attributes\SingleGroupingMoveAttribute.cs" />
    192     <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMoveAttribute.cs" />
    193     <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Attributes\SingleItemRotationMoveAttribute.cs" />
    194     <Compile Include="Encodings\MultiComponentVector\Moves\Triple\StochasticMCVTripleMoveGenerator.cs" />
    195     <Compile Include="Encodings\MultiComponentVector\Moves\Triple\ExhaustiveMCVTripleMoveGenerator.cs" />
    196     <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Moves\ChangePositionMove.cs" />
    197     <Compile Include="Encodings\MultiComponentVector\Moves\Triple\Moves\MCVTripleMove.cs" />
    198     <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMoveHardTabuCriterion.cs" />
    199     <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMove.cs" />
    200     <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Moves\SwapPositionMove.cs" />
    201     <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Moves\SingleItemRotationMove.cs" />
    202     <Compile Include="Encodings\MultiComponentVector\Moves\Multi\ExhaustiveMultiComponentVectorMoveGenerator.cs" />
    203     <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Moves\SingleGroupingMove.cs" />
    204     <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMoveGenerator.cs" />
    205     <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMoveSoftTabuCriterion.cs" />
    206     <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMoveMaker.cs" />
    207     <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorTabuMaker.cs" />
    208     <Compile Include="Encodings\MultiComponentVector\Moves\Multi\StochasticMultiComponentVectorMoveGenerator.cs" />
    209     <Compile Include="Encodings\MultiComponentVector\MultiComponentVectorEncoding.cs">
    210       <SubType>Code</SubType>
    211     </Compile>
    212     <Compile Include="Encodings\MultiComponentVector\MultiComponentVectorCrossover.cs" />
    213     <Compile Include="Encodings\MultiComponentVector\MultiComponentVectorManipulator.cs" />
    214     <Compile Include="Encodings\MultiComponentVector\MultiComponentVectorRandomCreator.cs" />
    215     <Compile Include="Encodings\MultiComponentVector\ThreeWayMultiComponentVectorManipulator.cs" />
    216162    <Compile Include="Encodings\PackingPlans\BinPacking.cs" />
    217163    <Compile Include="Encodings\PackingPlans\PackingPlan.cs" />
    218     <Compile Include="Encodings\PackingSequence\Encoding.cs" />
    219     <Compile Include="Encodings\PackingSequence\IPackingSequenceCreator.cs" />
    220     <Compile Include="Encodings\PackingSequence\Moves\Insertion\ExhaustiveInsertionMoveGenerator.cs" />
    221     <Compile Include="Encodings\PackingSequence\Moves\Insertion\StochasticInsertionMoveGenerator.cs" />
    222     <Compile Include="Encodings\PackingSequence\Moves\Insertion\InsertionMove.cs" />
    223     <Compile Include="Encodings\PackingSequence\Moves\Insertion\InsertionMoveAttribute.cs" />
    224     <Compile Include="Encodings\PackingSequence\Moves\Insertion\InsertionMoveGenerator.cs" />
    225     <Compile Include="Encodings\PackingSequence\PackingSequence.cs" />
    226     <Compile Include="Encodings\PackingSequence\PackingSequenceInversionManipulator.cs" />
    227     <Compile Include="Encodings\PackingSequence\PackingSequencePartiallyMatchedCrossover.cs" />
    228     <Compile Include="Encodings\PackingSequence\PackingSequenceOrderCrossover.cs" />
    229     <Compile Include="Encodings\PackingSequence\Moves\SequenceMove.cs" />
    230     <Compile Include="Encodings\PackingSequence\Moves\SequenceMoveAttribute.cs" />
    231     <Compile Include="Encodings\PackingSequence\Moves\GroupingMoveHardTabuCriterion.cs" />
    232     <Compile Include="Encodings\PackingSequence\Moves\GroupingMoveMaker.cs" />
    233     <Compile Include="Encodings\PackingSequence\Moves\GroupingMoveSoftTabuCriterion.cs" />
    234     <Compile Include="Encodings\PackingSequence\Moves\SequenceTabuMaker.cs" />
    235     <Compile Include="Encodings\PackingSequence\Moves\Swap2\ExhaustiveSwap2MoveGenerator.cs" />
    236     <Compile Include="Encodings\PackingSequence\Moves\Swap2\StochasticSwap2MoveGenerator.cs" />
    237     <Compile Include="Encodings\PackingSequence\Moves\Swap2\Swap2Move.cs" />
    238     <Compile Include="Encodings\PackingSequence\Moves\Swap2\Swap2MoveAttribute.cs" />
    239     <Compile Include="Encodings\PackingSequence\Moves\Swap2\Swap2MoveGenerator.cs" />
    240     <Compile Include="Encodings\PackingSequence\PackingSequenceCrossover.cs">
    241       <SubType>Code</SubType>
    242     </Compile>
    243     <Compile Include="Encodings\PackingSequence\PackingSequenceEncoding.cs">
    244       <SubType>Code</SubType>
    245     </Compile>
    246     <Compile Include="Encodings\PackingSequence\PackingSequenceManipulator.cs">
    247       <SubType>Code</SubType>
    248     </Compile>
    249     <Compile Include="Encodings\PackingSequence\PackingSequenceRandomCreator.cs" />
    250     <Compile Include="Encodings\PackingSequence\PackingSequenceScrambleManipulator.cs" />
    251164    <Compile Include="Encodings\PackingSolutionCreator.cs" />
    252165    <Compile Include="Encodings\PackingSolutionCrossover.cs" />
     
    282195    <Compile Include="Plugin.cs" />
    283196    <Compile Include="PackingSequenceProblem.cs" />
    284     <Compile Include="Problem.cs" />
    285197    <Compile Include="Properties\AssemblyInfo.cs" />
    286198  </ItemGroup>
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingMove.cs

    r14046 r14128  
    2323
    2424namespace HeuristicLab.Problems.BinPacking  {
    25   public interface IPackingMove : IItem {
    26     IPackingSolutionEncoding GetSolutionAfterMove();
     25  public interface IPackingMove<out T> : IItem {
     26    T GetSolutionAfterMove();
    2727  }
    2828}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingSolutionCreator.cs

    r14046 r14128  
    2424
    2525namespace HeuristicLab.Problems.BinPacking {
    26   public interface IPackingSolutionCreator : ISolutionCreator{
     26  public interface IPackingSolutionCreator : ISolutionCreator {
    2727    ILookupParameter<IItem> EncodedSolutionParameter { get; }
    2828  }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingSolutionCrossover.cs

    r14046 r14128  
    2525
    2626namespace HeuristicLab.Problems.BinPacking {
    27   public interface IPackingSolutionCrossover : ICrossover, IPackingOperator {
    28     ILookupParameter<IPackingSolutionEncoding> ChildParameter { get; }
    29     IScopeTreeLookupParameter<IPackingSolutionEncoding> ParentsParameter { get; }
     27  public interface IPackingSolutionCrossover<T> : ICrossover, IPackingOperator
     28  where T : class, IItem {
     29    ILookupParameter<T> ChildParameter { get; }
     30    IScopeTreeLookupParameter<T> ParentsParameter { get; }
    3031  }
    3132}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingSolutionManipulator.cs

    r14046 r14128  
    2424
    2525namespace HeuristicLab.Problems.BinPacking {
    26   public interface IPackingSolutionManipulator : IManipulator, IPackingOperator {
    27     ILookupParameter<IPackingSolutionEncoding> EncodedSolutionParameter { get; }
     26  public interface IPackingSolutionManipulator<T> : IManipulator, IPackingOperator
     27  where T : class, IItem {
     28    ILookupParameter<T> EncodedSolutionParameter { get; }
    2829  }
    2930}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingMoveEvaluator.cs

    r14050 r14128  
    2424using HeuristicLab.Data;
    2525using HeuristicLab.Encodings.PackingEncoding;
     26using HeuristicLab.Encodings.PermutationEncoding;
    2627using HeuristicLab.Operators;
    2728using HeuristicLab.Optimization;
     
    3233  [Item("PackingMoveEvaluator", "A base class for operators which evaluate Packing-Solution moves.")]
    3334  [StorableClass]
    34   public abstract class PackingMoveEvaluator<D, B, I> : SingleSuccessorOperator, IPackingMoveEvaluator, IMoveOperator
     35  public abstract class PackingMoveEvaluator<D, B, I, M> : SingleSuccessorOperator, IPackingMoveEvaluator
    3536    where D : class, IPackingPosition
    3637    where B : PackingShape<D>
    37     where I : PackingShape<D>, IPackingItem {     
     38    where I : PackingShape<D>, IPackingItem
     39    where M : IItem {     
    3840    public override bool CanChangeName {
    3941      get { return false; }
     
    6163      get { return (ScopeParameter)Parameters["CurrentScope"]; }
    6264    }
    63     public ILookupParameter<IPackingMove> PackingMoveParameter {
    64       get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; }
     65    public ILookupParameter<IPackingMove<M>> PackingMoveParameter {
     66      get { return (ILookupParameter<IPackingMove<M>>)Parameters["PackingMove"]; }
    6567    } 
    6668   
    6769    [StorableConstructor]
    6870    protected PackingMoveEvaluator(bool deserializing) : base(deserializing) { }
    69     protected PackingMoveEvaluator(PackingMoveEvaluator<D, B, I> original, Cloner cloner) : base(original, cloner) { }
     71    protected PackingMoveEvaluator(PackingMoveEvaluator<D, B, I, M> original, Cloner cloner) : base(original, cloner) { }
    7072    protected PackingMoveEvaluator()
    7173      : base() {
     
    7779      Parameters.Add(new ValueLookupParameter<IEvaluator>("PackingPlanEvaluator", "The actual packing plan evaluation operator."));
    7880      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the decoded solution should be added to."));
    79       Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate."));
     81      Parameters.Add(new LookupParameter<IPackingMove<M>>("PackingMove", "The move to evaluate."));
    8082    }
    8183
     
    8385
    8486    public override IOperation Apply() {
    85       IPackingMove move = PackingMoveParameter.ActualValue;
    86       IPackingSolutionEncoding newSolution = move.GetSolutionAfterMove();
     87      IPackingMove<M> move = PackingMoveParameter.ActualValue;
     88      var newSolution = move.GetSolutionAfterMove();
    8789      CurrentScopeParameter.ActualValue.Variables.Add(new Variable("MovedSolution", newSolution));
    8890
     
    9395      CurrentScopeParameter.ActualValue.Variables.Add(new Variable("PackingPlanAfterMove", packingPlan));
    9496
    95       DoubleValue quality = PackingRatioEvaluator<D, B, I>.CalculatePackingRatio(packingPlan);
     97      var quality = PackingRatioEvaluator<D, B, I>.CalculatePackingRatio(packingPlan);
    9698
    97       double moveQuality = quality.Value;
     99      double moveQuality = quality;
    98100
    99101      if (MoveQualityParameter.ActualValue == null) MoveQualityParameter.ActualValue = new DoubleValue(moveQuality);
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingSequenceProblem.cs

    r14064 r14128  
    2323
    2424using System;
     25using System.CodeDom;
    2526using System.Linq;
     27using System.Text;
    2628using HeuristicLab.Common;
    2729using HeuristicLab.Core;
    2830using HeuristicLab.Data;
    29 using HeuristicLab.Encodings.PackingEncoding.PackingSequence;
     31using HeuristicLab.Encodings.PermutationEncoding;
    3032using HeuristicLab.Optimization;
    3133using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     34using HeuristicLab.Problems.BinPacking;
    3235
    33 namespace HeuristicLab.Problems.BinPacking2d {
     36namespace HeuristicLab.Problems.BinPacking {
    3437  [StorableClass]
    35   abstract class PackingSequenceProblem : SingleObjectiveBasicProblem<Encoding> {
     38  public abstract class PackingSequenceProblem<TSolution, TEncoding> : SingleObjectiveBasicProblem<TEncoding>
     39    where TSolution : class, IItem
     40    where TEncoding : class, IEncoding {
    3641
    3742    // persistence
     
    4348
    4449    // cloning
    45     protected PackingSequenceProblem(PackingSequenceProblem original, Cloner cloner)
     50    protected PackingSequenceProblem(PackingSequenceProblem<TSolution, TEncoding> original, Cloner cloner)
    4651      : base(original, cloner) {
    4752    }
     
    5358    }
    5459
    55     public sealed override double Evaluate(Individual individual, IRandom random) {
    56       return Evaluate(individual.PackingSequence(), random);
    57     }
    58     public abstract double Evaluate(PackingSequence sequence, IRandom random);
    59 
    60     public virtual void Analyze(PackingSequence[] trees, double[] qualities, ResultCollection results,
     60    public virtual void Analyze(TSolution[] solutions, double[] qualities, ResultCollection results,
    6161      IRandom random) {
    6262      if (!results.ContainsKey("Best Solution Quality")) {
     
    6464      }
    6565      if (!results.ContainsKey("Best Solution")) {
    66         results.Add(new Result("Best Solution", typeof(PackingSequence)));
     66        results.Add(new Result("Best Solution", typeof(TSolution)));
    6767      }
    6868
     
    7272          IsBetter(bestQuality, ((DoubleValue)results["Best Solution Quality"].Value).Value)) {
    7373        var bestIdx = Array.IndexOf(qualities, bestQuality);
    74         var bestClone = (IItem)trees[bestIdx].Clone();
     74        var bestClone = (IItem)solutions[bestIdx].Clone();
    7575        results["Best Solution"].Value = bestClone;
    7676        results["Best Solution Quality"].Value = new DoubleValue(bestQuality);
    7777      }
    7878    }
    79 
    80     public sealed override void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random) {
    81       Analyze(individuals.Select(ind => ind.PackingSequence()).ToArray(), qualities, results, random);
    82     }
    8379  }
    8480}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem.cs

    r14054 r14128  
    2626using HeuristicLab.Parameters;
    2727using HeuristicLab.Data;
    28 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector;
    2928using HeuristicLab.PluginInfrastructure;
    3029using System.Linq;
    3130using System;
    32 using HeuristicLab.Encodings.PackingEncoding.PackingSequence;
    33 using HeuristicLab.Encodings.PackingEncoding.GroupingVector;
    3431using HeuristicLab.Encodings.PackingEncoding;
    3532
     
    9794    }
    9895
    99     protected Problem(IDecodingEvaluator e) : this(e, new MultiComponentVectorRandomCreator()) { }
    100 
    101     protected Problem(IDecodingEvaluator e, IPackingSolutionCreator c) : base(e, c) {
     96    protected Problem(IDecodingEvaluator e) : this(e, new PackingSequenceRandomCreator()) { }
     97
     98    protected Problem(IDecodingEvaluator e, IPackingSolutionCreator c)
     99      : base(e, c) {
    102100      Parameters.Add(new OptionalValueParameter<PackingPlan<D, B, I>>("BestKnownSolution", "The best known solution of this bin-packing instance."));
    103101      Parameters.Add(new ValueParameter<ItemList<I>>("PackingItemMeasures", "Packing-item data defining the measures of the different items that need to be packed.", new ItemList<I>()));
     
    109107      Parameters.Add(new ConstrainedValueParameter<IPackingSolutionDecoder>("PackingSolutionDecoder", "The operator that decodes the representation and creates a packing plan."));
    110108      this.Maximization.Value = true;
    111       InitializeProblemInstance();
     109      InitializeProblemInstance(); // TODO
    112110      InitializeOperators();
    113111      InitializeEventHandlers();
     
    163161        Operators.AddRange(ApplicationManager.Manager.GetInstances<IPackingSequenceOperator>());
    164162        InitializeDecoder();
    165       } else if (SolutionCreator.GetType() == typeof(GroupingVectorRandomCreator)) {
     163      } /* else if (SolutionCreator.GetType() == typeof(GroupingVectorRandomCreator)) {
    166164        Operators.AddRange(ApplicationManager.Manager.GetInstances<IGroupingVectorOperator>());
    167165        InitializeDecoder();
     
    169167        Operators.AddRange(ApplicationManager.Manager.GetInstances<IMultiComponentVectorOperator>());
    170168        InitializeDecoder();
    171       }
     169      } */
    172170    }
    173171    private void ParameterizeOperators() {
     
    193191        PackingPlanEvaluator.PackingPlanParameter.Hidden = false;
    194192      }
     193      /*
    195194
    196195      foreach (var op in Operators.OfType<IPackingSolutionManipulator>()) {
     
    205204        op.ParentsParameter.Hidden = true;
    206205      }
    207 
     206      */
    208207      foreach (var op in Operators.OfType<BestBinPackingSolutionAnalyzer<D, B, I>>()) {
    209208        op.QualityParameter.ActualName = PackingPlanEvaluator.QualityParameter.ActualName;
Note: See TracChangeset for help on using the changeset viewer.