Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/VRPMoveMaker.cs @ 17712

Last change on this file since 17712 was 17712, checked in by abeham, 4 years ago

#2521: working on VRP

File size: 3.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 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 HEAL.Attic;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Optimization;
27using HeuristicLab.Parameters;
28using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
29
30namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
31  [Item("VRPMoveMaker", "Performs a VRP move.")]
32  [StorableType("00082602-A676-48A7-A2D7-66733B972685")]
33  public abstract class VRPMoveMaker : VRPMoveOperator, IMoveMaker, ISingleObjectiveOperator {
34    public ILookupParameter<DoubleValue> QualityParameter {
35      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
36    }
37    public ILookupParameter<VRPEvaluation> EvaluationResultParameter {
38      get { return (ILookupParameter<VRPEvaluation>)Parameters["EvaluationResult"]; }
39    }
40    public ILookupParameter<DoubleValue> MoveQualityParameter {
41      get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; }
42    }
43    public ILookupParameter<DoubleValue> MovePenaltyParameter {
44      get { return (ILookupParameter<DoubleValue>)Parameters["MovePenalty"]; }
45    }
46    public ILookupParameter<VRPEvaluation> MoveEvaluationResultParameter {
47      get { return (ILookupParameter<VRPEvaluation>)Parameters["MoveEvaluationResult"]; }
48    }
49
50    [StorableConstructor]
51    protected VRPMoveMaker(StorableConstructorFlag _) : base(_) { }
52
53    public VRPMoveMaker()
54      : base() {
55      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the solution."));
56      Parameters.Add(new LookupParameter<VRPEvaluation>("EvaluationResult", "The evaluation of the solution."));
57      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move."));
58      Parameters.Add(new LookupParameter<DoubleValue>("MovePenalty", "The penalty applied to the move."));
59      Parameters.Add(new LookupParameter<VRPEvaluation>("MoveEvaluationResult", "The move evaluation."));
60    }
61
62    protected VRPMoveMaker(VRPMoveMaker original, Cloner cloner)
63      : base(original, cloner) {
64    }
65
66    protected abstract void PerformMove();
67
68    private void UpdateMoveEvaluation() {
69      EvaluationResultParameter.ActualValue = MoveEvaluationResultParameter.ActualValue;
70      QualityParameter.ActualValue = MoveQualityParameter.ActualValue;
71    }
72
73    public override IOperation InstrumentedApply() {
74      PerformMove();
75      UpdateMoveEvaluation();
76
77      return base.InstrumentedApply();
78    }
79  }
80}
Note: See TracBrowser for help on using the repository browser.