Changeset 3139
- Timestamp:
- 03/20/10 06:18:48 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.SGA/3.3/SGA.cs
r3107 r3139 191 191 UpdateMutators(); 192 192 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 193 if (Problem.Visualizer != null) Problem.Visualizer.VisualizationParameter.ActualNameChanged += new EventHandler(Visualizer_VisualizationParameter_ActualNameChanged); 193 194 base.OnProblemChanged(); 194 195 } 196 195 197 protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) { 196 198 ParameterizeStochasticOperator(Problem.SolutionCreator); … … 209 211 ParameterizeStochasticOperator(Problem.Visualizer); 210 212 ParameterizeSGAMainLoop(); 213 if (Problem.Visualizer != null) Problem.Visualizer.VisualizationParameter.ActualNameChanged += new EventHandler(Visualizer_VisualizationParameter_ActualNameChanged); 211 214 base.Problem_VisualizerChanged(sender, e); 212 215 } … … 234 237 ParameterizeSGAMainLoop(); 235 238 ParameterizeSelectors(); 239 } 240 private void Visualizer_VisualizationParameter_ActualNameChanged(object sender, EventArgs e) { 241 ParameterizeSGAMainLoop(); 236 242 } 237 243 #endregion … … 246 252 ElitesParameter.ValueChanged += new EventHandler(ElitesParameter_ValueChanged); 247 253 Elites.ValueChanged += new EventHandler(Elites_ValueChanged); 248 if (Problem != null) 254 if (Problem != null) { 255 UpdateCrossovers(); 256 UpdateMutators(); 249 257 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 258 if (Problem.Visualizer != null) Problem.Visualizer.VisualizationParameter.ActualNameChanged += new EventHandler(Visualizer_VisualizationParameter_ActualNameChanged); 259 } 250 260 } 251 261 … … 260 270 SGAMainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 261 271 SGAMainLoop.VisualizerParameter.ActualName = Problem.VisualizerParameter.Name; 262 SGAMainLoop.VisualizationParameter.ActualName = Problem.Visualizer.VisualizationParameter.ActualName; 272 if (Problem.Visualizer != null) 273 SGAMainLoop.VisualizationParameter.ActualName = Problem.Visualizer.VisualizationParameter.ActualName; 263 274 } 264 275 private void ParameterizeStochasticOperator(IOperator op) { -
trunk/sources/HeuristicLab.Operators/3.3/ResultsCollector.cs
r3095 r3139 45 45 IVariable var; 46 46 foreach (IParameter param in CollectedValues) { 47 results.TryGetValue(param.Name, out var); 48 if (var != null) 49 var.Value = (IItem)param.ActualValue; 50 else 51 results.Add(new Variable(param.Name, param.Description, param.ActualValue)); 47 IItem value = param.ActualValue; 48 if (value != null) { 49 results.TryGetValue(param.Name, out var); 50 if (var != null) 51 var.Value = value; 52 else 53 results.Add(new Variable(param.Name, param.Description, value)); 54 } 52 55 } 53 56 return base.Apply(); -
trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/PathTSPTourView.cs
r3107 r3139 83 83 DoubleMatrix coordinates = Content.Coordinates; 84 84 Permutation permutation = Content.Permutation; 85 Bitmap bitmap = new Bitmap(pictureBox.Width, pictureBox.Height); 85 86 86 double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue; 87 for (int i = 0; i < coordinates.Rows; i++) { 88 if (xMin > coordinates[i, 0]) xMin = coordinates[i, 0]; 89 if (yMin > coordinates[i, 1]) yMin = coordinates[i, 1]; 90 if (xMax < coordinates[i, 0]) xMax = coordinates[i, 0]; 91 if (yMax < coordinates[i, 1]) yMax = coordinates[i, 1]; 87 if (coordinates != null) { 88 double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue; 89 for (int i = 0; i < coordinates.Rows; i++) { 90 if (xMin > coordinates[i, 0]) xMin = coordinates[i, 0]; 91 if (yMin > coordinates[i, 1]) yMin = coordinates[i, 1]; 92 if (xMax < coordinates[i, 0]) xMax = coordinates[i, 0]; 93 if (yMax < coordinates[i, 1]) yMax = coordinates[i, 1]; 94 } 95 96 int border = 20; 97 double xStep = (pictureBox.Width - 2 * border) / (xMax - xMin); 98 double yStep = (pictureBox.Height - 2 * border) / (yMax - yMin); 99 100 Point[] points = new Point[coordinates.Rows]; 101 if (permutation == null) { 102 for (int i = 0; i < coordinates.Rows; i++) 103 points[i] = new Point(border + ((int)((coordinates[i, 0] - xMin) * xStep)), 104 border + ((int)((coordinates[i, 1] - yMin) * yStep))); 105 } else { 106 for (int i = 0; i < coordinates.Rows; i++) 107 points[i] = new Point(border + ((int)((coordinates[permutation[i], 0] - xMin) * xStep)), 108 border + ((int)((coordinates[permutation[i], 1] - yMin) * yStep))); 109 } 110 111 Graphics graphics = Graphics.FromImage(bitmap); 112 if (permutation != null) graphics.DrawPolygon(Pens.Black, points); 113 for (int i = 0; i < points.Length; i++) 114 graphics.FillRectangle(Brushes.Red, points[i].X - 2, points[i].Y - 2, 6, 6); 115 graphics.Dispose(); 92 116 } 93 94 int border = 20;95 double xStep = (pictureBox.Width - 2 * border) / (xMax - xMin);96 double yStep = (pictureBox.Height - 2 * border) / (yMax - yMin);97 98 Point[] points = new Point[coordinates.Rows];99 for (int i = 0; i < coordinates.Rows; i++)100 points[i] = new Point(border + ((int)((coordinates[permutation[i], 0] - xMin) * xStep)),101 border + ((int)((coordinates[permutation[i], 1] - yMin) * yStep)));102 103 Bitmap bitmap = new Bitmap(pictureBox.Width, pictureBox.Height);104 Graphics graphics = Graphics.FromImage(bitmap);105 graphics.DrawPolygon(Pens.Black, points);106 for (int i = 0; i < points.Length; i++)107 graphics.FillRectangle(Brushes.Blue, points[i].X - 1, points[i].Y - 1, 4, 4);108 graphics.Dispose();109 117 pictureBox.Image = bitmap; 110 118 } -
trunk/sources/HeuristicLab.Problems.TSP/3.3/PathTSPTour.cs
r3133 r3139 39 39 get { return coordinates; } 40 40 set { 41 if (value == null) throw new ArgumentNullException();42 41 if (coordinates != value) { 43 42 if (coordinates != null) DeregisterCoordinatesEvents(); … … 53 52 get { return permutation; } 54 53 set { 55 if (value == null) throw new ArgumentNullException();56 54 if (permutation != value) { 57 55 if (permutation != null) DeregisterPermutationEvents(); … … 63 61 } 64 62 65 p rivatePathTSPTour() : base() { }66 public PathTSPTour(DoubleMatrix coordinates , Permutation permutation)63 public PathTSPTour() : base() { } 64 public PathTSPTour(DoubleMatrix coordinates) 67 65 : base() { 68 66 Coordinates = coordinates; 67 } 68 public PathTSPTour(DoubleMatrix coordinates, Permutation permutation) 69 : this(coordinates) { 69 70 Permutation = permutation; 70 71 } -
trunk/sources/HeuristicLab.Problems.TSP/3.3/TSP.cs
r3107 r3139 218 218 } 219 219 private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) { 220 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 220 221 ParameterizeEvaluator(); 221 222 ParameterizeVisualizer(); 222 223 ClearDistanceMatrix(); 223 224 OnEvaluatorChanged(); 225 } 226 private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) { 227 ParameterizeVisualizer(); 224 228 } 225 229 private void VisualizerParameter_ValueChanged(object sender, EventArgs e) { … … 251 255 SolutionCreator.PermutationParameter.ActualNameChanged += new EventHandler(SolutionCreator_PermutationParameter_ActualNameChanged); 252 256 EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged); 257 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 253 258 VisualizerParameter.ValueChanged += new EventHandler(VisualizerParameter_ValueChanged); 254 259 } 260 255 261 private void InitializeOperators() { 256 262 operators = new List<IPermutationOperator>(); … … 287 293 } 288 294 private void ParameterizeVisualizer() { 289 Visualizer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName; 290 if (Visualizer is ICoordinatesTSPSolutionsVisualizer) 291 ((ICoordinatesTSPSolutionsVisualizer)Visualizer).CoordinatesParameter.ActualName = CoordinatesParameter.Name; 292 if (Visualizer is IPathCoordinatesTSPSolutionsVisualizer) 293 ((IPathCoordinatesTSPSolutionsVisualizer)Visualizer).PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName; 295 if (Visualizer != null) { 296 Visualizer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName; 297 if (Visualizer is ICoordinatesTSPSolutionsVisualizer) 298 ((ICoordinatesTSPSolutionsVisualizer)Visualizer).CoordinatesParameter.ActualName = CoordinatesParameter.Name; 299 if (Visualizer is IPathCoordinatesTSPSolutionsVisualizer) 300 ((IPathCoordinatesTSPSolutionsVisualizer)Visualizer).PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName; 301 } 294 302 } 295 303 private void ParameterizeOperators() {
Note: See TracChangeset
for help on using the changeset viewer.