Changeset 14149 for branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/PermutationEncoding/TranslocationMoveEvaluator.cs
- Timestamp:
- 07/21/16 12:06:43 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/PermutationEncoding/TranslocationMoveEvaluator.cs
r14148 r14149 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data;25 24 using HeuristicLab.Encodings.PermutationEncoding; 26 using HeuristicLab.Operators;27 using HeuristicLab.Optimization;28 using HeuristicLab.Parameters;29 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 26 … … 32 28 [Item("TranslocationMoveEvaluator", "Move evaluator for insertion or translocation moves.")] 33 29 [StorableClass] 34 public sealed class TranslocationMoveEvaluator : SingleSuccessorOperator, 35 ISingleObjectiveMoveEvaluator, ISingleObjectiveMoveOperator, IPermutationTranslocationMoveOperator { 36 public override bool CanChangeName { 37 get { return false; } 30 public sealed class TranslocationMoveEvaluator : MoveEvaluatorBase<Permutation, TranslocationMove>, IPermutationTranslocationMoveOperator { 31 public ILookupParameter<TranslocationMove> TranslocationMoveParameter { 32 get { return MoveParameter; } 38 33 } 39 34 public ILookupParameter<Permutation> PermutationParameter { 40 get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; }35 get { return EncodedSolutionParameter; } 41 36 } 42 public ILookupParameter<DoubleValue> QualityParameter {43 get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }44 }45 public ILookupParameter<DoubleValue> MoveQualityParameter {46 get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; }47 }48 public ILookupParameter<ReadOnlyItemList<PackingItem>> PackingItemMeasuresParameter {49 get { return (LookupParameter<ReadOnlyItemList<PackingItem>>)Parameters["Items"]; }50 }51 public ILookupParameter<PackingShape> PackingBinMeasuresParameter {52 get { return (LookupParameter<PackingShape>)Parameters["BinShape"]; }53 }54 public ILookupParameter<IPermutationDecoder> PackingSolutionDecoderParameter {55 get { return (ILookupParameter<IPermutationDecoder>)Parameters["Decoder"]; }56 }57 public ILookupParameter<IEvaluator> PackingPlanEvaluatorParameter {58 get { return (ILookupParameter<IEvaluator>)Parameters["SolutionEvaluator"]; }59 }60 61 public ILookupParameter<TranslocationMove> TranslocationMoveParameter {62 get { return (ILookupParameter<TranslocationMove>)Parameters["TranslocationMove"]; }63 }64 65 37 [StorableConstructor] 66 38 private TranslocationMoveEvaluator(bool deserializing) : base(deserializing) { } … … 68 40 public TranslocationMoveEvaluator() 69 41 : base() { 70 Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The encoded solution candidate to evaluate"));71 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of a packing solution."));72 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The evaluated quality of a move on a packing solution."));73 Parameters.Add(new LookupParameter<ReadOnlyItemList<PackingItem>>("Items", "Packing-item data taken from the bin-packing problem-instance."));74 Parameters.Add(new LookupParameter<PackingShape>("BinShape", "Packing-bin data taken from the bin-packing problem-instance."));75 Parameters.Add(new LookupParameter<IPermutationDecoder>("Decoder", "The decoding operator that is used to calculate a packing plan from the used representation."));76 Parameters.Add(new LookupParameter<IEvaluator>("SolutionEvaluator", "The actual packing plan evaluation operator."));77 Parameters.Add(new LookupParameter<TranslocationMove>("TranslocationMove", "The move to evaluate."));78 42 } 79 43 … … 82 46 } 83 47 84 85 public override IOperation Apply() { 86 var move = TranslocationMoveParameter.ActualValue; 87 var permutation = PermutationParameter.ActualValue; 88 var binShape = PackingBinMeasuresParameter.ActualValue; 89 var items = PackingItemMeasuresParameter.ActualValue; 48 public override double EvaluateMove(Permutation permutation, TranslocationMove move, PackingShape binShape, 49 ReadOnlyItemList<PackingItem> items) { 90 50 91 51 // uses full evaluation 92 93 52 TranslocationManipulator.Apply(permutation, move.Index1, move.Index2, move.Index3); 94 53 var solution = PackingSolutionDecoderParameter.ActualValue.Decode(permutation, binShape, items); 95 54 96 var quality = PackingPlanEvaluatorParameter.ActualValue.Evaluate(solution); 97 98 double moveQuality = quality; 99 100 if (MoveQualityParameter.ActualValue == null) 101 MoveQualityParameter.ActualValue = new DoubleValue(moveQuality); 102 else 103 MoveQualityParameter.ActualValue.Value = moveQuality; 104 return base.Apply(); 55 return PackingPlanEvaluatorParameter.ActualValue.Evaluate(solution); 105 56 } 106 57 }
Note: See TracChangeset
for help on using the changeset viewer.