Changeset 9495 for branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/Moves
- Timestamp:
- 05/15/13 22:23:36 (12 years ago)
- 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 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Encodings.IntegerVectorEncoding; 24 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Problems.BinPacking.Interfaces; 25 27 26 28 namespace HeuristicLab.Encodings.PackingEncoding.GroupingVector { 27 29 [Item("Single Grouping Move", "A move on a grouping vector that is specified by a single group-assignment-index.")] 28 30 [StorableClass] 29 public class SingleGroupingMove : Item 31 public class SingleGroupingMove : Item, IPackingMove{ 30 32 [Storable] 31 33 public int Index { get; protected set; } … … 53 55 return new SingleGroupingMove(this, cloner); 54 56 } 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 } 55 64 } 56 65 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/Moves/SingleGrouping/SingleGroupingMoveGenerator.cs
r9440 r9495 38 38 get { return (ILookupParameter<GroupingVectorEncoding>)Parameters["GroupingVector"]; } 39 39 } 40 public ILookupParameter< SingleGroupingMove> SingleGroupingMoveParameter {41 get { return (LookupParameter< SingleGroupingMove>)Parameters["SingleGroupingMove"]; }40 public ILookupParameter<IPackingMove> PackingMoveParameter { 41 get { return (LookupParameter<IPackingMove>)Parameters["PackingMove"]; } 42 42 } 43 43 protected ScopeParameter CurrentScopeParameter { … … 51 51 : base() { 52 52 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.")); 54 54 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the moves should be added as subscopes.")); 55 55 } … … 61 61 for (int i = 0; i < moveScopes.Length; i++) { 62 62 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])); 64 64 } 65 65 CurrentScopeParameter.ActualValue.SubScopes.AddRange(moveScopes); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/Moves/SingleGrouping/SingleGroupingMoveHardTabuCriterion.cs
r9440 r9495 38 38 get { return false; } 39 39 } 40 public ILookupParameter< SingleGroupingMove> SingleGroupingMoveParameter {41 get { return (ILookupParameter< SingleGroupingMove>)Parameters["SingleGroupingMove"]; }40 public ILookupParameter<IPackingMove> PackingMoveParameter { 41 get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; } 42 42 } 43 43 public ILookupParameter<GroupingVectorEncoding> GroupingVectorParameter { … … 65 65 public SingleGroupingMoveHardTabuCriterion() 66 66 : base() { 67 Parameters.Add(new LookupParameter< SingleGroupingMove>("SingleGroupingMove", "The move to evaluate."));67 Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate.")); 68 68 Parameters.Add(new LookupParameter<GroupingVectorEncoding>("GroupingVector", "The solution to evaluate.")); 69 69 Parameters.Add(new LookupParameter<BoolValue>("MoveTabu", "The variable to store if a move was tabu.")); … … 80 80 public override IOperation Apply() { 81 81 ItemList<IItem> tabuList = TabuListParameter.ActualValue; 82 SingleGroupingMove move = SingleGroupingMoveParameter.ActualValue;82 SingleGroupingMove move = PackingMoveParameter.ActualValue as SingleGroupingMove; 83 83 GroupingVectorEncoding groupingVector = GroupingVectorParameter.ActualValue; 84 84 int length = groupingVector.GroupingVector.Length; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/Moves/SingleGrouping/SingleGroupingMoveMaker.cs
r9440 r9495 42 42 get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; } 43 43 } 44 public ILookupParameter< SingleGroupingMove> SingleGroupingMoveParameter {45 get { return (ILookupParameter< SingleGroupingMove>)Parameters["SingleGroupingMove"]; }44 public ILookupParameter<IPackingMove> PackingMoveParameter { 45 get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; } 46 46 } 47 47 public ILookupParameter<GroupingVectorEncoding> GroupingVectorParameter { 48 48 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"]; } 49 55 } 50 56 … … 55 61 : base() { 56 62 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.")); 58 64 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move.")); 59 65 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.")); 60 68 } 61 69 … … 65 73 66 74 public override IOperation Apply() { 67 SingleGroupingMove move = SingleGroupingMoveParameter.ActualValue;75 IPackingMove move = PackingMoveParameter.ActualValue; 68 76 GroupingVectorEncoding groupingVector = GroupingVectorParameter.ActualValue; 69 77 DoubleValue moveQuality = MoveQualityParameter.ActualValue; 70 78 DoubleValue quality = QualityParameter.ActualValue; 71 79 72 groupingVector.GroupingVector[move.Index] = move.NewGroup; 80 groupingVector.GroupingVector = (move.GetSolutionAfterMove() as GroupingVectorEncoding).GroupingVector; 81 PackingPlanParameter.ActualValue = PackingPlanAfterMoveParameter.ActualValue; 73 82 74 83 quality.Value = moveQuality.Value; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/Moves/SingleGrouping/SingleGroupingMoveSoftTabuCriterion.cs
r9440 r9495 38 38 get { return false; } 39 39 } 40 public ILookupParameter< SingleGroupingMove> SingleGroupingMoveParameter {41 get { return (ILookupParameter< SingleGroupingMove>)Parameters["SingleGroupingMove"]; }40 public ILookupParameter<IPackingMove> PackingMoveParameter { 41 get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; } 42 42 } 43 43 public ILookupParameter<GroupingVectorEncoding> GroupingVectorParameter { … … 65 65 public SingleGroupingMoveSoftTabuCriterion() 66 66 : base() { 67 Parameters.Add(new LookupParameter< SingleGroupingMove>("SingleGroupingMove", "The move to evaluate."));67 Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate.")); 68 68 Parameters.Add(new LookupParameter<GroupingVectorEncoding>("GroupingVector", "The solution to evaluate.")); 69 69 Parameters.Add(new LookupParameter<BoolValue>("MoveTabu", "The variable to store if a move was tabu.")); … … 80 80 public override IOperation Apply() { 81 81 ItemList<IItem> tabuList = TabuListParameter.ActualValue; 82 SingleGroupingMove move = SingleGroupingMoveParameter.ActualValue;82 SingleGroupingMove move = PackingMoveParameter.ActualValue as SingleGroupingMove; 83 83 GroupingVectorEncoding groupingVector = GroupingVectorParameter.ActualValue; 84 84 int length = groupingVector.GroupingVector.Length; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/Moves/SingleGrouping/SingleGroupingTabuMaker.cs
r9440 r9495 32 32 [StorableClass] 33 33 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"]; } 36 36 } 37 37 public ILookupParameter<GroupingVectorEncoding> GroupingVectorParameter { … … 44 44 public SingleGroupingTabuMaker() 45 45 : base() { 46 Parameters.Add(new LookupParameter<SingleGroupingMove>("SingleGroupingMove", "The move to evaluate."));46 Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate.")); 47 47 Parameters.Add(new LookupParameter<GroupingVectorEncoding>("GroupingVector", "The solution to evaluate.")); 48 48 } … … 53 53 54 54 protected override IItem GetTabuAttribute(bool maximization, double quality, double moveQuality) { 55 SingleGroupingMove move = SingleGroupingMoveParameter.ActualValue;55 IPackingMove move = PackingMoveParameter.ActualValue; 56 56 GroupingVectorEncoding groupingVector = GroupingVectorParameter.ActualValue; 57 57 double baseQuality = moveQuality; 58 58 if (maximization && quality > moveQuality || !maximization && quality < moveQuality) 59 59 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(); 62 66 } 63 67 }
Note: See TracChangeset
for help on using the changeset viewer.