Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11327


Ignore:
Timestamp:
09/02/14 13:09:59 (10 years ago)
Author:
pfleck
Message:

#2208

  • Added distance and penalty visualization for orienteering solution.
  • Added Evaluate method in IOrienteeringEvaluator for evaluation of new best solutions (still need some design improvements).
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  
    6262        orienteeringSolutionView.Content = null;
    6363      } 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        }
    6669      }
    6770    }
     
    8992    private void BestKnownSolutionParameter_ValueChanged(object sender, EventArgs e) {
    9093      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;
    91109    }
    92110  }
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering.Views/3.3/OrienteeringSolutionView.Designer.cs

    r11240 r11327  
    5454      this.qualityGroupBox = new System.Windows.Forms.GroupBox();
    5555      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();
    5660      ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
    5761      this.tabControl.SuspendLayout();
     
    6468      this.splitContainer.SuspendLayout();
    6569      this.qualityGroupBox.SuspendLayout();
     70      this.distanceGroupBox.SuspendLayout();
     71      this.penaltyGroupBox.SuspendLayout();
    6672      this.SuspendLayout();
    6773      //
     
    7581      this.pictureBox.Location = new System.Drawing.Point(6, 6);
    7682      this.pictureBox.Name = "pictureBox";
    77       this.pictureBox.Size = new System.Drawing.Size(403, 322);
     83      this.pictureBox.Size = new System.Drawing.Size(199, 362);
    7884      this.pictureBox.TabIndex = 0;
    7985      this.pictureBox.TabStop = false;
     
    9197      this.tabControl.Name = "tabControl";
    9298      this.tabControl.SelectedIndex = 0;
    93       this.tabControl.Size = new System.Drawing.Size(423, 360);
     99      this.tabControl.Size = new System.Drawing.Size(219, 396);
    94100      this.tabControl.TabIndex = 0;
    95101      //
     
    100106      this.visualizationTabPage.Name = "visualizationTabPage";
    101107      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);
    103109      this.visualizationTabPage.TabIndex = 0;
    104110      this.visualizationTabPage.Text = "Visualization";
     
    111117      this.valueTabPage.Name = "valueTabPage";
    112118      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);
    114120      this.valueTabPage.TabIndex = 1;
    115121      this.valueTabPage.Text = "Value";
     
    124130      this.tourGroupBox.Location = new System.Drawing.Point(6, 6);
    125131      this.tourGroupBox.Name = "tourGroupBox";
    126       this.tourGroupBox.Size = new System.Drawing.Size(403, 288);
     132      this.tourGroupBox.Size = new System.Drawing.Size(239, 358);
    127133      this.tourGroupBox.TabIndex = 0;
    128134      this.tourGroupBox.TabStop = false;
     
    140146      this.tourViewHost.Name = "tourViewHost";
    141147      this.tourViewHost.ReadOnly = false;
    142       this.tourViewHost.Size = new System.Drawing.Size(391, 263);
     148      this.tourViewHost.Size = new System.Drawing.Size(227, 333);
    143149      this.tourViewHost.TabIndex = 0;
    144150      this.tourViewHost.ViewsLabelVisible = true;
     
    148154      //
    149155      this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
     156      this.splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
    150157      this.splitContainer.Location = new System.Drawing.Point(0, 0);
    151158      this.splitContainer.Name = "splitContainer";
    152       this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
    153159      //
    154160      // splitContainer.Panel1
    155161      //
    156162      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;
    157167      //
    158168      // splitContainer.Panel2
     
    160170      this.splitContainer.Panel2.Controls.Add(this.tabControl);
    161171      this.splitContainer.Size = new System.Drawing.Size(423, 402);
    162       this.splitContainer.SplitterDistance = 35;
     172      this.splitContainer.SplitterDistance = 200;
    163173      this.splitContainer.TabIndex = 0;
    164174      //
    165175      // qualityGroupBox
    166176      //
    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)
    169178            | System.Windows.Forms.AnchorStyles.Right)));
    170179      this.qualityGroupBox.Controls.Add(this.qualityViewHost);
    171180      this.qualityGroupBox.Location = new System.Drawing.Point(0, 0);
    172181      this.qualityGroupBox.Name = "qualityGroupBox";
    173       this.qualityGroupBox.Size = new System.Drawing.Size(423, 32);
     182      this.qualityGroupBox.Size = new System.Drawing.Size(194, 46);
    174183      this.qualityGroupBox.TabIndex = 0;
    175184      this.qualityGroupBox.TabStop = false;
     
    178187      // qualityViewHost
    179188      //
    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)));
    183189      this.qualityViewHost.Caption = "View";
    184190      this.qualityViewHost.Content = null;
     191      this.qualityViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
    185192      this.qualityViewHost.Enabled = false;
    186       this.qualityViewHost.Location = new System.Drawing.Point(6, 19);
     193      this.qualityViewHost.Location = new System.Drawing.Point(3, 16);
    187194      this.qualityViewHost.Name = "qualityViewHost";
    188195      this.qualityViewHost.ReadOnly = false;
    189       this.qualityViewHost.Size = new System.Drawing.Size(411, 7);
     196      this.qualityViewHost.Size = new System.Drawing.Size(188, 27);
    190197      this.qualityViewHost.TabIndex = 0;
    191198      this.qualityViewHost.ViewsLabelVisible = true;
    192199      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;
    193252      //
    194253      // OrienteeringSolutionView
     
    208267      this.splitContainer.ResumeLayout(false);
    209268      this.qualityGroupBox.ResumeLayout(false);
     269      this.distanceGroupBox.ResumeLayout(false);
     270      this.penaltyGroupBox.ResumeLayout(false);
    210271      this.ResumeLayout(false);
    211272
     
    223284    private System.Windows.Forms.GroupBox qualityGroupBox;
    224285    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;
    225290  }
    226291}
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering.Views/3.3/OrienteeringSolutionView.cs

    r11325 r11327  
    4343      Content.QualityChanged -= new EventHandler(Content_QualityChanged);
    4444      Content.PenaltyChanged -= new EventHandler(Content_PenaltyChanged);
     45      Content.DistanceChanged -= new EventHandler(Content_DistanceChanged);
    4546      Content.CoordinatesChanged -= new EventHandler(Content_CoordinatesChanged);
    4647      Content.StartingPointChanged -= new EventHandler(Content_StartingPointChanged);
     
    5455      Content.QualityChanged += new EventHandler(Content_QualityChanged);
    5556      Content.PenaltyChanged += new EventHandler(Content_PenaltyChanged);
     57      Content.DistanceChanged += new EventHandler(Content_DistanceChanged);
    5658      Content.CoordinatesChanged += new EventHandler(Content_CoordinatesChanged);
    5759      Content.StartingPointChanged += new EventHandler(Content_StartingPointChanged);
     
    6567      if (Content == null) {
    6668        qualityViewHost.Content = null;
     69        penaltyViewHost.Content = null;
     70        distanceViewHost.Content = null;
    6771        pictureBox.Image = null;
    6872        tourViewHost.Content = null;
    6973      } else {
    7074        qualityViewHost.Content = Content.Quality;
     75        penaltyViewHost.Content = Content.Penalty;
     76        distanceViewHost.Content = Content.Distance;
    7177        GenerateImage();
    7278        tourViewHost.Content = Content.IntegerVector;
     
    7783      base.SetEnabledStateOfControls();
    7884      qualityGroupBox.Enabled = Content != null;
     85      penaltyGroupBox.Enabled = Content != null;
     86      distanceGroupBox.Enabled = Content != null;
    7987      pictureBox.Enabled = Content != null;
    8088      tourGroupBox.Enabled = Content != null;
     
    162170      if (InvokeRequired)
    163171        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;
    166183    }
    167184    private void Content_CoordinatesChanged(object sender, EventArgs e) {
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/Analyzers/BestOrienteeringSolutionAnalyser.cs

    r11319 r11327  
    3939      get { return (IScopeTreeLookupParameter<IntegerVector>)Parameters["IntegerVector"]; }
    4040    }
    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"]; }
    4346    }
    4447    public ILookupParameter<IntValue> StartingPointParameter {
     
    5154      get { return (ILookupParameter<DoubleArray>)Parameters["Scores"]; }
    5255    }
     56    public ILookupParameter<DoubleValue> PointVisitingCostsParameter {
     57      get { return (ILookupParameter<DoubleValue>)Parameters["PointVisitingCosts"]; }
     58    }
    5359
    54     public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
    55       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
     60    public IScopeTreeLookupParameter<DoubleValue> QualityParameter {
     61      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
    5662    }
    57     public ScopeTreeLookupParameter<DoubleValue> PenaltyParameter {
    58       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Penalty"]; }
     63    public IScopeTreeLookupParameter<DoubleValue> PenaltyParameter {
     64      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Penalty"]; }
    5965    }
    60     public LookupParameter<OrienteeringSolution> BestSolutionParameter {
    61       get { return (LookupParameter<OrienteeringSolution>)Parameters["BestSolution"]; }
     66    public ILookupParameter<OrienteeringSolution> BestSolutionParameter {
     67      get { return (ILookupParameter<OrienteeringSolution>)Parameters["BestSolution"]; }
    6268    }
    63     public ValueLookupParameter<ResultCollection> ResultsParameter {
    64       get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; }
     69    public IValueLookupParameter<ResultCollection> ResultsParameter {
     70      get { return (IValueLookupParameter<ResultCollection>)Parameters["Results"]; }
    6571    }
    66     public LookupParameter<DoubleValue> BestKnownQualityParameter {
    67       get { return (LookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
     72    public ILookupParameter<DoubleValue> BestKnownQualityParameter {
     73      get { return (ILookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
    6874    }
    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"]; }
    7477    }
    7578
     
    8487      Parameters.Add(new ScopeTreeLookupParameter<IntegerVector>("IntegerVector", "The Orienteering solutions which should be analysed."));
    8588      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."));
    8690      Parameters.Add(new LookupParameter<IntValue>("StartingPoint", "Index of the starting point."));
    8791      Parameters.Add(new LookupParameter<IntValue>("TerminalPoint", "Index of the ending point."));
    8892      Parameters.Add(new LookupParameter<DoubleArray>("Scores", "The scores of the points."));
     93      Parameters.Add(new LookupParameter<DoubleValue>("PointVisitingCosts", "The costs for visiting a point."));
    8994      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the Orienteering solutions which should be analyzed."));
    9095      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Penalty", "The applied penalty of the Orienteering solutions."));
     
    9398      Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this Orienteering instance."));
    9499      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."));
    96100    }
    97101
     
    108112        BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[bestIndex].Value);
    109113        BestKnownSolutionParameter.ActualValue = (IntegerVector)solutions[bestIndex].Clone();
    110         BestKnownSolutionPenaltyParameter.ActualValue = new DoubleValue(penalties[bestIndex].Value);
    111114      }
    112115
     
    116119      var terminalPoint = TerminalPointParameter.ActualValue;
    117120      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
    118125      if (solution == null) {
    119126        solution = new OrienteeringSolution(
     
    124131          scores,
    125132          new DoubleValue(qualities[bestIndex].Value),
    126           new DoubleValue(penalties[bestIndex].Value));
     133          new DoubleValue(penalties[bestIndex].Value),
     134          new DoubleValue(distance));
    127135        BestSolutionParameter.ActualValue = solution;
    128136        results.Add(new Result("Best Orienteering Solution", solution));
    129         results.Add(new Result("BestKnownSolutionPenalty", solution.Penalty));
    130137      } else {
    131138        if (solution.Quality.Value < qualities[bestIndex].Value) {
     
    135142          solution.Quality.Value = qualities[bestIndex].Value;
    136143          solution.Penalty.Value = penalties[bestIndex].Value;
    137           results["BestKnownSolutionPenalty"].Value = solution.Penalty;
     144          solution.Distance.Value = distance;
    138145        }
    139146      }
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/Evaluators/OrienteeringEvaluator.cs

    r11320 r11327  
    2121
    2222using System.Linq;
    23 using System.Security.Permissions;
    2423using HeuristicLab.Common;
    2524using HeuristicLab.Core;
     
    8382    }
    8483
    85     public class OrienteeringEvaluation {
    86       public DoubleValue Quality;
    87       public DoubleValue Penalty;
    88     }
    89 
    9084    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) {
    9286
    9387      double score = solution.Sum(t => scores[t]);
    94       double distance = distances.CalculateTourLength(solution.ToList(), pointVisitingCosts.Value);
     88      double distance = distances.CalculateTourLength(solution.ToList(), pointVisitingCosts);
    9589
    96       double distanceViolation = distance - maximumDistance.Value;
     90      double distanceViolation = distance - maximumDistance;
    9791
    9892      double penalty = 0.0;
    99       penalty += distanceViolation > 0 ? distanceViolation * distancePenaltyFactor.Value : 0;
     93      penalty += distanceViolation > 0 ? distanceViolation * distancePenaltyFactor : 0;
    10094
    10195      double quality = score - penalty;
     
    10397      return new OrienteeringEvaluation {
    10498        Quality = new DoubleValue(quality),
    105         Penalty = new DoubleValue(penalty)
     99        Penalty = new DoubleValue(penalty),
     100        Distance = new DoubleValue(distance)
    106101      };
    107102    }
     
    109104    public override IOperation InstrumentedApply() {
    110105      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);
    113108
    114109      QualityParameter.ActualValue = evaluation.Quality;
     
    117112      return base.InstrumentedApply();
    118113    }
     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    }
    119120  }
    120121}
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/HeuristicLab.Problems.Orienteering-3.3.csproj

    r11321 r11327  
    8585    <Compile Include="Creators\GreedyOrienteeringTourCreator.cs" />
    8686    <Compile Include="DistanceMatrix.cs" />
     87    <Compile Include="OrienteeringEvaluation.cs" />
    8788    <Compile Include="Improvers\OrienteeringLocalImprovementOperator.cs" />
    8889    <Compile Include="Interfaces\IOrienteeringEvaluator.cs" />
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/Interfaces/IOrienteeringEvaluator.cs

    r11321 r11327  
    3333    ILookupParameter<DoubleValue> PointVisitingCostsParameter { get; }
    3434    ILookupParameter<DoubleValue> PenaltyParameter { get; }
     35
     36    OrienteeringEvaluation Evaluate(IntegerVector solution, DoubleArray scores,
     37      DistanceMatrix distances, double maximumDistance, double pointVisitingCosts);
    3538  }
    3639}
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/OrienteeringSolution.cs

    r11319 r11327  
    103103          if (penalty != null) RegisterPenaltyEvents();
    104104          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();
    105118        }
    106119      }
     
    119132    }
    120133    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)
    122135      : base() {
    123136      this.integerVector = integerVector;
     
    128141      this.quality = quality;
    129142      this.penalty = penalty;
     143      this.distance = distance;
    130144      Initialize();
    131145    }
     
    148162      if (quality != null) RegisterQualityEvents();
    149163      if (penalty != null) RegisterPenaltyEvents();
     164      if (distance != null) RegisterDistanceEvents();
    150165    }
    151166
     
    200215    }
    201216
     217    public event EventHandler DistanceChanged;
     218    private void OnDistanceChanged() {
     219      var changed = DistanceChanged;
     220      if (changed != null)
     221        changed(this, EventArgs.Empty);
     222    }
     223
    202224    private void RegisterIntegerVectorEvents() {
    203225      IntegerVector.ItemChanged += new EventHandler<EventArgs<int>>(IntegerVector_ItemChanged);
     
    248270      Penalty.ValueChanged -= new EventHandler(Penalty_ValueChanged);
    249271    }
     272    private void RegisterDistanceEvents() {
     273      Distance.ValueChanged += new EventHandler(Distance_ValueChanged);
     274    }
     275    private void DeregisterDistanceEvents() {
     276      Distance.ValueChanged -= new EventHandler(Distance_ValueChanged);
     277    }
    250278
    251279    private void IntegerVector_ItemChanged(object sender, EventArgs<int> e) {
     
    278306    private void Penalty_ValueChanged(object sender, EventArgs e) {
    279307      OnPenaltyChanged();
     308    }
     309    private void Distance_ValueChanged(object sender, EventArgs e) {
     310      OnDistanceChanged();
    280311    }
    281312    #endregion
Note: See TracChangeset for help on using the changeset viewer.