[17260] | 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 |
|
---|
[17335] | 22 | using System.ComponentModel;
|
---|
[17260] | 23 | using System.Drawing;
|
---|
| 24 | using HEAL.Attic;
|
---|
| 25 | using HeuristicLab.Common;
|
---|
| 26 | using HeuristicLab.Core;
|
---|
| 27 | using HeuristicLab.Data;
|
---|
[17533] | 28 | using HeuristicLab.Encodings.PermutationEncoding;
|
---|
[17260] | 29 | using HeuristicLab.Problems.TravelingSalesman;
|
---|
| 30 |
|
---|
| 31 | namespace HeuristicLab.Problems.PTSP {
|
---|
| 32 | [StorableType("596f52b5-b2c8-45a0-a7bd-e5b9c787c960")]
|
---|
[17533] | 33 | public interface IProbabilisticTSPSolution : ITSPSolution {
|
---|
| 34 | PercentArray Probabilities { get; }
|
---|
[17260] | 35 | }
|
---|
| 36 |
|
---|
| 37 | /// <summary>
|
---|
| 38 | /// Represents a tour of a Traveling Salesman Problem given in path representation which can be visualized in the GUI.
|
---|
| 39 | /// </summary>
|
---|
| 40 | [Item("pTSP Solution", "Represents a tour of a Probabilistic Traveling Salesman Problem given in path representation which can be visualized in the GUI.")]
|
---|
| 41 | [StorableType("ea784622-41e5-493e-a1f3-4c38fed99216")]
|
---|
[17335] | 42 | public sealed class ProbabilisticTSPSolution : Item, IProbabilisticTSPSolution {
|
---|
[17260] | 43 | public static new Image StaticItemImage {
|
---|
| 44 | get { return HeuristicLab.Common.Resources.VSImageLibrary.Image; }
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | [Storable]
|
---|
[17335] | 48 | private ITSPSolution tspSolution;
|
---|
| 49 | public ITSPSolution TSPSolution {
|
---|
| 50 | get { return tspSolution; }
|
---|
| 51 | set {
|
---|
| 52 | if (tspSolution == value) return;
|
---|
| 53 | tspSolution = value;
|
---|
| 54 | OnPropertyChanged(nameof(TSPSolution));
|
---|
| 55 | }
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | [Storable]
|
---|
[17533] | 59 | private PercentArray probabilities;
|
---|
| 60 | public PercentArray Probabilities {
|
---|
[17260] | 61 | get { return probabilities; }
|
---|
| 62 | set {
|
---|
| 63 | if (probabilities == value) return;
|
---|
| 64 | probabilities = value;
|
---|
| 65 | OnPropertyChanged(nameof(Probabilities));
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 |
|
---|
[17533] | 69 | ITSPData ITSPSolution.Data => tspSolution.Data;
|
---|
| 70 |
|
---|
| 71 | Permutation ITSPSolution.Tour => tspSolution.Tour;
|
---|
| 72 |
|
---|
| 73 | DoubleValue ITSPSolution.TourLength => tspSolution.TourLength;
|
---|
| 74 |
|
---|
[17260] | 75 | [StorableConstructor]
|
---|
| 76 | private ProbabilisticTSPSolution(StorableConstructorFlag _) : base(_) { }
|
---|
| 77 | private ProbabilisticTSPSolution(ProbabilisticTSPSolution original, Cloner cloner)
|
---|
| 78 | : base(original, cloner) {
|
---|
[17335] | 79 | this.tspSolution = cloner.Clone(original.tspSolution);
|
---|
[17260] | 80 | this.probabilities = cloner.Clone(original.probabilities);
|
---|
| 81 | }
|
---|
| 82 | public ProbabilisticTSPSolution() : base() { }
|
---|
[17335] | 83 | public ProbabilisticTSPSolution(ITSPSolution tspSolution, PercentArray probabilities)
|
---|
| 84 | : base() {
|
---|
| 85 | this.tspSolution = tspSolution;
|
---|
[17260] | 86 | this.probabilities = probabilities;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 90 | return new ProbabilisticTSPSolution(this, cloner);
|
---|
| 91 | }
|
---|
[17335] | 92 |
|
---|
| 93 | public event PropertyChangedEventHandler PropertyChanged;
|
---|
| 94 | private void OnPropertyChanged(string property) {
|
---|
| 95 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
|
---|
| 96 | }
|
---|
[17260] | 97 | }
|
---|
| 98 | }
|
---|