Changeset 884 for trunk/sources
- Timestamp:
- 12/02/08 12:41:21 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Routing.TSP
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Routing.TSP/DistanceMatrixPathTSPEvaluator.cs
r2 r884 29 29 30 30 namespace HeuristicLab.Routing.TSP { 31 /// <summary> 32 /// Evaluates the TSP path by using values in the distance matrix. 33 /// </summary> 31 34 public class DistanceMatrixPathTSPEvaluator : SingleObjectiveEvaluatorBase { 35 /// <inheritdoc/> 32 36 public override string Description { 33 37 get { return @"TODO\r\nOperator description still missing ..."; } 34 38 } 35 39 40 /// <summary> 41 /// Initializes a new instance of <see cref="DistanceMatrixPathTSPEvaluator"/> with two variable 42 /// infos (<c>Permutation</c>, <c>DistanceMatrix</c>). 43 /// </summary> 36 44 public DistanceMatrixPathTSPEvaluator() 37 45 : base() { … … 40 48 } 41 49 50 /// <summary> 51 /// Calculates the length of the path in the given <paramref name="scope"/> by taking the 52 /// values of the distance matrix. 53 /// </summary> 54 /// <param name="scope">The current scope with the permutation and the distance matrix.</param> 55 /// <returns>The calculated length.</returns> 42 56 protected override double Evaluate(IScope scope) { 43 57 double[,] distanceMatrix = GetVariableValue<DoubleMatrixData>("DistanceMatrix", scope, true).Data; -
trunk/sources/HeuristicLab.Routing.TSP/HeuristicLabRoutingTSPPlugin.cs
r582 r884 26 26 27 27 namespace HeuristicLab.Routing.TSP { 28 /// <summary> 29 /// Plugin class for HeuristicLab.Routing.TSP plugin 30 /// </summary> 28 31 [ClassInfo(Name = "HeuristicLab.Routing.TSP-3.2")] 29 32 [PluginFile(Filename = "HeuristicLab.Routing.TSP-3.2.dll", Filetype = PluginFileType.Assembly)] -
trunk/sources/HeuristicLab.Routing.TSP/PathTSPEvaluatorBase.cs
r2 r884 29 29 30 30 namespace HeuristicLab.Routing.TSP { 31 /// <summary> 32 /// Base class for TSP path evaluation, based on length calculation. 33 /// </summary> 31 34 public abstract class PathTSPEvaluatorBase : SingleObjectiveEvaluatorBase { 35 /// <summary> 36 /// Initializes a new instance of <see cref="PathTSPEvaluatorBase"/> with two variable infos 37 /// (<c>Coordinates</c> and <c>Permutation</c>). 38 /// </summary> 32 39 public PathTSPEvaluatorBase() 33 40 : base() { … … 36 43 } 37 44 45 /// <summary> 46 /// Calculates the length of a whole path of the given <paramref name="scope"/>. 47 /// </summary> 48 /// <param name="scope">The scope where to evaluate the path.</param> 49 /// <returns>The calculated length.</returns> 38 50 protected sealed override double Evaluate(IScope scope) { 39 51 double[,] coordinates = GetVariableValue<DoubleMatrixData>("Coordinates", scope, true).Data; … … 53 65 } 54 66 67 /// <summary> 68 /// Calculates the distance between two given points. 69 /// </summary> 70 /// <param name="x1">The x coordinate of point 1.</param> 71 /// <param name="y1">The y coordinate of point 1.</param> 72 /// <param name="x2">The x coordinate of point 2.</param> 73 /// <param name="y2">The y coordinate of point 2.</param> 74 /// <returns>The calculated distance.</returns> 55 75 protected abstract double CalculateDistance(double x1, double y1, double x2, double y2); 56 76 } -
trunk/sources/HeuristicLab.Routing.TSP/RoundedEuclideanPathTSPEvaluator.cs
r2 r884 29 29 30 30 namespace HeuristicLab.Routing.TSP { 31 /// <summary> 32 /// Evaluates the TSP path by using the euclidean distance between two points. 33 /// </summary> 31 34 public class RoundedEuclideanPathTSPEvaluator : PathTSPEvaluatorBase { 35 /// <inheritdoc/> 32 36 public override string Description { 33 37 get { return @"TODO\r\nOperator description still missing ..."; } 34 38 } 35 39 40 /// <summary> 41 /// Calculates the distance between two points by using the euclidean distance. 42 /// </summary> 43 /// <param name="x1">The x coordinate of point 1.</param> 44 /// <param name="y1">The y coordinate of point 1.</param> 45 /// <param name="x2">The x coordinate of point 2.</param> 46 /// <param name="y2">The y coordinate of point 2.</param> 47 /// <returns>The euclidean distance between the two points.</returns> 36 48 protected override double CalculateDistance(double x1, double y1, double x2, double y2) { 37 49 return Math.Round(Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))); -
trunk/sources/HeuristicLab.Routing.TSP/TSPDistanceMatrixInjectorBase.cs
r77 r884 28 28 29 29 namespace HeuristicLab.Routing.TSP { 30 /// <summary> 31 /// Base class to inject the calculated distance matrix of the TSP path into the current scope. 32 /// </summary> 30 33 public abstract class TSPDistanceMatrixInjectorBase : OperatorBase { 34 /// <summary> 35 /// Initializes a new instance of <see cref="TSPDistanceMatrixInjectorBase"/> with three variable infos 36 /// (<c>Cities</c>, <c>Coordinates</c> and <c>DistanceMatrix</c>). 37 /// </summary> 31 38 public TSPDistanceMatrixInjectorBase() 32 39 : base() { … … 36 43 } 37 44 45 /// <summary> 46 /// Generates a distance matrix with the distances between all cities in the current path. 47 /// </summary> 48 /// <param name="scope">The current scope with the path.</param> 49 /// <returns><c>null</c>.</returns> 38 50 public override IOperation Apply(IScope scope) { 39 51 int cities = GetVariableValue<IntData>("Cities", scope, true).Data; … … 54 66 } 55 67 68 /// <summary> 69 /// Calculates the distance between two points in the path. 70 /// </summary> 71 /// <param name="x1">The x coordinate of point 1.</param> 72 /// <param name="y1">The y coordinate of point 1.</param> 73 /// <param name="x2">The x coordinate of point 2.</param> 74 /// <param name="y2">The y coordinate of point 2.</param> 75 /// <returns>The calculated distance.</returns> 56 76 protected abstract double CalculateDistance(double x1, double y1, double x2, double y2); 57 77 } -
trunk/sources/HeuristicLab.Routing.TSP/TSPInjector.cs
r77 r884 29 29 30 30 namespace HeuristicLab.Routing.TSP { 31 /// <summary> 32 /// Injects a new TSP in a given scope with all its needed variables.... 33 /// </summary> 31 34 public class TSPInjector : OperatorBase { 35 /// <inheritdoc/> 32 36 public override string Description { 33 37 get { return @"TODO\r\nOperator description still missing ..."; } 34 38 } 35 39 40 /// <summary> 41 /// Initializes a new instance of <see cref="TSPInjector"/> with four variable infos 42 /// (<c>Maximization</c>, <c>Cities</c>, <c>Coordinates</c> and <c>BestKnownQuality</c>). 43 /// </summary> 36 44 public TSPInjector() 37 45 : base() { … … 46 54 } 47 55 56 /// <summary> 57 /// Creates a new instance of <see cref="TSPInjectorView"/> to display the current instance. 58 /// </summary> 59 /// <returns>The created view as <see cref="TSPInjectorView"/>.</returns> 48 60 public override IView CreateView() { 49 61 return new TSPInjectorView(this); 50 62 } 51 63 64 /// <summary> 65 /// Adds a new TSP to the given <paramref name="scope"/>, through adding the needed variables. 66 /// </summary> 67 /// <param name="scope">The current scope where to inject the variables.</param> 68 /// <returns><c>null</c>.</returns> 52 69 public override IOperation Apply(IScope scope) { 53 70 scope.AddVariable(new Variable(scope.TranslateName("Maximization"), new BoolData(false))); -
trunk/sources/HeuristicLab.Routing.TSP/TSPInjectorView.cs
r2 r884 32 32 33 33 namespace HeuristicLab.Routing.TSP { 34 /// <summary> 35 /// Class to represent a <see cref="TSPInjector"/> visually. 36 /// </summary> 34 37 public partial class TSPInjectorView : ViewBase { 38 /// <summary> 39 /// Gets or set the <see cref="TSPInjector"/> to represent visually. 40 /// </summary> 41 /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>. 42 /// No own data storage present.</remarks> 35 43 public TSPInjector TSPInjector { 36 44 get { return (TSPInjector)Item; } … … 38 46 } 39 47 48 /// <summary> 49 /// Initializes a new instance of <see cref="TSPInjectorView"/>. 50 /// </summary> 40 51 public TSPInjectorView() { 41 52 InitializeComponent(); 42 53 } 54 /// <summary> 55 /// Initializes a new instance of <see cref="TSPInjectorView"/> with the given 56 /// <paramref name="tspInjector"/>. 57 /// </summary> 58 /// <param name="tspInjector">The <see cref="TSPInjector"/> to display.</param> 43 59 public TSPInjectorView(TSPInjector tspInjector) 44 60 : this() { … … 46 62 } 47 63 64 /// <summary> 65 /// Removes the event handlers in all children. 66 /// </summary> 67 /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks> 48 68 protected override void RemoveItemEvents() { 49 69 operatorBaseVariableInfosView.Operator = null; … … 51 71 base.RemoveItemEvents(); 52 72 } 73 /// <summary> 74 /// Adds event handlers in all children. 75 /// </summary> 76 /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks> 53 77 protected override void AddItemEvents() { 54 78 base.AddItemEvents(); … … 57 81 } 58 82 83 /// <summary> 84 /// Updates all controls with the latest data of the model. 85 /// </summary> 86 /// <remarks>Calls <see cref="ViewBase.UpdateControls"/> of base class <see cref="ViewBase"/>.</remarks> 59 87 protected override void UpdateControls() { 60 88 base.UpdateControls(); -
trunk/sources/HeuristicLab.Routing.TSP/TSPParser.cs
r2 r884 27 27 28 28 namespace HeuristicLab.Routing.TSP { 29 /// <summary> 30 /// Parses a *.tsp file and extracts its information about a TSP. 31 /// </summary> 29 32 public class TSPParser { 30 33 private const int EOF = 0; … … 39 42 40 43 private string myName; 44 /// <summary> 45 /// Gets the name of the parsed TSP. 46 /// </summary> 41 47 public string Name { 42 48 get { return myName; } 43 49 } 44 50 private double[,] myVertices; 51 /// <summary> 52 /// Gets the vertices of the parsed TSP. 53 /// </summary> 45 54 public double[,] Vertices { 46 55 get { return myVertices; } 47 56 } 48 57 private int myWeightType; 58 /// <summary> 59 /// Gets the weight type of the parsed TSP. 60 /// </summary> 49 61 public int WeightType { 50 62 get { return myWeightType; } 51 63 } 52 64 65 /// <summary> 66 /// Initializes a new instance of <see cref="TSPParser"/> with the given <paramref name="path"/>. 67 /// </summary> 68 /// <exception cref="ArgumentException">Thrown when the input file name is not in TSP format (*.tsp) 69 /// </exception> 70 /// <param name="path">The path where the TSP is stored.</param> 53 71 public TSPParser(String path) { 54 72 if (!path.EndsWith(".tsp")) … … 61 79 } 62 80 81 /// <summary> 82 /// Reads the TSP file and parses the elements. 83 /// </summary> 84 /// <exception cref="InvalidDataException">Thrown when file contains unknown (edge) types.</exception> 63 85 public void Parse() { 64 86 int section = -1; -
trunk/sources/HeuristicLab.Routing.TSP/TSPRoundedEuclideanDistanceMatrixInjector.cs
r2 r884 28 28 29 29 namespace HeuristicLab.Routing.TSP { 30 /// <summary> 31 /// Injects a distance matrix with euclidean distances of a TSP path into the current scope. 32 /// </summary> 30 33 public class TSPRoundedEuclideanDistanceMatrixInjector : TSPDistanceMatrixInjectorBase { 34 /// <inheritdoc/> 31 35 public override string Description { 32 36 get { return @"TODO\r\nOperator description still missing ..."; } 33 37 } 34 38 39 /// <summary> 40 /// Calculates the distance between two points by using the euclidean distance. 41 /// </summary> 42 /// <param name="x1">The x coordinate of point 1.</param> 43 /// <param name="y1">The y coordinate of point 1.</param> 44 /// <param name="x2">The x coordinate of point 2.</param> 45 /// <param name="y2">The y coordinate of point 2.</param> 46 /// <returns>The euclidean distance between the two points.</returns> 35 47 protected override double CalculateDistance(double x1, double y1, double x2, double y2) { 36 48 return Math.Round(Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))); -
trunk/sources/HeuristicLab.Routing.TSP/TSPTour.cs
r2 r884 29 29 30 30 namespace HeuristicLab.Routing.TSP { 31 /// <summary> 32 /// Represent the tour of a TSP. 33 /// </summary> 31 34 public class TSPTour : ItemBase, IVisualizationItem { 32 35 private DoubleMatrixData myCoordinates; 36 /// <summary> 37 /// Gets or sets the coordinates of the current instance. 38 /// </summary> 33 39 public DoubleMatrixData Coordinates { 34 40 get { return myCoordinates; } … … 36 42 } 37 43 private Permutation.Permutation myTour; 44 /// <summary> 45 /// Gets or sets the current permutation/tour of the current instance. 46 /// </summary> 38 47 public Permutation.Permutation Tour { 39 48 get { return myTour; } … … 42 51 43 52 53 /// <summary> 54 /// Initializes a new instance of <see cref="TSPTour"/>. 55 /// </summary> 44 56 public TSPTour() { } 57 /// <summary> 58 /// Initializes a new instance of <see cref="TSPTour"/> with the given <paramref name="coordinates"/> 59 /// and the given <paramref name="tour"/>. 60 /// </summary> 61 /// <param name="coordinates">The coordinates of the TSP.</param> 62 /// <param name="tour">The tour the current instance should represent.</param> 45 63 public TSPTour(DoubleMatrixData coordinates, Permutation.Permutation tour) { 46 64 myCoordinates = coordinates; … … 48 66 } 49 67 50 68 /// <summary> 69 /// Clones the current instance (deep clone). 70 /// </summary> 71 /// <remarks>Uses <see cref="Auxiliary.Clone"/> method of class <see cref="Auxiliary"/> to clone 72 /// the coordinates.</remarks> 73 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 74 /// <returns>The cloned object as <see cref="TSPTour"/>.</returns> 51 75 public override object Clone(IDictionary<Guid, object> clonedObjects) { 52 76 TSPTour clone = (TSPTour)base.Clone(clonedObjects); … … 56 80 } 57 81 82 /// <summary> 83 /// Creates a new instance of <see cref="TSPTourView"/> to display the current instance. 84 /// </summary> 85 /// <returns>The created view as <see cref="TSPTourView"/>.</returns> 58 86 public override IView CreateView() { 59 87 return new TSPTourView(this); 60 88 } 61 89 90 /// <summary> 91 /// Occurs when the coordinates of the current instance have been changed. 92 /// </summary> 62 93 public event EventHandler CoordinatesChanged; 94 /// <summary> 95 /// Fires a new <c>CoordinatesChanged</c> event. 96 /// </summary> 63 97 protected virtual void OnCoordinatesChanged() { 64 98 if (CoordinatesChanged != null) 65 99 CoordinatesChanged(this, new EventArgs()); 66 100 } 101 /// <summary> 102 /// Occurs when the tour of the current instance has been changed. 103 /// </summary> 67 104 public event EventHandler TourChanged; 105 /// <summary> 106 /// Fires a new <c>TourChanged</c> event. 107 /// </summary> 68 108 protected virtual void OnTourChanged() { 69 109 if (TourChanged != null) … … 72 112 73 113 #region Persistence Methods 114 /// <summary> 115 /// Saves the current instance as <see cref="XmlNode"/> in the specified <paramref name="document"/>. 116 /// </summary> 117 /// <remarks>Calls <see cref="StorableBase.GetXmlNode"/> of base class <see cref="ItemBase"/>. <br/> 118 /// The coordinates and the tour are saved as a child node with the tag names <c>Coordinates</c> and 119 /// <c>Tour</c>.</remarks> 120 /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param> 121 /// <param name="document">The <see cref="XmlDocument"/> where to save the data.</param> 122 /// <param name="persistedObjects">The dictionary of all already persisted objects. 123 /// (Needed to avoid cycles.)</param> 124 /// <returns>The saved <see cref="XmlNode"/>.</returns> 74 125 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) { 75 126 XmlNode node = base.GetXmlNode(name, document, persistedObjects); … … 78 129 return node; 79 130 } 131 /// <summary> 132 /// Loads the persisted TSP tour from the specified <paramref name="node"/>. 133 /// </summary> 134 /// <remarks>Calls <see cref="StorableBase.Populate"/> of base class 135 /// <see cref="ItemBase"/>.<br/> 136 /// The coordinates and the tour must be saved as child nodes with the tag names <c>Coordinates</c> 137 /// and <c>Tour</c> (see <see cref="GetXmlNode"/>).</remarks> 138 /// <param name="node">The <see cref="XmlNode"/> where the TSP tour is saved.</param> 139 /// <param name="restoredObjects">A dictionary of all already restored objects. (Needed to avoid cycles.)</param> 80 140 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) { 81 141 base.Populate(node, restoredObjects); -
trunk/sources/HeuristicLab.Routing.TSP/TSPTourInjector.cs
r77 r884 29 29 30 30 namespace HeuristicLab.Routing.TSP { 31 /// <summary> 32 /// Injects a new TSP tour in a given scope with all its neccessary variables. 33 /// </summary> 31 34 public class TSPTourInjector : OperatorBase { 35 /// <inheritdoc/> 32 36 public override string Description { 33 37 get { return @"TODO\r\nOperator description still missing ..."; } 34 38 } 35 39 40 /// <summary> 41 /// Initializes a new instance of <see cref="TSPTourInjector"/> with three variable infos 42 /// (<c>Coordinates</c>, <c>Permutation</c> and <c>Tour</c>). 43 /// </summary> 36 44 public TSPTourInjector() { 37 45 AddVariableInfo(new VariableInfo("Coordinates", "City coordinates", typeof(DoubleMatrixData), VariableKind.In)); … … 40 48 } 41 49 50 /// <summary> 51 /// Adds a new <see cref="TSPTour"/> to the given <paramref name="scope"/> with all 52 /// its neccessary variables. 53 /// </summary> 54 /// <param name="scope">The current scope where to inject the TSP tour.</param> 55 /// <returns><c>null</c>.</returns> 42 56 public override IOperation Apply(IScope scope) { 43 57 DoubleMatrixData coordinates = GetVariableValue<DoubleMatrixData>("Coordinates", scope, true); -
trunk/sources/HeuristicLab.Routing.TSP/TSPTourView.cs
r2 r884 33 33 34 34 namespace HeuristicLab.Routing.TSP { 35 /// <summary> 36 /// Class for the visual representation of a <see cref="TSPTour"/>. 37 /// </summary> 35 38 public partial class TSPTourView : ViewBase { 39 /// <summary> 40 /// Gets or sets the <see cref="TSPTour"/> to represent visually. 41 /// </summary> 42 /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>. 43 /// No own data storage present.</remarks> 36 44 public TSPTour TSPTour { 37 45 get { return (TSPTour)base.Item; } … … 40 48 41 49 50 /// <summary> 51 /// Initializes a new instance of <see cref="TSPTourView"/> with caption "TSP Tour View". 52 /// </summary> 42 53 public TSPTourView() { 43 54 InitializeComponent(); 44 55 Caption = "TSP Tour View"; 45 56 } 57 /// <summary> 58 /// Initializes a new instance of <see cref="TSPTourView"/> with the given <paramref name="tspTour"/>. 59 /// </summary> 60 /// <param name="tspTour">The tour to display.</param> 46 61 public TSPTourView(TSPTour tspTour) 47 62 : this() { … … 50 65 51 66 67 /// <summary> 68 /// Removes all event handlers from the underlying <see cref="TSPTour"/>. 69 /// </summary> 70 /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks> 52 71 protected override void RemoveItemEvents() { 53 72 TSPTour.CoordinatesChanged -= new EventHandler(TSPTour_CoordinatesChanged); … … 55 74 base.RemoveItemEvents(); 56 75 } 76 /// <summary> 77 /// Adds event handlers to the underlying <see cref="TSPTour"/>. 78 /// </summary> 79 /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks> 57 80 protected override void AddItemEvents() { 58 81 base.AddItemEvents(); … … 61 84 } 62 85 86 /// <summary> 87 /// Updates all controls with the latest data of the model. 88 /// </summary> 89 /// <remarks>Calls <see cref="ViewBase.UpdateControls"/> of base class <see cref="ViewBase"/>.</remarks> 63 90 protected override void UpdateControls() { 64 91 base.UpdateControls();
Note: See TracChangeset
for help on using the changeset viewer.