Changeset 11327
- Timestamp:
- 09/02/14 13:09:59 (10 years ago)
- Location:
- branches/HeuristicLab.Problems.Orienteering
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering.Views/3.3/OrienteeringProblemView.cs
r11325 r11327 62 62 orienteeringSolutionView.Content = null; 63 63 } else { 64 orienteeringSolutionView.Content = new OrienteeringSolution( 65 Content.BestKnownSolution, Content.Coordinates, Content.StartingPointParameter.Value, Content.TerminalPointParameter.Value, Content.Scores, Content.BestKnownQuality, penalty: null); 64 orienteeringSolutionView.Content = new OrienteeringSolution(Content.BestKnownSolution, 65 Content.Coordinates, Content.StartingPointParameter.Value, Content.TerminalPointParameter.Value, Content.Scores); 66 if (Content.BestKnownSolution != null) { 67 EvaluateBestSolution(); 68 } 66 69 } 67 70 } … … 89 92 private void BestKnownSolutionParameter_ValueChanged(object sender, EventArgs e) { 90 93 orienteeringSolutionView.Content.IntegerVector = Content.BestKnownSolution; 94 if (Content.BestKnownSolution != null) 95 EvaluateBestSolution(); 96 else { 97 var solution = orienteeringSolutionView.Content; 98 solution.Penalty = null; 99 solution.Distance = null; 100 } 101 } 102 103 private void EvaluateBestSolution() { 104 var evaluation = Content.Evaluator.Evaluate(Content.BestKnownSolution, Content.Scores, Content.DistanceMatrix, 105 Content.MaximumDistance, Content.PointVisitingCosts); 106 orienteeringSolutionView.Content.Quality = evaluation.Quality; 107 orienteeringSolutionView.Content.Penalty = evaluation.Penalty; 108 orienteeringSolutionView.Content.Distance = evaluation.Distance; 91 109 } 92 110 } -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering.Views/3.3/OrienteeringSolutionView.Designer.cs
r11240 r11327 54 54 this.qualityGroupBox = new System.Windows.Forms.GroupBox(); 55 55 this.qualityViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 56 this.distanceGroupBox = new System.Windows.Forms.GroupBox(); 57 this.distanceViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 58 this.penaltyGroupBox = new System.Windows.Forms.GroupBox(); 59 this.penaltyViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 56 60 ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); 57 61 this.tabControl.SuspendLayout(); … … 64 68 this.splitContainer.SuspendLayout(); 65 69 this.qualityGroupBox.SuspendLayout(); 70 this.distanceGroupBox.SuspendLayout(); 71 this.penaltyGroupBox.SuspendLayout(); 66 72 this.SuspendLayout(); 67 73 // … … 75 81 this.pictureBox.Location = new System.Drawing.Point(6, 6); 76 82 this.pictureBox.Name = "pictureBox"; 77 this.pictureBox.Size = new System.Drawing.Size( 403, 322);83 this.pictureBox.Size = new System.Drawing.Size(199, 362); 78 84 this.pictureBox.TabIndex = 0; 79 85 this.pictureBox.TabStop = false; … … 91 97 this.tabControl.Name = "tabControl"; 92 98 this.tabControl.SelectedIndex = 0; 93 this.tabControl.Size = new System.Drawing.Size( 423, 360);99 this.tabControl.Size = new System.Drawing.Size(219, 396); 94 100 this.tabControl.TabIndex = 0; 95 101 // … … 100 106 this.visualizationTabPage.Name = "visualizationTabPage"; 101 107 this.visualizationTabPage.Padding = new System.Windows.Forms.Padding(3); 102 this.visualizationTabPage.Size = new System.Drawing.Size( 415, 334);108 this.visualizationTabPage.Size = new System.Drawing.Size(211, 370); 103 109 this.visualizationTabPage.TabIndex = 0; 104 110 this.visualizationTabPage.Text = "Visualization"; … … 111 117 this.valueTabPage.Name = "valueTabPage"; 112 118 this.valueTabPage.Padding = new System.Windows.Forms.Padding(3); 113 this.valueTabPage.Size = new System.Drawing.Size( 415, 300);119 this.valueTabPage.Size = new System.Drawing.Size(251, 370); 114 120 this.valueTabPage.TabIndex = 1; 115 121 this.valueTabPage.Text = "Value"; … … 124 130 this.tourGroupBox.Location = new System.Drawing.Point(6, 6); 125 131 this.tourGroupBox.Name = "tourGroupBox"; 126 this.tourGroupBox.Size = new System.Drawing.Size( 403, 288);132 this.tourGroupBox.Size = new System.Drawing.Size(239, 358); 127 133 this.tourGroupBox.TabIndex = 0; 128 134 this.tourGroupBox.TabStop = false; … … 140 146 this.tourViewHost.Name = "tourViewHost"; 141 147 this.tourViewHost.ReadOnly = false; 142 this.tourViewHost.Size = new System.Drawing.Size( 391, 263);148 this.tourViewHost.Size = new System.Drawing.Size(227, 333); 143 149 this.tourViewHost.TabIndex = 0; 144 150 this.tourViewHost.ViewsLabelVisible = true; … … 148 154 // 149 155 this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill; 156 this.splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; 150 157 this.splitContainer.Location = new System.Drawing.Point(0, 0); 151 158 this.splitContainer.Name = "splitContainer"; 152 this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;153 159 // 154 160 // splitContainer.Panel1 155 161 // 156 162 this.splitContainer.Panel1.Controls.Add(this.qualityGroupBox); 163 this.splitContainer.Panel1.Controls.Add(this.distanceGroupBox); 164 this.splitContainer.Panel1.Controls.Add(this.penaltyGroupBox); 165 this.splitContainer.Panel1.Margin = new System.Windows.Forms.Padding(0, 0, 5, 0); 166 this.splitContainer.Panel1MinSize = 0; 157 167 // 158 168 // splitContainer.Panel2 … … 160 170 this.splitContainer.Panel2.Controls.Add(this.tabControl); 161 171 this.splitContainer.Size = new System.Drawing.Size(423, 402); 162 this.splitContainer.SplitterDistance = 35;172 this.splitContainer.SplitterDistance = 200; 163 173 this.splitContainer.TabIndex = 0; 164 174 // 165 175 // qualityGroupBox 166 176 // 167 this.qualityGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 168 | System.Windows.Forms.AnchorStyles.Left) 177 this.qualityGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 169 178 | System.Windows.Forms.AnchorStyles.Right))); 170 179 this.qualityGroupBox.Controls.Add(this.qualityViewHost); 171 180 this.qualityGroupBox.Location = new System.Drawing.Point(0, 0); 172 181 this.qualityGroupBox.Name = "qualityGroupBox"; 173 this.qualityGroupBox.Size = new System.Drawing.Size( 423, 32);182 this.qualityGroupBox.Size = new System.Drawing.Size(194, 46); 174 183 this.qualityGroupBox.TabIndex = 0; 175 184 this.qualityGroupBox.TabStop = false; … … 178 187 // qualityViewHost 179 188 // 180 this.qualityViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)181 | System.Windows.Forms.AnchorStyles.Left)182 | System.Windows.Forms.AnchorStyles.Right)));183 189 this.qualityViewHost.Caption = "View"; 184 190 this.qualityViewHost.Content = null; 191 this.qualityViewHost.Dock = System.Windows.Forms.DockStyle.Fill; 185 192 this.qualityViewHost.Enabled = false; 186 this.qualityViewHost.Location = new System.Drawing.Point( 6, 19);193 this.qualityViewHost.Location = new System.Drawing.Point(3, 16); 187 194 this.qualityViewHost.Name = "qualityViewHost"; 188 195 this.qualityViewHost.ReadOnly = false; 189 this.qualityViewHost.Size = new System.Drawing.Size( 411,7);196 this.qualityViewHost.Size = new System.Drawing.Size(188, 27); 190 197 this.qualityViewHost.TabIndex = 0; 191 198 this.qualityViewHost.ViewsLabelVisible = true; 192 199 this.qualityViewHost.ViewType = null; 200 // 201 // distanceGroupBox 202 // 203 this.distanceGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 204 | System.Windows.Forms.AnchorStyles.Right))); 205 this.distanceGroupBox.Controls.Add(this.distanceViewHost); 206 this.distanceGroupBox.Location = new System.Drawing.Point(0, 49); 207 this.distanceGroupBox.Name = "distanceGroupBox"; 208 this.distanceGroupBox.Size = new System.Drawing.Size(194, 46); 209 this.distanceGroupBox.TabIndex = 1; 210 this.distanceGroupBox.TabStop = false; 211 this.distanceGroupBox.Text = "Distance"; 212 // 213 // distanceViewHost 214 // 215 this.distanceViewHost.Caption = "View"; 216 this.distanceViewHost.Content = null; 217 this.distanceViewHost.Dock = System.Windows.Forms.DockStyle.Fill; 218 this.distanceViewHost.Enabled = false; 219 this.distanceViewHost.Location = new System.Drawing.Point(3, 16); 220 this.distanceViewHost.Name = "distanceViewHost"; 221 this.distanceViewHost.ReadOnly = false; 222 this.distanceViewHost.Size = new System.Drawing.Size(188, 27); 223 this.distanceViewHost.TabIndex = 0; 224 this.distanceViewHost.ViewsLabelVisible = true; 225 this.distanceViewHost.ViewType = null; 226 // 227 // penaltyGroupBox 228 // 229 this.penaltyGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 230 | System.Windows.Forms.AnchorStyles.Right))); 231 this.penaltyGroupBox.Controls.Add(this.penaltyViewHost); 232 this.penaltyGroupBox.Location = new System.Drawing.Point(0, 101); 233 this.penaltyGroupBox.Name = "penaltyGroupBox"; 234 this.penaltyGroupBox.Size = new System.Drawing.Size(194, 46); 235 this.penaltyGroupBox.TabIndex = 2; 236 this.penaltyGroupBox.TabStop = false; 237 this.penaltyGroupBox.Text = "Penalty"; 238 // 239 // penaltyViewHost 240 // 241 this.penaltyViewHost.Caption = "View"; 242 this.penaltyViewHost.Content = null; 243 this.penaltyViewHost.Dock = System.Windows.Forms.DockStyle.Fill; 244 this.penaltyViewHost.Enabled = false; 245 this.penaltyViewHost.Location = new System.Drawing.Point(3, 16); 246 this.penaltyViewHost.Name = "penaltyViewHost"; 247 this.penaltyViewHost.ReadOnly = false; 248 this.penaltyViewHost.Size = new System.Drawing.Size(188, 27); 249 this.penaltyViewHost.TabIndex = 0; 250 this.penaltyViewHost.ViewsLabelVisible = true; 251 this.penaltyViewHost.ViewType = null; 193 252 // 194 253 // OrienteeringSolutionView … … 208 267 this.splitContainer.ResumeLayout(false); 209 268 this.qualityGroupBox.ResumeLayout(false); 269 this.distanceGroupBox.ResumeLayout(false); 270 this.penaltyGroupBox.ResumeLayout(false); 210 271 this.ResumeLayout(false); 211 272 … … 223 284 private System.Windows.Forms.GroupBox qualityGroupBox; 224 285 private HeuristicLab.MainForm.WindowsForms.ViewHost qualityViewHost; 286 private System.Windows.Forms.GroupBox distanceGroupBox; 287 private MainForm.WindowsForms.ViewHost distanceViewHost; 288 private System.Windows.Forms.GroupBox penaltyGroupBox; 289 private MainForm.WindowsForms.ViewHost penaltyViewHost; 225 290 } 226 291 } -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering.Views/3.3/OrienteeringSolutionView.cs
r11325 r11327 43 43 Content.QualityChanged -= new EventHandler(Content_QualityChanged); 44 44 Content.PenaltyChanged -= new EventHandler(Content_PenaltyChanged); 45 Content.DistanceChanged -= new EventHandler(Content_DistanceChanged); 45 46 Content.CoordinatesChanged -= new EventHandler(Content_CoordinatesChanged); 46 47 Content.StartingPointChanged -= new EventHandler(Content_StartingPointChanged); … … 54 55 Content.QualityChanged += new EventHandler(Content_QualityChanged); 55 56 Content.PenaltyChanged += new EventHandler(Content_PenaltyChanged); 57 Content.DistanceChanged += new EventHandler(Content_DistanceChanged); 56 58 Content.CoordinatesChanged += new EventHandler(Content_CoordinatesChanged); 57 59 Content.StartingPointChanged += new EventHandler(Content_StartingPointChanged); … … 65 67 if (Content == null) { 66 68 qualityViewHost.Content = null; 69 penaltyViewHost.Content = null; 70 distanceViewHost.Content = null; 67 71 pictureBox.Image = null; 68 72 tourViewHost.Content = null; 69 73 } else { 70 74 qualityViewHost.Content = Content.Quality; 75 penaltyViewHost.Content = Content.Penalty; 76 distanceViewHost.Content = Content.Distance; 71 77 GenerateImage(); 72 78 tourViewHost.Content = Content.IntegerVector; … … 77 83 base.SetEnabledStateOfControls(); 78 84 qualityGroupBox.Enabled = Content != null; 85 penaltyGroupBox.Enabled = Content != null; 86 distanceGroupBox.Enabled = Content != null; 79 87 pictureBox.Enabled = Content != null; 80 88 tourGroupBox.Enabled = Content != null; … … 162 170 if (InvokeRequired) 163 171 Invoke(new EventHandler(Content_PenaltyChanged), sender, e); 164 else 165 GenerateImage(); 172 else { 173 penaltyViewHost.Content = Content.Penalty; 174 GenerateImage(); 175 } 176 } 177 178 private void Content_DistanceChanged(object sender, EventArgs e) { 179 if (InvokeRequired) 180 Invoke(new EventHandler(Content_DistanceChanged), sender, e); 181 else 182 distanceViewHost.Content = Content.Distance; 166 183 } 167 184 private void Content_CoordinatesChanged(object sender, EventArgs e) { -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/Analyzers/BestOrienteeringSolutionAnalyser.cs
r11319 r11327 39 39 get { return (IScopeTreeLookupParameter<IntegerVector>)Parameters["IntegerVector"]; } 40 40 } 41 public LookupParameter<DoubleMatrix> CoordinatesParameter { 42 get { return (LookupParameter<DoubleMatrix>)Parameters["Coordinates"]; } 41 public ILookupParameter<DoubleMatrix> CoordinatesParameter { 42 get { return (ILookupParameter<DoubleMatrix>)Parameters["Coordinates"]; } 43 } 44 public ILookupParameter<DistanceMatrix> DistanceMatrixParameter { 45 get { return (ILookupParameter<DistanceMatrix>)Parameters["DistanceMatrix"]; } 43 46 } 44 47 public ILookupParameter<IntValue> StartingPointParameter { … … 51 54 get { return (ILookupParameter<DoubleArray>)Parameters["Scores"]; } 52 55 } 56 public ILookupParameter<DoubleValue> PointVisitingCostsParameter { 57 get { return (ILookupParameter<DoubleValue>)Parameters["PointVisitingCosts"]; } 58 } 53 59 54 public ScopeTreeLookupParameter<DoubleValue> QualityParameter {55 get { return ( ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }60 public IScopeTreeLookupParameter<DoubleValue> QualityParameter { 61 get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; } 56 62 } 57 public ScopeTreeLookupParameter<DoubleValue> PenaltyParameter {58 get { return ( ScopeTreeLookupParameter<DoubleValue>)Parameters["Penalty"]; }63 public IScopeTreeLookupParameter<DoubleValue> PenaltyParameter { 64 get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Penalty"]; } 59 65 } 60 public LookupParameter<OrienteeringSolution> BestSolutionParameter {61 get { return ( LookupParameter<OrienteeringSolution>)Parameters["BestSolution"]; }66 public ILookupParameter<OrienteeringSolution> BestSolutionParameter { 67 get { return (ILookupParameter<OrienteeringSolution>)Parameters["BestSolution"]; } 62 68 } 63 public ValueLookupParameter<ResultCollection> ResultsParameter {64 get { return ( ValueLookupParameter<ResultCollection>)Parameters["Results"]; }69 public IValueLookupParameter<ResultCollection> ResultsParameter { 70 get { return (IValueLookupParameter<ResultCollection>)Parameters["Results"]; } 65 71 } 66 public LookupParameter<DoubleValue> BestKnownQualityParameter {67 get { return ( LookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }72 public ILookupParameter<DoubleValue> BestKnownQualityParameter { 73 get { return (ILookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; } 68 74 } 69 public LookupParameter<IntegerVector> BestKnownSolutionParameter { 70 get { return (LookupParameter<IntegerVector>)Parameters["BestKnownSolution"]; } 71 } 72 public LookupParameter<DoubleValue> BestKnownSolutionPenaltyParameter { 73 get { return (LookupParameter<DoubleValue>)Parameters["BestKnownSolutionPenalty"]; } 75 public ILookupParameter<IntegerVector> BestKnownSolutionParameter { 76 get { return (ILookupParameter<IntegerVector>)Parameters["BestKnownSolution"]; } 74 77 } 75 78 … … 84 87 Parameters.Add(new ScopeTreeLookupParameter<IntegerVector>("IntegerVector", "The Orienteering solutions which should be analysed.")); 85 88 Parameters.Add(new LookupParameter<DoubleMatrix>("Coordinates", "The x- and y-Coordinates of the points.")); 89 Parameters.Add(new LookupParameter<DistanceMatrix>("DistanceMatrix", "The matrix which contains the distances between the points.")); 86 90 Parameters.Add(new LookupParameter<IntValue>("StartingPoint", "Index of the starting point.")); 87 91 Parameters.Add(new LookupParameter<IntValue>("TerminalPoint", "Index of the ending point.")); 88 92 Parameters.Add(new LookupParameter<DoubleArray>("Scores", "The scores of the points.")); 93 Parameters.Add(new LookupParameter<DoubleValue>("PointVisitingCosts", "The costs for visiting a point.")); 89 94 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the Orienteering solutions which should be analyzed.")); 90 95 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Penalty", "The applied penalty of the Orienteering solutions.")); … … 93 98 Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this Orienteering instance.")); 94 99 Parameters.Add(new LookupParameter<IntegerVector>("BestKnownSolution", "The best known solution of this Orienteering instance.")); 95 Parameters.Add(new LookupParameter<DoubleValue>("BestKnownSolutionPenalty", "The penalty of the best known solution of this Orienteering instance."));96 100 } 97 101 … … 108 112 BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[bestIndex].Value); 109 113 BestKnownSolutionParameter.ActualValue = (IntegerVector)solutions[bestIndex].Clone(); 110 BestKnownSolutionPenaltyParameter.ActualValue = new DoubleValue(penalties[bestIndex].Value);111 114 } 112 115 … … 116 119 var terminalPoint = TerminalPointParameter.ActualValue; 117 120 var scores = ScoresParameter.ActualValue; 121 var pointVisitingCosts = PointVisitingCostsParameter.ActualValue; 122 var distances = DistanceMatrixParameter.ActualValue; 123 double distance = distances.CalculateTourLength(solutions[bestIndex].ToList(), pointVisitingCosts.Value); 124 118 125 if (solution == null) { 119 126 solution = new OrienteeringSolution( … … 124 131 scores, 125 132 new DoubleValue(qualities[bestIndex].Value), 126 new DoubleValue(penalties[bestIndex].Value)); 133 new DoubleValue(penalties[bestIndex].Value), 134 new DoubleValue(distance)); 127 135 BestSolutionParameter.ActualValue = solution; 128 136 results.Add(new Result("Best Orienteering Solution", solution)); 129 results.Add(new Result("BestKnownSolutionPenalty", solution.Penalty));130 137 } else { 131 138 if (solution.Quality.Value < qualities[bestIndex].Value) { … … 135 142 solution.Quality.Value = qualities[bestIndex].Value; 136 143 solution.Penalty.Value = penalties[bestIndex].Value; 137 results["BestKnownSolutionPenalty"].Value = solution.Penalty;144 solution.Distance.Value = distance; 138 145 } 139 146 } -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/Evaluators/OrienteeringEvaluator.cs
r11320 r11327 21 21 22 22 using System.Linq; 23 using System.Security.Permissions;24 23 using HeuristicLab.Common; 25 24 using HeuristicLab.Core; … … 83 82 } 84 83 85 public class OrienteeringEvaluation {86 public DoubleValue Quality;87 public DoubleValue Penalty;88 }89 90 84 public static OrienteeringEvaluation Apply(IntegerVector solution, DoubleArray scores, 91 DistanceMatrix distances, DoubleValue maximumDistance, DoubleValue pointVisitingCosts, DoubleValue distancePenaltyFactor) {85 DistanceMatrix distances, double maximumDistance, double pointVisitingCosts, double distancePenaltyFactor) { 92 86 93 87 double score = solution.Sum(t => scores[t]); 94 double distance = distances.CalculateTourLength(solution.ToList(), pointVisitingCosts .Value);88 double distance = distances.CalculateTourLength(solution.ToList(), pointVisitingCosts); 95 89 96 double distanceViolation = distance - maximumDistance .Value;90 double distanceViolation = distance - maximumDistance; 97 91 98 92 double penalty = 0.0; 99 penalty += distanceViolation > 0 ? distanceViolation * distancePenaltyFactor .Value: 0;93 penalty += distanceViolation > 0 ? distanceViolation * distancePenaltyFactor : 0; 100 94 101 95 double quality = score - penalty; … … 103 97 return new OrienteeringEvaluation { 104 98 Quality = new DoubleValue(quality), 105 Penalty = new DoubleValue(penalty) 99 Penalty = new DoubleValue(penalty), 100 Distance = new DoubleValue(distance) 106 101 }; 107 102 } … … 109 104 public override IOperation InstrumentedApply() { 110 105 var evaluation = Apply(IntegerVectorParameter.ActualValue, ScoresParameter.ActualValue, 111 DistanceMatrixParameter.ActualValue, MaximumDistanceParameter.ActualValue ,112 PointVisitingCostsParameter.ActualValue , DistancePenaltyFactorParameter.ActualValue);106 DistanceMatrixParameter.ActualValue, MaximumDistanceParameter.ActualValue.Value, 107 PointVisitingCostsParameter.ActualValue.Value, DistancePenaltyFactorParameter.ActualValue.Value); 113 108 114 109 QualityParameter.ActualValue = evaluation.Quality; … … 117 112 return base.InstrumentedApply(); 118 113 } 114 115 public OrienteeringEvaluation Evaluate(IntegerVector solution, DoubleArray scores, 116 DistanceMatrix distances, double maximumDistance, double pointVisitingCosts) { 117 return Apply(solution, scores, distances, maximumDistance, pointVisitingCosts, 118 ((IValueParameter<DoubleValue>)DistancePenaltyFactorParameter).Value.Value); 119 } 119 120 } 120 121 } -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/HeuristicLab.Problems.Orienteering-3.3.csproj
r11321 r11327 85 85 <Compile Include="Creators\GreedyOrienteeringTourCreator.cs" /> 86 86 <Compile Include="DistanceMatrix.cs" /> 87 <Compile Include="OrienteeringEvaluation.cs" /> 87 88 <Compile Include="Improvers\OrienteeringLocalImprovementOperator.cs" /> 88 89 <Compile Include="Interfaces\IOrienteeringEvaluator.cs" /> -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/Interfaces/IOrienteeringEvaluator.cs
r11321 r11327 33 33 ILookupParameter<DoubleValue> PointVisitingCostsParameter { get; } 34 34 ILookupParameter<DoubleValue> PenaltyParameter { get; } 35 36 OrienteeringEvaluation Evaluate(IntegerVector solution, DoubleArray scores, 37 DistanceMatrix distances, double maximumDistance, double pointVisitingCosts); 35 38 } 36 39 } -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/OrienteeringSolution.cs
r11319 r11327 103 103 if (penalty != null) RegisterPenaltyEvents(); 104 104 OnPenaltyChanged(); 105 } 106 } 107 } 108 [Storable] 109 private DoubleValue distance; 110 public DoubleValue Distance { 111 get { return distance; } 112 set { 113 if (distance != value) { 114 if (distance != null) DeregisterDistanceEvents(); 115 distance = value; 116 if (distance != null) RegisterDistanceEvents(); 117 OnDistanceChanged(); 105 118 } 106 119 } … … 119 132 } 120 133 public OrienteeringSolution(IntegerVector integerVector, DoubleMatrix coordinates, IntValue startingPoint, IntValue terminalPoint, 121 DoubleArray scores, DoubleValue quality , DoubleValue penalty)134 DoubleArray scores, DoubleValue quality = null, DoubleValue penalty = null, DoubleValue distance = null) 122 135 : base() { 123 136 this.integerVector = integerVector; … … 128 141 this.quality = quality; 129 142 this.penalty = penalty; 143 this.distance = distance; 130 144 Initialize(); 131 145 } … … 148 162 if (quality != null) RegisterQualityEvents(); 149 163 if (penalty != null) RegisterPenaltyEvents(); 164 if (distance != null) RegisterDistanceEvents(); 150 165 } 151 166 … … 200 215 } 201 216 217 public event EventHandler DistanceChanged; 218 private void OnDistanceChanged() { 219 var changed = DistanceChanged; 220 if (changed != null) 221 changed(this, EventArgs.Empty); 222 } 223 202 224 private void RegisterIntegerVectorEvents() { 203 225 IntegerVector.ItemChanged += new EventHandler<EventArgs<int>>(IntegerVector_ItemChanged); … … 248 270 Penalty.ValueChanged -= new EventHandler(Penalty_ValueChanged); 249 271 } 272 private void RegisterDistanceEvents() { 273 Distance.ValueChanged += new EventHandler(Distance_ValueChanged); 274 } 275 private void DeregisterDistanceEvents() { 276 Distance.ValueChanged -= new EventHandler(Distance_ValueChanged); 277 } 250 278 251 279 private void IntegerVector_ItemChanged(object sender, EventArgs<int> e) { … … 278 306 private void Penalty_ValueChanged(object sender, EventArgs e) { 279 307 OnPenaltyChanged(); 308 } 309 private void Distance_ValueChanged(object sender, EventArgs e) { 310 OnDistanceChanged(); 280 311 } 281 312 #endregion
Note: See TracChangeset
for help on using the changeset viewer.