Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/15/13 22:23:36 (12 years ago)
Author:
jhelm
Message:

#1966: Did some major refactoring in Decoder-classes; Added MoveEvaluator classes for different encodings and dimensions; Added new crossover-class for MCV encoding;

Location:
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/Moves/SingleGrouping
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/Moves/SingleGrouping/SingleGroupingMove.cs

    r9440 r9495  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
     24using HeuristicLab.Encodings.IntegerVectorEncoding;
    2425using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26using HeuristicLab.Problems.BinPacking.Interfaces;
    2527
    2628namespace HeuristicLab.Encodings.PackingEncoding.GroupingVector {
    2729  [Item("Single Grouping Move", "A move on a grouping vector that is specified by a single group-assignment-index.")]
    2830  [StorableClass]
    29   public class SingleGroupingMove : Item {
     31  public class SingleGroupingMove : Item, IPackingMove{
    3032    [Storable]
    3133    public int Index { get; protected set; }
     
    5355      return new SingleGroupingMove(this, cloner);
    5456    }
     57
     58    public IPackingSolutionEncoding GetSolutionAfterMove() {
     59      GroupingVectorEncoding newSolution = new GroupingVectorEncoding();
     60      newSolution.GroupingVector = new IntegerVector(GroupingVector.GroupingVector);
     61      newSolution.GroupingVector[Index] = NewGroup;
     62      return newSolution;
     63    }
    5564  }
    5665}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/Moves/SingleGrouping/SingleGroupingMoveGenerator.cs

    r9440 r9495  
    3838      get { return (ILookupParameter<GroupingVectorEncoding>)Parameters["GroupingVector"]; }
    3939    }
    40     public ILookupParameter<SingleGroupingMove> SingleGroupingMoveParameter {
    41       get { return (LookupParameter<SingleGroupingMove>)Parameters["SingleGroupingMove"]; }
     40    public ILookupParameter<IPackingMove> PackingMoveParameter {
     41      get { return (LookupParameter<IPackingMove>)Parameters["PackingMove"]; }
    4242    }
    4343    protected ScopeParameter CurrentScopeParameter {
     
    5151      : base() {
    5252      Parameters.Add(new LookupParameter<GroupingVectorEncoding>("GroupingVector", "The grouping vector for which moves should be generated."));
    53       Parameters.Add(new LookupParameter<SingleGroupingMove>("SingleGroupingMove", "The moves that should be generated in subscopes."));
     53      Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The moves that should be generated in subscopes."));
    5454      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the moves should be added as subscopes."));
    5555    }
     
    6161      for (int i = 0; i < moveScopes.Length; i++) {
    6262        moveScopes[i] = new Scope(i.ToString());
    63         moveScopes[i].Variables.Add(new Variable(SingleGroupingMoveParameter.ActualName, moves[i]));
     63        moveScopes[i].Variables.Add(new Variable(PackingMoveParameter.ActualName, moves[i]));
    6464      }
    6565      CurrentScopeParameter.ActualValue.SubScopes.AddRange(moveScopes);
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/Moves/SingleGrouping/SingleGroupingMoveHardTabuCriterion.cs

    r9440 r9495  
    3838      get { return false; }
    3939    }
    40     public ILookupParameter<SingleGroupingMove> SingleGroupingMoveParameter {
    41       get { return (ILookupParameter<SingleGroupingMove>)Parameters["SingleGroupingMove"]; }
     40    public ILookupParameter<IPackingMove> PackingMoveParameter {
     41      get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; }
    4242    }
    4343    public ILookupParameter<GroupingVectorEncoding> GroupingVectorParameter {
     
    6565    public SingleGroupingMoveHardTabuCriterion()
    6666      : base() {
    67       Parameters.Add(new LookupParameter<SingleGroupingMove>("SingleGroupingMove", "The move to evaluate."));
     67      Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate."));
    6868      Parameters.Add(new LookupParameter<GroupingVectorEncoding>("GroupingVector", "The solution to evaluate."));
    6969      Parameters.Add(new LookupParameter<BoolValue>("MoveTabu", "The variable to store if a move was tabu."));
     
    8080    public override IOperation Apply() {
    8181      ItemList<IItem> tabuList = TabuListParameter.ActualValue;
    82       SingleGroupingMove move = SingleGroupingMoveParameter.ActualValue;
     82      SingleGroupingMove move = PackingMoveParameter.ActualValue as SingleGroupingMove;
    8383      GroupingVectorEncoding groupingVector = GroupingVectorParameter.ActualValue;
    8484      int length = groupingVector.GroupingVector.Length;
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/Moves/SingleGrouping/SingleGroupingMoveMaker.cs

    r9440 r9495  
    4242      get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; }
    4343    }
    44     public ILookupParameter<SingleGroupingMove> SingleGroupingMoveParameter {
    45       get { return (ILookupParameter<SingleGroupingMove>)Parameters["SingleGroupingMove"]; }
     44    public ILookupParameter<IPackingMove> PackingMoveParameter {
     45      get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; }
    4646    }
    4747    public ILookupParameter<GroupingVectorEncoding> GroupingVectorParameter {
    4848      get { return (ILookupParameter<GroupingVectorEncoding>)Parameters["GroupingVector"]; }
     49    }
     50    public ILookupParameter<IPackingPlan> PackingPlanParameter {
     51      get { return (ILookupParameter<IPackingPlan>)Parameters["PackingPlan"]; }
     52    }
     53    public ILookupParameter<IPackingPlan> PackingPlanAfterMoveParameter {
     54      get { return (ILookupParameter<IPackingPlan>)Parameters["PackingPlanAfterMove"]; }
    4955    }
    5056
     
    5561      : base() {
    5662      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the solution."));
    57       Parameters.Add(new LookupParameter<SingleGroupingMove>("SingleGroupingMove", "The move to evaluate."));
     63      Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate."));
    5864      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move."));
    5965      Parameters.Add(new LookupParameter<GroupingVectorEncoding>("GroupingVector", "The solution as grouping vector."));
     66      Parameters.Add(new LookupParameter<IPackingPlan>("PackingPlan", "The currently best performing, decoded bin-packing solution represented as generalized packing-plan."));
     67      Parameters.Add(new LookupParameter<IPackingPlan>("PackingPlanAfterMove", "The moved and decoded bin-packing solution represented as generalized packing-plan."));
    6068    }
    6169
     
    6573
    6674    public override IOperation Apply() {
    67       SingleGroupingMove move = SingleGroupingMoveParameter.ActualValue;
     75      IPackingMove move = PackingMoveParameter.ActualValue;
    6876      GroupingVectorEncoding groupingVector = GroupingVectorParameter.ActualValue;
    6977      DoubleValue moveQuality = MoveQualityParameter.ActualValue;
    7078      DoubleValue quality = QualityParameter.ActualValue;
    7179
    72       groupingVector.GroupingVector[move.Index] = move.NewGroup;
     80      groupingVector.GroupingVector = (move.GetSolutionAfterMove() as GroupingVectorEncoding).GroupingVector;
     81      PackingPlanParameter.ActualValue = PackingPlanAfterMoveParameter.ActualValue;
    7382
    7483      quality.Value = moveQuality.Value;
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/Moves/SingleGrouping/SingleGroupingMoveSoftTabuCriterion.cs

    r9440 r9495  
    3838      get { return false; }
    3939    }
    40     public ILookupParameter<SingleGroupingMove> SingleGroupingMoveParameter {
    41       get { return (ILookupParameter<SingleGroupingMove>)Parameters["SingleGroupingMove"]; }
     40    public ILookupParameter<IPackingMove> PackingMoveParameter {
     41      get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; }
    4242    }
    4343    public ILookupParameter<GroupingVectorEncoding> GroupingVectorParameter {
     
    6565    public SingleGroupingMoveSoftTabuCriterion()
    6666      : base() {
    67       Parameters.Add(new LookupParameter<SingleGroupingMove>("SingleGroupingMove", "The move to evaluate."));
     67      Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate."));
    6868      Parameters.Add(new LookupParameter<GroupingVectorEncoding>("GroupingVector", "The solution to evaluate."));
    6969      Parameters.Add(new LookupParameter<BoolValue>("MoveTabu", "The variable to store if a move was tabu."));
     
    8080    public override IOperation Apply() {
    8181      ItemList<IItem> tabuList = TabuListParameter.ActualValue;
    82       SingleGroupingMove move = SingleGroupingMoveParameter.ActualValue;
     82      SingleGroupingMove move = PackingMoveParameter.ActualValue as SingleGroupingMove;
    8383      GroupingVectorEncoding groupingVector = GroupingVectorParameter.ActualValue;
    8484      int length = groupingVector.GroupingVector.Length;
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/Moves/SingleGrouping/SingleGroupingTabuMaker.cs

    r9440 r9495  
    3232  [StorableClass]
    3333  public class SingleGroupingTabuMaker : TabuMaker, IGroupingVectorMoveOperator{
    34     public ILookupParameter<SingleGroupingMove> SingleGroupingMoveParameter {
    35       get { return (ILookupParameter<SingleGroupingMove>)Parameters["SingleGroupingMove"]; }
     34    public ILookupParameter<IPackingMove> PackingMoveParameter {
     35      get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; }
    3636    }
    3737    public ILookupParameter<GroupingVectorEncoding> GroupingVectorParameter {
     
    4444    public SingleGroupingTabuMaker()
    4545      : base() {
    46       Parameters.Add(new LookupParameter<SingleGroupingMove>("SingleGroupingMove", "The move to evaluate."));
     46        Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate."));
    4747      Parameters.Add(new LookupParameter<GroupingVectorEncoding>("GroupingVector", "The solution to evaluate."));
    4848    }
     
    5353
    5454    protected override IItem GetTabuAttribute(bool maximization, double quality, double moveQuality) {
    55       SingleGroupingMove move = SingleGroupingMoveParameter.ActualValue;
     55      IPackingMove move = PackingMoveParameter.ActualValue;
    5656      GroupingVectorEncoding groupingVector = GroupingVectorParameter.ActualValue;   
    5757      double baseQuality = moveQuality;
    5858      if (maximization && quality > moveQuality || !maximization && quality < moveQuality)
    5959        baseQuality = quality; // we make an uphill move, the lower bound is the solution quality
    60            
    61       return new SingleGroupingMoveAttribute (move.Index, move.NewGroup, baseQuality);
     60
     61      var sgMove = move as SingleGroupingMove;
     62      if (sgMove != null)
     63        return new SingleGroupingMoveAttribute(sgMove.Index, sgMove.NewGroup, baseQuality);
     64      else
     65        return move.GetSolutionAfterMove();
    6266    }
    6367  }
Note: See TracChangeset for help on using the changeset viewer.