[9563] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[13032] | 3 | * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[9563] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
[13032] | 22 |
|
---|
[9563] | 23 | using HeuristicLab.Common;
|
---|
| 24 | using HeuristicLab.Core;
|
---|
| 25 | using HeuristicLab.Data;
|
---|
| 26 | using HeuristicLab.Operators;
|
---|
| 27 | using HeuristicLab.Optimization;
|
---|
| 28 | using HeuristicLab.Parameters;
|
---|
| 29 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 30 | using HeuristicLab.Problems.BinPacking.Interfaces;
|
---|
| 31 |
|
---|
| 32 | namespace HeuristicLab.Encodings.PackingEncoding.PackingSequence {
|
---|
| 33 | [Item("Sequence Move Maker", "Peforms a Sequence move on a given Sequence vector and updates the quality.")]
|
---|
| 34 | [StorableClass]
|
---|
| 35 | public class SequenceMoveMaker : SingleSuccessorOperator, IMoveMaker, IPackingSequenceMoveOperator {
|
---|
| 36 | public override bool CanChangeName {
|
---|
| 37 | get { return false; }
|
---|
| 38 | }
|
---|
| 39 | public ILookupParameter<DoubleValue> QualityParameter {
|
---|
| 40 | get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
|
---|
| 41 | }
|
---|
| 42 | public ILookupParameter<DoubleValue> MoveQualityParameter {
|
---|
| 43 | get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; }
|
---|
| 44 | }
|
---|
| 45 | public ILookupParameter<IPackingMove> PackingMoveParameter {
|
---|
| 46 | get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; }
|
---|
| 47 | }
|
---|
| 48 | public ILookupParameter<PackingSequenceEncoding> PackingSequenceParameter {
|
---|
| 49 | get { return (ILookupParameter<PackingSequenceEncoding>)Parameters["PackingSequence"]; }
|
---|
| 50 | }
|
---|
| 51 | public ILookupParameter<IPackingPlan> PackingPlanParameter {
|
---|
| 52 | get { return (ILookupParameter<IPackingPlan>)Parameters["PackingPlan"]; }
|
---|
| 53 | }
|
---|
| 54 | public ILookupParameter<IPackingPlan> PackingPlanAfterMoveParameter {
|
---|
| 55 | get { return (ILookupParameter<IPackingPlan>)Parameters["PackingPlanAfterMove"]; }
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | [StorableConstructor]
|
---|
| 59 | protected SequenceMoveMaker(bool deserializing) : base(deserializing) { }
|
---|
| 60 | protected SequenceMoveMaker(SequenceMoveMaker original, Cloner cloner) : base(original, cloner) { }
|
---|
| 61 | public SequenceMoveMaker()
|
---|
| 62 | : base() {
|
---|
| 63 | 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<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<IPackingPlan>("PackingPlan", "The currently best performing, decoded bin-packing solution represented as generalized packing-plan."));
|
---|
| 68 | Parameters.Add(new LookupParameter<IPackingPlan>("PackingPlanAfterMove", "The moved and decoded bin-packing solution represented as generalized packing-plan."));
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 72 | return new SequenceMoveMaker(this, cloner);
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | public override IOperation Apply() {
|
---|
| 76 | IPackingMove move = PackingMoveParameter.ActualValue;
|
---|
| 77 | PackingSequenceEncoding PackingSequence = PackingSequenceParameter.ActualValue;
|
---|
| 78 | DoubleValue moveQuality = MoveQualityParameter.ActualValue;
|
---|
| 79 | DoubleValue quality = QualityParameter.ActualValue;
|
---|
| 80 |
|
---|
| 81 | PackingSequence.PackingSequence = (move.GetSolutionAfterMove() as PackingSequenceEncoding).PackingSequence;
|
---|
| 82 | PackingPlanParameter.ActualValue = PackingPlanAfterMoveParameter.ActualValue;
|
---|
| 83 |
|
---|
| 84 | quality.Value = moveQuality.Value;
|
---|
| 85 |
|
---|
| 86 | return base.Apply();
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 | }
|
---|