Free cookie consent management tool by TermsFeed Policy Generator

source: branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDExchange/PotvinPDExchangeMoveEvaluator.cs @ 6773

Last change on this file since 6773 was 6773, checked in by svonolfe, 13 years ago

Added moves for pickup and delivery problems (#1177)

File size: 3.5 KB
Line 
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
22using HeuristicLab.Core;
23using HeuristicLab.Encodings.PermutationEncoding;
24using HeuristicLab.Parameters;
25using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
26using HeuristicLab.Data;
27using HeuristicLab.Common;
28using HeuristicLab.Optimization;
29
30namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
31  [Item("PotvinPDExchangeMoveEvaluator", "Evaluates a exchange move for a PDP representation. ")]
32  [StorableClass]
33  public sealed class PotvinPDExchangeMoveEvaluator : PotvinMoveEvaluator, IPotvinPDExchangeMoveOperator {
34    public ILookupParameter<PotvinPDExchangeMove> PDExchangeMoveParameter {
35      get { return (ILookupParameter<PotvinPDExchangeMove>)Parameters["PotvinPDExchangeMove"]; }
36    }
37
38    public override ILookupParameter VRPMoveParameter {
39      get { return PDExchangeMoveParameter; }
40    }
41
42    public ILookupParameter<VariableCollection> MemoriesParameter {
43      get { return (ILookupParameter<VariableCollection>)Parameters["Memories"]; }
44    }
45
46    public IValueParameter<StringValue> AdditionFrequencyMemoryKeyParameter {
47      get { return (IValueParameter<StringValue>)Parameters["AdditionFrequencyMemoryKey"]; }
48    }
49
50    public IValueParameter<DoubleValue> LambdaParameter {
51      get { return (IValueParameter<DoubleValue>)Parameters["Lambda"]; }
52    }
53
54    [StorableConstructor]
55    private PotvinPDExchangeMoveEvaluator(bool deserializing) : base(deserializing) { }
56
57    public PotvinPDExchangeMoveEvaluator()
58      : base() {
59        Parameters.Add(new LookupParameter<PotvinPDExchangeMove>("PotvinPDExchangeMove", "The move that should be evaluated."));
60
61       Parameters.Add(new LookupParameter<VariableCollection>("Memories", "The TS memory collection."));
62       Parameters.Add(new ValueParameter<StringValue>("AdditionFrequencyMemoryKey", "The key that is used for the addition frequency in the TS memory.", new StringValue("AdditionFrequency")));
63       Parameters.Add(new ValueParameter<DoubleValue>("Lambda", "The lambda parameter.", new DoubleValue(0.015)));
64    }
65
66    public override IDeepCloneable Clone(Cloner cloner) {
67      return new PotvinPDExchangeMoveEvaluator(this, cloner);
68    }
69
70    private PotvinPDExchangeMoveEvaluator(PotvinPDExchangeMoveEvaluator original, Cloner cloner)
71      : base(original, cloner) {
72    }
73
74    protected override void EvaluateMove() {
75      PotvinPDExchangeMove move = PDExchangeMoveParameter.ActualValue;
76
77      PotvinEncoding newSolution = PDExchangeMoveParameter.ActualValue.Individual.Clone() as PotvinEncoding;
78      PotvinPDExchangeMoveMaker.Apply(newSolution, move, ProblemInstance);
79
80      UpdateEvaluation(newSolution);
81    }
82  }
83}
Note: See TracBrowser for help on using the repository browser.