Changeset 11325
- Timestamp:
- 09/01/14 15:56:15 (10 years ago)
- Location:
- branches/HeuristicLab.Problems.Orienteering
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering.Views/3.3/OrienteeringProblemView.cs
r11319 r11325 63 63 } else { 64 64 orienteeringSolutionView.Content = new OrienteeringSolution( 65 Content.BestKnownSolution, Content.Coordinates, Content.StartingPoint , Content.TerminalPoint, Content.Scores, Content.BestKnownQuality, penalty: null);65 Content.BestKnownSolution, Content.Coordinates, Content.StartingPointParameter.Value, Content.TerminalPointParameter.Value, Content.Scores, Content.BestKnownQuality, penalty: null); 66 66 } 67 67 } … … 76 76 } 77 77 private void StartingPointParameter_ValueChanged(object sender, EventArgs e) { 78 orienteeringSolutionView.Content.StartingPoint = Content.StartingPoint;78 orienteeringSolutionView.Content.StartingPoint.Value = Content.StartingPoint; 79 79 } 80 80 private void TerminalPointParameter_ValueChanged(object sender, EventArgs e) { 81 orienteeringSolutionView.Content.TerminalPoint = Content.TerminalPoint;81 orienteeringSolutionView.Content.TerminalPoint.Value = Content.TerminalPoint; 82 82 } 83 83 private void ScoresParameter_ValueChanged(object sender, EventArgs e) { -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering.Views/3.3/OrienteeringSolutionView.cs
r11319 r11325 134 134 Font font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular); 135 135 var beginSize = graphics.MeasureString("Begin", font); 136 graphics.DrawString("Begin", font, Brushes.Black, points[startingPoint].X - beginSize.Width, points[startingPoint].Y - beginSize.Height); 137 graphics.DrawString("End", font, Brushes.Black, points[terminalPoint].X, points[terminalPoint].Y); 136 if (startingPoint >= 0 && startingPoint < points.Length) 137 graphics.DrawString("Begin", font, Brushes.Black, points[startingPoint].X - beginSize.Width, points[startingPoint].Y - beginSize.Height); 138 if (terminalPoint >= 0 && terminalPoint < points.Length) 139 graphics.DrawString("End", font, Brushes.Black, points[terminalPoint].X, points[terminalPoint].Y); 138 140 } 139 141 } else { -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/OrienteeringProblem.cs
r11321 r11325 48 48 get { return (OptionalValueParameter<DoubleMatrix>)Parameters["Coordinates"]; } 49 49 } 50 public ValueParameter<DistanceMatrix> DistanceMatrixParameter {51 get { return ( ValueParameter<DistanceMatrix>)Parameters["DistanceMatrix"]; }52 } 53 54 public ValueParameter<IntValue> StartingPointParameter {55 get { return ( ValueParameter<IntValue>)Parameters["StartingPoint"]; }56 } 57 public ValueParameter<IntValue> TerminalPointParameter {58 get { return ( ValueParameter<IntValue>)Parameters["TerminalPoint"]; }59 } 60 public ValueParameter<DoubleValue> MaximumDistanceParameter {61 get { return ( ValueParameter<DoubleValue>)Parameters["MaximumDistance"]; }62 } 63 public ValueParameter<DoubleArray> ScoresParameter {64 get { return ( ValueParameter<DoubleArray>)Parameters["Scores"]; }65 } 66 public ValueParameter<DoubleValue> PointVisitingCostsParameter {67 get { return ( ValueParameter<DoubleValue>)Parameters["PointVisitingCosts"]; }50 public IValueParameter<DistanceMatrix> DistanceMatrixParameter { 51 get { return (IValueParameter<DistanceMatrix>)Parameters["DistanceMatrix"]; } 52 } 53 54 public IFixedValueParameter<IntValue> StartingPointParameter { 55 get { return (IFixedValueParameter<IntValue>)Parameters["StartingPoint"]; } 56 } 57 public IFixedValueParameter<IntValue> TerminalPointParameter { 58 get { return (IFixedValueParameter<IntValue>)Parameters["TerminalPoint"]; } 59 } 60 public IFixedValueParameter<DoubleValue> MaximumDistanceParameter { 61 get { return (IFixedValueParameter<DoubleValue>)Parameters["MaximumDistance"]; } 62 } 63 public IValueParameter<DoubleArray> ScoresParameter { 64 get { return (IValueParameter<DoubleArray>)Parameters["Scores"]; } 65 } 66 public IFixedValueParameter<DoubleValue> PointVisitingCostsParameter { 67 get { return (IFixedValueParameter<DoubleValue>)Parameters["PointVisitingCosts"]; } 68 68 } 69 69 … … 82 82 set { DistanceMatrixParameter.Value = value; } 83 83 } 84 public IntValueStartingPoint {85 get { return StartingPointParameter.Value ; }86 set { StartingPointParameter.Value = value; }87 } 88 public IntValueTerminalPoint {89 get { return TerminalPointParameter.Value ; }90 set { TerminalPointParameter.Value = value; }91 } 92 public DoubleValue MaximumDistance {93 get { return MaximumDistanceParameter.Value ; }94 set { MaximumDistanceParameter.Value = value; }84 public int StartingPoint { 85 get { return StartingPointParameter.Value.Value; } 86 set { StartingPointParameter.Value.Value = value; } 87 } 88 public int TerminalPoint { 89 get { return TerminalPointParameter.Value.Value; } 90 set { TerminalPointParameter.Value.Value = value; } 91 } 92 public double MaximumDistance { 93 get { return MaximumDistanceParameter.Value.Value; } 94 set { MaximumDistanceParameter.Value.Value = value; } 95 95 } 96 96 public DoubleArray Scores { … … 98 98 set { ScoresParameter.Value = value; } 99 99 } 100 public DoubleValue PointVisitingCosts {101 get { return PointVisitingCostsParameter.Value ; }102 set { PointVisitingCostsParameter.Value = value; }100 public double PointVisitingCosts { 101 get { return PointVisitingCostsParameter.Value.Value; } 102 set { PointVisitingCostsParameter.Value.Value = value; } 103 103 } 104 104 public IntegerVector BestKnownSolution { … … 126 126 Parameters.Add(new OptionalValueParameter<DoubleMatrix>("Coordinates", "The x- and y-Coordinates of the points.")); 127 127 Parameters.Add(new ValueParameter<DistanceMatrix>("DistanceMatrix", "The matrix which contains the distances between the points.")); 128 Parameters.Add(new ValueParameter<IntValue>("StartingPoint", "Index of the starting point.", new IntValue(0)));129 Parameters.Add(new ValueParameter<IntValue>("TerminalPoint", "Index of the ending point.", new IntValue(0)));130 Parameters.Add(new ValueParameter<DoubleValue>("MaximumDistance", "The maximum distance constraint for a Orienteering solution."));128 Parameters.Add(new FixedValueParameter<IntValue>("StartingPoint", "Index of the starting point.", new IntValue(0))); 129 Parameters.Add(new FixedValueParameter<IntValue>("TerminalPoint", "Index of the ending point.", new IntValue(0))); 130 Parameters.Add(new FixedValueParameter<DoubleValue>("MaximumDistance", "The maximum distance constraint for a Orienteering solution.")); 131 131 Parameters.Add(new ValueParameter<DoubleArray>("Scores", "The scores of the points.")); 132 Parameters.Add(new ValueParameter<DoubleValue>("PointVisitingCosts", "The costs for visiting a point."));132 Parameters.Add(new FixedValueParameter<DoubleValue>("PointVisitingCosts", "The costs for visiting a point.")); 133 133 Parameters.Add(new OptionalValueParameter<IntegerVector>("BestKnownSolution", "The best known solution of this Orienteering instance.")); 134 134 … … 173 173 ParameterizeSolutionCreator(); 174 174 UpdateDistanceMatrix(); 175 CheckStartingIndex(); 176 CheckTerminalIndex(); 175 177 } 176 178 private void CoordinatesValue_ItemChanged(object sender, EventArgs<int, int> e) { 177 179 UpdateDistanceMatrix(); 180 CheckStartingIndex(); 181 CheckTerminalIndex(); 178 182 } 179 183 private void CoordinatesValue_Reset(object sender, EventArgs e) { 180 184 ParameterizeSolutionCreator(); 181 185 UpdateDistanceMatrix(); 182 } 183 private void StartingPointParameter_ValueChanged(object sender, EventArgs e) { 184 ParameterizeEvaluator(); 185 ParameterizeAnalyzer(); 186 } 187 188 private void TerminalPointParameter_ValueChanged(object sender, EventArgs e) { 189 ParameterizeEvaluator(); 190 ParameterizeAnalyzer(); 191 } 192 private void MaximumDistanceParameter_ValueChanged(object sender, EventArgs e) { 193 ParameterizeEvaluator(); 194 ParameterizeAnalyzer(); 195 } 186 CheckStartingIndex(); 187 CheckTerminalIndex(); 188 } 189 private void StartingPointParameterValue_ValueChanged(object sender, EventArgs e) { 190 CheckStartingIndex(); 191 } 192 193 private void TerminalPointParameterValue_ValueChanged(object sender, EventArgs e) { 194 CheckTerminalIndex(); 195 } 196 private void MaximumDistanceParameterValue_ValueChanged(object sender, EventArgs e) { } 196 197 private void ScoresParameter_ValueChanged(object sender, EventArgs e) { 197 198 ParameterizeEvaluator(); … … 204 205 ParameterizeSolutionCreator(); 205 206 } 206 private void PointVisitingCostsParameter_ValueChanged(object sender, EventArgs e) { 207 ParameterizeEvaluator(); 208 ParameterizeAnalyzer(); 209 } 207 private void PointVisitingCostsParameterValue_ValueChanged(object sender, EventArgs e) { } 210 208 #endregion 211 209 … … 225 223 } 226 224 227 StartingPointParameter.ValueChanged += StartingPointParameter_ValueChanged; 228 TerminalPointParameter.ValueChanged += TerminalPointParameter_ValueChanged; 229 MaximumDistanceParameter.ValueChanged += MaximumDistanceParameter_ValueChanged; 225 StartingPointParameter.Value.ValueChanged += StartingPointParameterValue_ValueChanged; 226 TerminalPointParameter.Value.ValueChanged += TerminalPointParameterValue_ValueChanged; 227 MaximumDistanceParameter.Value.ValueChanged += MaximumDistanceParameterValue_ValueChanged; 228 PointVisitingCostsParameter.Value.ValueChanged += PointVisitingCostsParameterValue_ValueChanged; 230 229 231 230 ScoresParameter.ValueChanged += ScoresParameter_ValueChanged; 232 231 ScoresParameter.Value.Reset += ScoresValue_Reset; 233 PointVisitingCostsParameter.ValueChanged += PointVisitingCostsParameter_ValueChanged;234 232 } 235 233 … … 318 316 DistanceMatrix = new DistanceMatrix(distances); 319 317 } 318 private void CheckStartingIndex() { 319 if (StartingPoint < 0) StartingPoint = 0; 320 if (StartingPoint >= DistanceMatrix.Rows) StartingPoint = DistanceMatrix.Rows - 1; 321 } 322 private void CheckTerminalIndex() { 323 if (TerminalPoint < 0) TerminalPoint = 0; 324 if (TerminalPoint >= DistanceMatrix.Rows) TerminalPoint = DistanceMatrix.Rows - 1; 325 } 320 326 321 327 private void InitializeInitialOrienteeringInstance() { … … 330 336 DistanceMatrix = CalculateDistanceMatrix(coordinates); 331 337 332 StartingPoint .Value= 0;333 TerminalPoint .Value= 20;334 MaximumDistance .Value= 30;338 StartingPoint = 0; 339 TerminalPoint = 20; 340 MaximumDistance = 30; 335 341 336 342 Scores = new DoubleArray(new double[21] { 0, 20, 20, 30, 15, 15, 10, 20, 20, 20, 15, 10, 10, 25, 40, 40, 30, 30, 50, 30, 0 }); 337 343 } 338 344 345 #region Instance consuming 339 346 public void Load(OPData data) { 340 347 if (data.Coordinates == null && data.Distances == null) … … 356 363 DistanceMatrix = new DistanceMatrix(data.GetDistanceMatrix()); 357 364 358 StartingPoint = new IntValue(data.StartingPoint);359 TerminalPoint = new IntValue(data.TerminalPoint);360 361 PointVisitingCosts = new DoubleValue(data.PointVisitingCosts);362 MaximumDistance = new DoubleValue(data.MaximumDistance);365 StartingPoint = data.StartingPoint; 366 TerminalPoint = data.TerminalPoint; 367 368 PointVisitingCosts = data.PointVisitingCosts; 369 MaximumDistance = data.MaximumDistance; 363 370 Scores = new DoubleArray(data.Scores); 364 371 } … … 383 390 DistanceMatrix = new DistanceMatrix(data.GetDistanceMatrix()); 384 391 385 StartingPoint = new IntValue(0); // First city is interpreted as start point386 TerminalPoint = new IntValue(data.Dimension - 1); // Last city is interpreted als end point387 388 PointVisitingCosts = new DoubleValue(0);389 MaximumDistance = new DoubleValue(DistanceMatrix.Average() * 5.0); // distance from start to end first to last city is interpreted as maximum distance392 StartingPoint = 0; // First city is interpreted as start point 393 TerminalPoint = data.Dimension - 1; // Last city is interpreted als end point 394 395 PointVisitingCosts = 0; 396 MaximumDistance = DistanceMatrix.Average() * 5.0; // distance from start to end first to last city is interpreted as maximum distance 390 397 Scores = new DoubleArray(Enumerable.Repeat(1.0, data.Dimension).ToArray()); // all scores are 1 391 398 } … … 409 416 : CalculateDistanceMatrix(data.Coordinates); 410 417 411 StartingPoint = new IntValue(0); // Depot is interpreted as start point412 TerminalPoint = new IntValue(0); // Depot is interpreted als end point413 414 PointVisitingCosts = new DoubleValue(0);415 MaximumDistance = new DoubleValue(data.Capacity * 2); // capacity is interpreted as max distance418 StartingPoint = 0; // Depot is interpreted as start point 419 TerminalPoint = 0; // Depot is interpreted als end point 420 421 PointVisitingCosts = 0; 422 MaximumDistance = data.Capacity * 2; // capacity is interpreted as max distance 416 423 Scores = new DoubleArray(data.Demands); // demands are interpreted as scores 417 424 } 425 #endregion 418 426 } 419 427 }
Note: See TracChangeset
for help on using the changeset viewer.