1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
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 |
|
---|
22 | using HeuristicLab.Core;
|
---|
23 | using HeuristicLab.Encodings.PermutationEncoding;
|
---|
24 | using HeuristicLab.Parameters;
|
---|
25 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
26 | using HeuristicLab.Data;
|
---|
27 | using HeuristicLab.Common;
|
---|
28 | using HeuristicLab.Optimization;
|
---|
29 | using HeuristicLab.Problems.VehicleRouting.Encodings.Potvin;
|
---|
30 |
|
---|
31 | namespace HeuristicLab.PDPSimulation.Operators {
|
---|
32 | [Item("DynPotvinPDRearrangeMoveEvaluator", "Evaluates a rearrange move for a PDP representation. ")]
|
---|
33 | [StorableClass]
|
---|
34 | public sealed class DynPotvinPDRearrangeMoveEvaluator : PotvinMoveEvaluator, IDynPotvinPDRearrangeMoveOperator {
|
---|
35 | public ILookupParameter<DynPotvinPDRearrangeMove> PDRearrangeMoveParameter {
|
---|
36 | get { return (ILookupParameter<DynPotvinPDRearrangeMove>)Parameters["DynPotvinPDRearrangeMove"]; }
|
---|
37 | }
|
---|
38 |
|
---|
39 | public override ILookupParameter VRPMoveParameter {
|
---|
40 | get { return PDRearrangeMoveParameter; }
|
---|
41 | }
|
---|
42 |
|
---|
43 | public ILookupParameter<VariableCollection> MemoriesParameter {
|
---|
44 | get { return (ILookupParameter<VariableCollection>)Parameters["Memories"]; }
|
---|
45 | }
|
---|
46 |
|
---|
47 | public IValueParameter<StringValue> AdditionFrequencyMemoryKeyParameter {
|
---|
48 | get { return (IValueParameter<StringValue>)Parameters["AdditionFrequencyMemoryKey"]; }
|
---|
49 | }
|
---|
50 |
|
---|
51 | public IValueParameter<DoubleValue> LambdaParameter {
|
---|
52 | get { return (IValueParameter<DoubleValue>)Parameters["Lambda"]; }
|
---|
53 | }
|
---|
54 |
|
---|
55 | [StorableConstructor]
|
---|
56 | private DynPotvinPDRearrangeMoveEvaluator(bool deserializing) : base(deserializing) { }
|
---|
57 |
|
---|
58 | public DynPotvinPDRearrangeMoveEvaluator()
|
---|
59 | : base() {
|
---|
60 | Parameters.Add(new LookupParameter<DynPotvinPDRearrangeMove>("DynPotvinPDRearrangeMove", "The move that should be evaluated."));
|
---|
61 |
|
---|
62 | Parameters.Add(new LookupParameter<VariableCollection>("Memories", "The TS memory collection."));
|
---|
63 | Parameters.Add(new ValueParameter<StringValue>("AdditionFrequencyMemoryKey", "The key that is used for the addition frequency in the TS memory.", new StringValue("AdditionFrequency")));
|
---|
64 | Parameters.Add(new ValueParameter<DoubleValue>("Lambda", "The lambda parameter.", new DoubleValue(0.015)));
|
---|
65 | }
|
---|
66 |
|
---|
67 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
68 | return new DynPotvinPDRearrangeMoveEvaluator(this, cloner);
|
---|
69 | }
|
---|
70 |
|
---|
71 | private DynPotvinPDRearrangeMoveEvaluator(DynPotvinPDRearrangeMoveEvaluator original, Cloner cloner)
|
---|
72 | : base(original, cloner) {
|
---|
73 | }
|
---|
74 |
|
---|
75 | protected override void EvaluateMove() {
|
---|
76 | DynPotvinPDRearrangeMove move = PDRearrangeMoveParameter.ActualValue;
|
---|
77 |
|
---|
78 | PotvinEncoding newSolution = PDRearrangeMoveParameter.ActualValue.Individual.Clone() as PotvinEncoding;
|
---|
79 | DynPotvinPDRearrangeMoveMaker.Apply(newSolution, move, ProblemInstance);
|
---|
80 |
|
---|
81 | UpdateEvaluation(newSolution);
|
---|
82 | }
|
---|
83 | }
|
---|
84 | }
|
---|