Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3097 for trunk


Ignore:
Timestamp:
03/18/10 05:37:06 (14 years ago)
Author:
swagner
Message:

Started to implement TSP tour visualization (#924)

Location:
trunk/sources
Files:
5 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r3093 r3097  
    8686    <None Include="HeuristicLabOptimizationPlugin.cs.frame" />
    8787    <Compile Include="Algorithm.cs" />
     88    <Compile Include="Interfaces\ISolutionVisualizer.cs" />
    8889    <Compile Include="Interfaces\IDiscreteDoubleValueModifier.cs" />
    8990    <Compile Include="Interfaces\IMoveOperator.cs" />
  • trunk/sources/HeuristicLab.Problems.TSP/3.3/HeuristicLab.Problems.TSP-3.3.csproj

    r3074 r3097  
    8484  </ItemGroup>
    8585  <ItemGroup>
     86    <Compile Include="Interfaces\IPathTSPTourVisualizer.cs" />
     87    <Compile Include="Interfaces\ITSPTourVisualizer.cs" />
     88    <Compile Include="TSPTour.cs" />
     89    <Compile Include="Visualizers\PathTSPTourVisualizer.cs" />
    8690    <Compile Include="Evaluators\TSPCoordinatesPathEvaluator.cs" />
    8791    <Compile Include="Evaluators\TSPEvaluator.cs" />
  • trunk/sources/HeuristicLab.Problems.TSP/3.3/TSPTour.cs

    r2883 r3097  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using System.Xml;
    2623using HeuristicLab.Core;
    2724using HeuristicLab.Data;
    28 using HeuristicLab.Permutation;
     25using HeuristicLab.Encodings.PermutationEncoding;
    2926using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3027
    3128namespace HeuristicLab.Problems.TSP {
    3229  /// <summary>
    33   /// Represent the tour of a TSP.
     30  /// Represents a tour of a Traveling Salesman Problem which can be visualized in the GUI.
    3431  /// </summary>
    35   public class TSPTour : ItemBase, IVisualizationItem {
    36 
     32  [Item("TSPTour", "Represents a tour of a Traveling Salesman Problem which can be visualized in the GUI.")]
     33  [StorableClass]
     34  public sealed class TSPTour : Item {
     35    private DoubleMatrix coordinates;
    3736    [Storable]
    38     private DoubleMatrixData myCoordinates;
    39     /// <summary>
    40     /// Gets or sets the coordinates of the current instance.
    41     /// </summary>
    42     public DoubleMatrixData Coordinates {
    43       get { return myCoordinates; }
    44       set { myCoordinates = value; }
     37    public DoubleMatrix Coordinates {
     38      get { return coordinates; }
     39      set {
     40        if (value == null) throw new ArgumentNullException();
     41        if (coordinates != value) {
     42          coordinates = value;
     43          OnCoordinatesChanged();
     44        }
     45      }
     46    }
     47    private Permutation permutation;
     48    [Storable]
     49    public Permutation Permutation {
     50      get { return permutation; }
     51      set {
     52        if (value == null) throw new ArgumentNullException();
     53        if (permutation != value) {
     54          permutation = value;
     55          OnPermutationChanged();
     56        }
     57      }
    4558    }
    4659
    47     [Storable]
    48     private Permutation.Permutation myTour;
    49     /// <summary>
    50     /// Gets or sets the current permutation/tour of the current instance.
    51     /// </summary>
    52     public Permutation.Permutation Tour {
    53       get { return myTour; }
    54       set { myTour = value; }
     60    private TSPTour() : base() { }
     61    public TSPTour(DoubleMatrix coordinates, Permutation permutation)
     62      : base() {
     63      if ((coordinates == null) || (permutation == null)) throw new ArgumentNullException();
     64      this.coordinates = coordinates;
     65      this.permutation = permutation;
    5566    }
    5667
    57 
    58     /// <summary>
    59     /// Initializes a new instance of <see cref="TSPTour"/>.
    60     /// </summary>
    61     public TSPTour() { }
    62     /// <summary>
    63     /// Initializes a new instance of <see cref="TSPTour"/> with the given <paramref name="coordinates"/>
    64     /// and the given <paramref name="tour"/>.
    65     /// </summary>
    66     /// <param name="coordinates">The coordinates of the TSP.</param>
    67     /// <param name="tour">The tour the current instance should represent.</param>
    68     public TSPTour(DoubleMatrixData coordinates, Permutation.Permutation tour) {
    69       myCoordinates = coordinates;
    70       myTour = tour;
    71     }
    72 
    73     /// <summary>
    74     /// Clones the current instance (deep clone).
    75     /// </summary>
    76     /// <remarks>Uses <see cref="cloner.Clone"/> method of class <see cref="Auxiliary"/> to clone
    77     /// the coordinates.</remarks>
    78     /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    79     /// <returns>The cloned object as <see cref="TSPTour"/>.</returns>
    80     public override IItem Clone(ICloner cloner) {
    81       TSPTour clone = (TSPTour)base.Clone(cloner);
    82       clone.myCoordinates = (DoubleMatrixData)cloner.Clone(Coordinates);
    83       clone.myTour = Tour;
     68    public override IDeepCloneable Clone(Cloner cloner) {
     69      TSPTour clone = new TSPTour((DoubleMatrix)cloner.Clone(coordinates), (Permutation)cloner.Clone(permutation));
     70      cloner.RegisterClonedObject(this, clone);
    8471      return clone;
    8572    }
    8673
    87     /// <summary>
    88     /// Occurs when the coordinates of the current instance have been changed.
    89     /// </summary>
    9074    public event EventHandler CoordinatesChanged;
    91     /// <summary>
    92     /// Fires a new <c>CoordinatesChanged</c> event.
    93     /// </summary>
    94     protected virtual void OnCoordinatesChanged() {
     75    private void OnCoordinatesChanged() {
    9576      if (CoordinatesChanged != null)
    96         CoordinatesChanged(this, new EventArgs());
     77        CoordinatesChanged(this, EventArgs.Empty);
    9778    }
    98     /// <summary>
    99     /// Occurs when the tour of the current instance has been changed.
    100     /// </summary>
    101     public event EventHandler TourChanged;
    102     /// <summary>
    103     /// Fires a new <c>TourChanged</c> event.
    104     /// </summary>
    105     protected virtual void OnTourChanged() {
    106       if (TourChanged != null)
    107         TourChanged(this, new EventArgs());
    108     }   
     79    public event EventHandler PermutationChanged;
     80    private void OnPermutationChanged() {
     81      if (PermutationChanged != null)
     82        PermutationChanged(this, EventArgs.Empty);
     83    }
    10984  }
    11085}
Note: See TracChangeset for help on using the changeset viewer.