Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2521_ProblemRefactoring/HeuristicLab.Problems.PTSP/3.3/ProbabilisticTSPSolution.cs @ 17260

Last change on this file since 17260 was 17260, checked in by abeham, 5 years ago

#2521: Worked on PTSP refactoring

File size: 3.2 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 System.Drawing;
23using HEAL.Attic;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Data;
27using HeuristicLab.Encodings.PermutationEncoding;
28using HeuristicLab.Problems.TravelingSalesman;
29
30namespace HeuristicLab.Problems.PTSP {
31  [StorableType("596f52b5-b2c8-45a0-a7bd-e5b9c787c960")]
32  public interface IProbabilisticTSPSolution : ITSPSolution {
33    DoubleArray Probabilities { get; }
34  }
35
36  /// <summary>
37  /// Represents a tour of a Traveling Salesman Problem given in path representation which can be visualized in the GUI.
38  /// </summary>
39  [Item("pTSP Solution", "Represents a tour of a Probabilistic Traveling Salesman Problem given in path representation which can be visualized in the GUI.")]
40  [StorableType("ea784622-41e5-493e-a1f3-4c38fed99216")]
41  public sealed class ProbabilisticTSPSolution : TSPSolution, IProbabilisticTSPSolution {
42    public static new Image StaticItemImage {
43      get { return HeuristicLab.Common.Resources.VSImageLibrary.Image; }
44    }
45
46    [Storable]
47    private DoubleArray probabilities;
48    public DoubleArray Probabilities {
49      get { return probabilities; }
50      set {
51        if (probabilities == value) return;
52        probabilities = value;
53        OnPropertyChanged(nameof(Probabilities));
54      }
55    }
56
57    [StorableConstructor]
58    private ProbabilisticTSPSolution(StorableConstructorFlag _) : base(_) { }
59    private ProbabilisticTSPSolution(ProbabilisticTSPSolution original, Cloner cloner)
60      : base(original, cloner) {
61      this.probabilities = cloner.Clone(original.probabilities);
62    }
63    public ProbabilisticTSPSolution() : base() { }
64    public ProbabilisticTSPSolution(DoubleMatrix coordinates, PercentArray probabilities)
65      : base(coordinates) {
66      this.probabilities = probabilities;
67    }
68    public ProbabilisticTSPSolution(DoubleMatrix coordinates, PercentArray probabilities, Permutation permutation)
69      : base(coordinates, permutation) {
70      this.probabilities = probabilities;
71    }
72    public ProbabilisticTSPSolution(DoubleMatrix coordinates, PercentArray probabilities, Permutation permutation, DoubleValue quality)
73      : base(coordinates, permutation, quality) {
74      this.probabilities = probabilities;
75    }
76
77    public override IDeepCloneable Clone(Cloner cloner) {
78      return new ProbabilisticTSPSolution(this, cloner);
79    }
80  }
81}
Note: See TracBrowser for help on using the repository browser.