Index: /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/HeuristicLab.Problems.TSP.Views-3.3.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/HeuristicLab.Problems.TSP.Views-3.3.csproj (revision 3152)
+++ /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/HeuristicLab.Problems.TSP.Views-3.3.csproj (revision 3153)
@@ -152,4 +152,8 @@
HeuristicLab.Optimization-3.3
+
+ {56F9106A-079F-4C61-92F6-86A84C2D84B7}
+ HeuristicLab.Parameters-3.3
+
{94186A6A-5176-4402-AE83-886557B53CCA}
Index: /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/HeuristicLabProblemsTSPViewsPlugin.cs.frame
===================================================================
--- /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/HeuristicLabProblemsTSPViewsPlugin.cs.frame (revision 3152)
+++ /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/HeuristicLabProblemsTSPViewsPlugin.cs.frame (revision 3153)
@@ -38,4 +38,5 @@
[PluginDependency("HeuristicLab.Optimization", "3.3")]
[PluginDependency("HeuristicLab.Optimization.Views", "3.3")]
+ [PluginDependency("HeuristicLab.Parameters", "3.3")]
[PluginDependency("HeuristicLab.Problems.TSP", "3.3")]
public class HeuristicLabProblemsTSPViewsPlugin : PluginBase {
Index: /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/PathTSPTourView.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/PathTSPTourView.cs (revision 3152)
+++ /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/PathTSPTourView.cs (revision 3153)
@@ -69,9 +69,10 @@
base.OnContentChanged();
if (Content == null) {
+ pictureBox.Image = null;
pictureBox.Enabled = false;
} else {
pictureBox.Enabled = true;
+ GenerateImage();
}
- GenerateImage();
}
@@ -85,5 +86,5 @@
Bitmap bitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
- if (coordinates != null) {
+ if ((coordinates != null) && (coordinates.Rows > 0) && (coordinates.Columns == 2)) {
double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue;
for (int i = 0; i < coordinates.Rows; i++) {
@@ -99,16 +100,16 @@
Point[] points = new Point[coordinates.Rows];
- if (permutation == null) {
- for (int i = 0; i < coordinates.Rows; i++)
- points[i] = new Point(border + ((int)((coordinates[i, 0] - xMin) * xStep)),
- border + ((int)((coordinates[i, 1] - yMin) * yStep)));
- } else {
- for (int i = 0; i < coordinates.Rows; i++)
- points[i] = new Point(border + ((int)((coordinates[permutation[i], 0] - xMin) * xStep)),
- border + ((int)((coordinates[permutation[i], 1] - yMin) * yStep)));
- }
+ for (int i = 0; i < coordinates.Rows; i++)
+ points[i] = new Point(border + ((int)((coordinates[i, 0] - xMin) * xStep)),
+ border + ((int)((coordinates[i, 1] - yMin) * yStep)));
Graphics graphics = Graphics.FromImage(bitmap);
- if (permutation != null) graphics.DrawPolygon(Pens.Black, points);
+ if ((permutation != null) && (permutation.Length == coordinates.Rows) && (permutation.Validate())) {
+ Point[] tour = new Point[permutation.Length];
+ for (int i = 0; i < permutation.Length; i++) {
+ tour[i] = points[permutation[i]];
+ }
+ graphics.DrawPolygon(Pens.Black, tour);
+ }
for (int i = 0; i < points.Length; i++)
graphics.FillRectangle(Brushes.Red, points[i].X - 2, points[i].Y - 2, 6, 6);
Index: /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/TSPLIBImportDialog.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/TSPLIBImportDialog.cs (revision 3152)
+++ /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/TSPLIBImportDialog.cs (revision 3153)
@@ -27,5 +27,5 @@
namespace HeuristicLab.Problems.TSP.Views {
- public partial class TSPLIBImportDialog : Form {
+ public sealed partial class TSPLIBImportDialog : Form {
private string tspFileName;
public string TSPFileName {
Index: /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/TSPView.Designer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/TSPView.Designer.cs (revision 3152)
+++ /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/TSPView.Designer.cs (revision 3153)
@@ -47,10 +47,14 @@
private void InitializeComponent() {
this.importButton = new System.Windows.Forms.Button();
+ this.tabControl = new System.Windows.Forms.TabControl();
+ this.parametersTabPage = new System.Windows.Forms.TabPage();
+ this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();
+ this.visualizationTabPage = new System.Windows.Forms.TabPage();
+ this.pathTSPTourView = new HeuristicLab.Problems.TSP.Views.PathTSPTourView();
((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
+ this.tabControl.SuspendLayout();
+ this.parametersTabPage.SuspendLayout();
+ this.visualizationTabPage.SuspendLayout();
this.SuspendLayout();
- //
- // parameterCollectionView
- //
- this.parameterCollectionView.Size = new System.Drawing.Size(529, 341);
//
// nameTextBox
@@ -76,13 +80,73 @@
this.importButton.Click += new System.EventHandler(this.importButton_Click);
//
+ // tabControl
+ //
+ this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.tabControl.Controls.Add(this.parametersTabPage);
+ this.tabControl.Controls.Add(this.visualizationTabPage);
+ this.tabControl.Location = new System.Drawing.Point(0, 52);
+ this.tabControl.Name = "tabControl";
+ this.tabControl.SelectedIndex = 0;
+ this.tabControl.Size = new System.Drawing.Size(529, 341);
+ this.tabControl.TabIndex = 4;
+ //
+ // parametersTabPage
+ //
+ this.parametersTabPage.Controls.Add(this.parameterCollectionView);
+ this.parametersTabPage.Location = new System.Drawing.Point(4, 22);
+ this.parametersTabPage.Name = "parametersTabPage";
+ this.parametersTabPage.Padding = new System.Windows.Forms.Padding(3);
+ this.parametersTabPage.Size = new System.Drawing.Size(521, 315);
+ this.parametersTabPage.TabIndex = 0;
+ this.parametersTabPage.Text = "Parameters";
+ this.parametersTabPage.UseVisualStyleBackColor = true;
+ //
+ // parameterCollectionView
+ //
+ this.parameterCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.parameterCollectionView.Caption = "ParameterCollection";
+ this.parameterCollectionView.Content = null;
+ this.parameterCollectionView.Location = new System.Drawing.Point(6, 6);
+ this.parameterCollectionView.Name = "parameterCollectionView";
+ this.parameterCollectionView.Size = new System.Drawing.Size(509, 303);
+ this.parameterCollectionView.TabIndex = 0;
+ //
+ // visualizationTabPage
+ //
+ this.visualizationTabPage.Controls.Add(this.pathTSPTourView);
+ this.visualizationTabPage.Location = new System.Drawing.Point(4, 22);
+ this.visualizationTabPage.Name = "visualizationTabPage";
+ this.visualizationTabPage.Padding = new System.Windows.Forms.Padding(3);
+ this.visualizationTabPage.Size = new System.Drawing.Size(521, 315);
+ this.visualizationTabPage.TabIndex = 1;
+ this.visualizationTabPage.Text = "Visualization";
+ this.visualizationTabPage.UseVisualStyleBackColor = true;
+ //
+ // pathTSPTourView
+ //
+ this.pathTSPTourView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.pathTSPTourView.Caption = "View";
+ this.pathTSPTourView.Content = null;
+ this.pathTSPTourView.Location = new System.Drawing.Point(6, 6);
+ this.pathTSPTourView.Name = "pathTSPTourView";
+ this.pathTSPTourView.Size = new System.Drawing.Size(509, 303);
+ this.pathTSPTourView.TabIndex = 0;
+ //
// TSPView
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.tabControl);
this.Controls.Add(this.importButton);
this.Name = "TSPView";
this.Size = new System.Drawing.Size(529, 422);
this.Controls.SetChildIndex(this.importButton, 0);
- this.Controls.SetChildIndex(this.parameterCollectionView, 0);
+ this.Controls.SetChildIndex(this.tabControl, 0);
this.Controls.SetChildIndex(this.nameLabel, 0);
this.Controls.SetChildIndex(this.descriptionLabel, 0);
@@ -90,4 +154,7 @@
this.Controls.SetChildIndex(this.descriptionTextBox, 0);
((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
+ this.tabControl.ResumeLayout(false);
+ this.parametersTabPage.ResumeLayout(false);
+ this.visualizationTabPage.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -98,4 +165,9 @@
private System.Windows.Forms.Button importButton;
+ private System.Windows.Forms.TabControl tabControl;
+ private System.Windows.Forms.TabPage parametersTabPage;
+ private System.Windows.Forms.TabPage visualizationTabPage;
+ private HeuristicLab.Core.Views.ParameterCollectionView parameterCollectionView;
+ private PathTSPTourView pathTSPTourView;
}
Index: /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/TSPView.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/TSPView.cs (revision 3152)
+++ /trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/TSPView.cs (revision 3153)
@@ -22,7 +22,7 @@
using System;
using System.Windows.Forms;
+using HeuristicLab.Core;
using HeuristicLab.Core.Views;
using HeuristicLab.MainForm;
-using HeuristicLab.Optimization.Views;
namespace HeuristicLab.Problems.TSP.Views {
@@ -32,5 +32,5 @@
[View("TSP View")]
[Content(typeof(TSP), true)]
- public sealed partial class TSPView : ProblemView {
+ public sealed partial class TSPView : NamedItemView {
private TSPLIBImportDialog tsplibImportDialog;
@@ -55,9 +55,28 @@
}
+ protected override void DeregisterContentEvents() {
+ Content.CoordinatesParameter.ValueChanged -= new EventHandler(CoordinatesParameter_ValueChanged);
+ Content.BestKnownSolutionParameter.ValueChanged -= new EventHandler(BestKnownSolutionParameter_ValueChanged);
+ base.DeregisterContentEvents();
+ }
+ protected override void RegisterContentEvents() {
+ base.RegisterContentEvents();
+ Content.CoordinatesParameter.ValueChanged += new EventHandler(CoordinatesParameter_ValueChanged);
+ Content.BestKnownSolutionParameter.ValueChanged += new EventHandler(BestKnownSolutionParameter_ValueChanged);
+ }
+
protected override void OnContentChanged() {
base.OnContentChanged();
if (Content == null) {
+ parameterCollectionView.Content = null;
+ parameterCollectionView.Enabled = false;
+ pathTSPTourView.Content = null;
+ pathTSPTourView.Enabled = false;
importButton.Enabled = false;
} else {
+ parameterCollectionView.Content = ((IParameterizedNamedItem)Content).Parameters;
+ parameterCollectionView.Enabled = true;
+ pathTSPTourView.Content = new PathTSPTour(Content.Coordinates, Content.BestKnownSolution);
+ pathTSPTourView.Enabled = true;
importButton.Enabled = true;
}
@@ -79,4 +98,11 @@
}
}
+
+ private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
+ pathTSPTourView.Content.Coordinates = Content.Coordinates;
+ }
+ private void BestKnownSolutionParameter_ValueChanged(object sender, EventArgs e) {
+ pathTSPTourView.Content.Permutation = Content.BestKnownSolution;
+ }
}
}
Index: /trunk/sources/HeuristicLab.Problems.TSP/3.3/HeuristicLab.Problems.TSP-3.3.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Problems.TSP/3.3/HeuristicLab.Problems.TSP-3.3.csproj (revision 3152)
+++ /trunk/sources/HeuristicLab.Problems.TSP/3.3/HeuristicLab.Problems.TSP-3.3.csproj (revision 3153)
@@ -156,4 +156,5 @@
+
Index: /trunk/sources/HeuristicLab.Problems.TSP/3.3/TSP.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.TSP/3.3/TSP.cs (revision 3152)
+++ /trunk/sources/HeuristicLab.Problems.TSP/3.3/TSP.cs (revision 3153)
@@ -23,4 +23,5 @@
using System.Collections.Generic;
using System.Drawing;
+using System.IO;
using System.Linq;
using HeuristicLab.Common;
@@ -178,8 +179,9 @@
Coordinates = new DoubleMatrix(tspParser.Vertices);
BestKnownQuality = null;
-
+ BestKnownSolution = null;
if (!string.IsNullOrEmpty(optimalTourFileName)) {
TSPLIBTourParser tourParser = new TSPLIBTourParser(optimalTourFileName);
tourParser.Parse();
+ if (tourParser.Tour.Length != Coordinates.Rows) throw new InvalidDataException("Length of optimal tour is not equal to number of cities.");
BestKnownSolution = new Permutation(tourParser.Tour);
}