Changeset 11320


Ignore:
Timestamp:
09/01/14 10:36:54 (7 years ago)
Author:
pfleck
Message:

#2208 Renamed FixedPenalty to PointVisitingCosts

Location:
branches/HeuristicLab.Problems.Orienteering
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Instances/3.3/Types/OPData.cs

    r11319 r11320  
    3737    /// The penalty for each visited vertex.
    3838    /// </summary>
    39     public double FixedPenalty { get; set; }
     39    public double PointVisitingCosts { get; set; }
    4040    /// <summary>
    4141    /// Index of the starting point
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/Creators/GreedyOrienteeringTourCreator.cs

    r11319 r11320  
    5555      get { return (ILookupParameter<IntValue>)Parameters["TerminalPoint"]; }
    5656    }
    57     public ILookupParameter<DoubleValue> FixedPenaltyParameter {
    58       get { return (ILookupParameter<DoubleValue>)Parameters["FixedPenalty"]; }
     57    public ILookupParameter<DoubleValue> PointVisitingCostsParameter {
     58      get { return (ILookupParameter<DoubleValue>)Parameters["PointVisitingCosts"]; }
    5959    }
    6060    #endregion
     
    7373      Parameters.Add(new LookupParameter<IntValue>("StartingPoint", "Index of the starting point."));
    7474      Parameters.Add(new LookupParameter<IntValue>("TerminalPoint", "Index of the ending point."));
    75       Parameters.Add(new LookupParameter<DoubleValue>("FixedPenalty", "The penalty for each visited vertex."));
     75      Parameters.Add(new LookupParameter<DoubleValue>("PointVisitingCosts", "The costs for visiting a point."));
    7676    }
    7777
     
    8585      int numPoints = ScoresParameter.ActualValue.Length;
    8686      var distances = DistanceMatrixParameter.ActualValue;
    87       double fixedPenalty = FixedPenaltyParameter.ActualValue.Value;
     87      double pointVisitingCosts = PointVisitingCostsParameter.ActualValue.Value;
    8888      double maxDistance = MaximumDistanceParameter.ActualValue.Value;
    8989      var scores = ScoresParameter.ActualValue;
     
    9292      var feasiblePoints = (
    9393        from point in Enumerable.Range(0, numPoints)
    94         let distance = distances[startPoint, point] + distances[point, endPoint] + fixedPenalty
     94        let distance = distances[startPoint, point] + distances[point, endPoint] + pointVisitingCosts
    9595        let score = scores[point]
    9696        where distance <= maxDistance
     
    115115          for (int insertPosition = 1; insertPosition < tour.Count; insertPosition++) {
    116116            // Create the candidate tour
    117             double detour = distances.CalculateInsertionCosts(tour, insertPosition, feasiblePoints[i], fixedPenalty);
     117            double detour = distances.CalculateInsertionCosts(tour, insertPosition, feasiblePoints[i], pointVisitingCosts);
    118118
    119119            // If the insertion would be feasible, perform it
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/DistanceMatrix.cs

    r11228 r11320  
    5353    }
    5454
    55     public double CalculateTourLength(IList<int> path, double fixedPenalty) {
     55    public double CalculateTourLength(IList<int> path, double pointVisitingCosts) {
    5656      double length = 0.0;
    5757      for (int i = 1; i < path.Count; i++)
    5858        length += this[path[i - 1], path[i]];
    5959      // Add the fixed penalty for every vertex except for the starting and ending vertex
    60       length += (path.Count - 2) * fixedPenalty;
     60      length += (path.Count - 2) * pointVisitingCosts;
    6161      return length;
    6262    }
    63     public double CalculateInsertionCosts(IList<int> path, int insertPosition, int point, double fixedPenalty) {
     63    public double CalculateInsertionCosts(IList<int> path, int insertPosition, int point, double pointVisitingCosts) {
    6464      double detour = this[path[insertPosition - 1], point] + this[point, path[insertPosition]];
    65       detour += fixedPenalty;
     65      detour += pointVisitingCosts;
    6666      detour -= this[path[insertPosition - 1], path[insertPosition]];
    6767      return detour;
     
    7272      return detour;
    7373    }
    74     public double CalculateRemovementSaving(List<int> path, int removePosition, double fixedPenalty) {
     74    public double CalculateRemovementSaving(List<int> path, int removePosition, double pointVisitingCosts) {
    7575      double saving = this[path[removePosition - 1], path[removePosition]];
    7676      saving += this[path[removePosition], path[removePosition + 1]];
    7777      saving -= this[path[removePosition - 1], path[removePosition + 1]];
    78       saving += fixedPenalty;
     78      saving += pointVisitingCosts;
    7979      return saving;
    8080    }
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/Evaluators/OrienteeringEvaluator.cs

    r11311 r11320  
    5555      get { return (ILookupParameter<DoubleValue>)Parameters["MaximumDistance"]; }
    5656    }
    57     public ILookupParameter<DoubleValue> FixedPenaltyParameter {
    58       get { return (ILookupParameter<DoubleValue>)Parameters["FixedPenalty"]; }
     57    public ILookupParameter<DoubleValue> PointVisitingCostsParameter {
     58      get { return (ILookupParameter<DoubleValue>)Parameters["PointVisitingCosts"]; }
    5959    }
    6060    #endregion
     
    8080      Parameters.Add(new LookupParameter<DistanceMatrix>("DistanceMatrix", "The matrix which contains the distances between the points."));
    8181      Parameters.Add(new LookupParameter<DoubleValue>("MaximumDistance", "The maximum distance constraint for a Orienteering solution."));
    82       Parameters.Add(new LookupParameter<DoubleValue>("FixedPenalty", "The penalty for each visited vertex."));
     82      Parameters.Add(new LookupParameter<DoubleValue>("PointVisitingCosts", "The costs for visiting a point."));
    8383    }
    8484
     
    8989
    9090    public static OrienteeringEvaluation Apply(IntegerVector solution, DoubleArray scores,
    91       DistanceMatrix distances, DoubleValue maximumDistance, DoubleValue fixedPenalty, DoubleValue distancePenaltyFactor) {
     91      DistanceMatrix distances, DoubleValue maximumDistance, DoubleValue pointVisitingCosts, DoubleValue distancePenaltyFactor) {
    9292
    9393      double score = solution.Sum(t => scores[t]);
    94       double distance = distances.CalculateTourLength(solution.ToList(), fixedPenalty.Value);
     94      double distance = distances.CalculateTourLength(solution.ToList(), pointVisitingCosts.Value);
    9595
    9696      double distanceViolation = distance - maximumDistance.Value;
     
    110110      var evaluation = Apply(IntegerVectorParameter.ActualValue, ScoresParameter.ActualValue,
    111111        DistanceMatrixParameter.ActualValue, MaximumDistanceParameter.ActualValue,
    112         FixedPenaltyParameter.ActualValue, DistancePenaltyFactorParameter.ActualValue);
     112        PointVisitingCostsParameter.ActualValue, DistancePenaltyFactorParameter.ActualValue);
    113113
    114114      QualityParameter.ActualValue = evaluation.Quality;
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/Improvers/OrienteeringLocalImprovementOperator.cs

    r11319 r11320  
    5858      get { return (ILookupParameter<IntValue>)Parameters["TerminalPoint"]; }
    5959    }
    60     public ILookupParameter<DoubleValue> FixedPenaltyParameter {
    61       get { return (ILookupParameter<DoubleValue>)Parameters["FixedPenalty"]; }
     60    public ILookupParameter<DoubleValue> PointVisitingCostsParameter {
     61      get { return (ILookupParameter<DoubleValue>)Parameters["PointVisitingCosts"]; }
    6262    }
    6363    #region ILocalImprovementOperator Parameters
     
    9999      Parameters.Add(new LookupParameter<IntValue>("StartingPoint", "Index of the starting point."));
    100100      Parameters.Add(new LookupParameter<IntValue>("TerminalPoint", "Index of the ending point."));
    101       Parameters.Add(new LookupParameter<DoubleValue>("FixedPenalty", "The penalty for each visited vertex."));
     101      Parameters.Add(new LookupParameter<DoubleValue>("PointVisitingCosts", "The costs for visiting a point."));
    102102
    103103      Parameters.Add(new ValueLookupParameter<IntValue>("LocalIterations", "The number of iterations that have already been performed.", new IntValue(0)));
     
    119119      var distances = DistanceMatrixParameter.ActualValue;
    120120      var scores = ScoresParameter.ActualValue;
    121       double fixedPenalty = FixedPenaltyParameter.ActualValue.Value;
     121      double pointVisitingCosts = PointVisitingCostsParameter.ActualValue.Value;
    122122      double maxLength = MaximumDistanceParameter.ActualValue.Value;
    123123      int maxIterations = MaximumIterationsParameter.ActualValue.Value;
     
    129129      var tour = IntegerVectorParameter.ActualValue.ToList();
    130130
    131       double tourLength = distances.CalculateTourLength(tour, fixedPenalty);
     131      double tourLength = distances.CalculateTourLength(tour, pointVisitingCosts);
    132132      double tourScore = tour.Sum(point => scores[point]);
    133133
     
    148148        // Determine if any of the visitable points can be included at any position within the tour
    149149        IncludeNewPoints(tour, visitablePoints,
    150           distances, fixedPenalty, maxLength, scores,
     150          distances, pointVisitingCosts, maxLength, scores,
    151151          ref tourLength, ref tourScore, ref evaluations, ref optimizationDone);
    152152
     
    211211    }
    212212    private void IncludeNewPoints(List<int> tour, List<int> visitablePoints,
    213       DistanceMatrix distances, double fixedPenalty, double maxLength, DoubleArray scores,
     213      DistanceMatrix distances, double pointVisitingCosts, double maxLength, DoubleArray scores,
    214214      ref double tourLength, ref double tourScore, ref int evaluations, ref bool optimizationDone) {
    215215
     
    224224          evaluations++;
    225225
    226           double detour = distances.CalculateInsertionCosts(tour, tourPosition, visitablePoints[i], fixedPenalty);
     226          double detour = distances.CalculateInsertionCosts(tour, tourPosition, visitablePoints[i], pointVisitingCosts);
    227227
    228228          // Determine if including the point does not violate any constraint
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/OrienteeringProblem.cs

    r11319 r11320  
    6464      get { return (ValueParameter<DoubleArray>)Parameters["Scores"]; }
    6565    }
    66     public ValueParameter<DoubleValue> FixedPenaltyParameter {
    67       get { return (ValueParameter<DoubleValue>)Parameters["FixedPenalty"]; }
     66    public ValueParameter<DoubleValue> PointVisitingCostsParameter {
     67      get { return (ValueParameter<DoubleValue>)Parameters["PointVisitingCosts"]; }
    6868    }
    6969
     
    9898      set { ScoresParameter.Value = value; }
    9999    }
    100     public DoubleValue FixedPenalty {
    101       get { return FixedPenaltyParameter.Value; }
    102       set { FixedPenaltyParameter.Value = value; }
     100    public DoubleValue PointVisitingCosts {
     101      get { return PointVisitingCostsParameter.Value; }
     102      set { PointVisitingCostsParameter.Value = value; }
    103103    }
    104104    public IntegerVector BestKnownSolution {
     
    130130      Parameters.Add(new ValueParameter<DoubleValue>("MaximumDistance", "The maximum distance constraint for a Orienteering solution."));
    131131      Parameters.Add(new ValueParameter<DoubleArray>("Scores", "The scores of the points."));
    132       Parameters.Add(new ValueParameter<DoubleValue>("FixedPenalty", "The penalty for each visited vertex."));
     132      Parameters.Add(new ValueParameter<DoubleValue>("PointVisitingCosts", "The costs for visiting a point."));
    133133      Parameters.Add(new OptionalValueParameter<IntegerVector>("BestKnownSolution", "The best known solution of this Orienteering instance."));
    134134
     
    204204      ParameterizeSolutionCreator();
    205205    }
    206     private void FixedPenaltyParameter_ValueChanged(object sender, EventArgs e) {
     206    private void PointVisitingCostsParameter_ValueChanged(object sender, EventArgs e) {
    207207      ParameterizeEvaluator();
    208208      ParameterizeAnalyzer();
     
    231231      ScoresParameter.ValueChanged += ScoresParameter_ValueChanged;
    232232      ScoresParameter.Value.Reset += ScoresValue_Reset;
    233       FixedPenaltyParameter.ValueChanged += FixedPenaltyParameter_ValueChanged;
     233      PointVisitingCostsParameter.ValueChanged += PointVisitingCostsParameter_ValueChanged;
    234234    }
    235235
     
    242242        creator.StartingPointParameter.ActualName = StartingPointParameter.Name;
    243243        creator.TerminalPointParameter.ActualName = TerminalPointParameter.Name;
    244         creator.FixedPenaltyParameter.ActualName = FixedPenaltyParameter.Name;
     244        creator.PointVisitingCostsParameter.ActualName = PointVisitingCostsParameter.Name;
    245245      }
    246246    }
     
    281281        op.StartingPointParameter.ActualName = StartingPointParameter.Name;
    282282        op.TerminalPointParameter.ActualName = TerminalPointParameter.Name;
    283         op.FixedPenaltyParameter.ActualName = FixedPenaltyParameter.Name;
     283        op.PointVisitingCostsParameter.ActualName = PointVisitingCostsParameter.Name;
    284284      }
    285285      foreach (var op in Operators.OfType<OrienteeringShakingOperator>()) {
     
    290290        op.StartingPointParameter.ActualName = StartingPointParameter.Name;
    291291        op.TerminalPointParameter.ActualName = TerminalPointParameter.Name;
    292         op.FixedPenaltyParameter.ActualName = FixedPenaltyParameter.Name;
     292        op.PointVisitingCostsParameter.ActualName = PointVisitingCostsParameter.Name;
    293293      }
    294294    }
     
    362362      TerminalPoint = new IntValue(data.TerminalPoint);
    363363
     364      PointVisitingCosts = new DoubleValue(data.PointVisitingCosts);
    364365      MaximumDistance = new DoubleValue(data.MaximumDistance);
    365366      Scores = new DoubleArray(data.Scores);
     
    388389      TerminalPoint = new IntValue(data.Dimension - 1); // Last city is interpreted als end point
    389390
     391      PointVisitingCosts = new DoubleValue(0);
    390392      MaximumDistance = new DoubleValue(DistanceMatrix.Average() * 5.0); // distance from start to end first to last city is interpreted as maximum distance
    391393      Scores = new DoubleArray(Enumerable.Repeat(1.0, data.Dimension).ToArray()); // all scores are 1
     
    413415      TerminalPoint = new IntValue(0); // Depot is interpreted als end point
    414416
     417      PointVisitingCosts = new DoubleValue(0);
    415418      MaximumDistance = new DoubleValue(data.Capacity * 2); // capacity is interpreted as max distance
    416419      Scores = new DoubleArray(data.Demands); // demands are interpreted as scores
    417 
    418       OnReset();
    419420    }
    420421  }
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/Shakers/OrienteeringShakingOperator.cs

    r11319 r11320  
    7676      get { return (ILookupParameter<DoubleArray>)Parameters["Scores"]; }
    7777    }
    78     public ILookupParameter<DoubleValue> FixedPenaltyParameter {
    79       get { return (ILookupParameter<DoubleValue>)Parameters["FixedPenalty"]; }
     78    public ILookupParameter<DoubleValue> PointVisitingCostsParameter {
     79      get { return (ILookupParameter<DoubleValue>)Parameters["PointVisitingCosts"]; }
    8080    }
    8181
     
    101101      Parameters.Add(new LookupParameter<DistanceMatrix>("DistanceMatrix", "The matrix which contains the distances between the points."));
    102102      Parameters.Add(new LookupParameter<DoubleArray>("Scores", "The scores of the points."));
    103       Parameters.Add(new LookupParameter<DoubleValue>("FixedPenalty", "The penalty for each visited vertex."));
     103      Parameters.Add(new LookupParameter<DoubleValue>("PointVisitingCosts", "The costs for visiting a point."));
    104104
    105105      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator that will be used."));
     
    116116      var startingPoint = StartingPointParameter.ActualValue.Value;
    117117      var terminalPoint = TerminalPointParameter.ActualValue.Value;
    118       var fixedPenalty = FixedPenaltyParameter.ActualValue.Value;
     118      var pointVisitingCosts = PointVisitingCostsParameter.ActualValue.Value;
    119119      double maxDistance = MaximumDistanceParameter.ActualValue.Value;
    120120      int numPoints = scores.Length;
     
    139139          from point in Enumerable.Range(0, numPoints)
    140140          // Calculate the distance when going from the starting point to this point and then to the end point
    141           let distance = distances[startingPoint, point] + distances[point, terminalPoint] + fixedPenalty
     141          let distance = distances[startingPoint, point] + distances[point, terminalPoint] + pointVisitingCosts
    142142          // If this distance is feasible and the point is neither starting nor ending point, check the point
    143143          where distance < maxDistance && point != startingPoint && point != terminalPoint
     
    157157
    158158        // Bring the tour back to be feasible
    159         CleanupTour(actualTour, distances, maxDistance, fixedPenalty);
     159        CleanupTour(actualTour, distances, maxDistance, pointVisitingCosts);
    160160
    161161        // Set new Tour
     
    208208      }
    209209    }
    210     private void CleanupTour(List<int> actualTour, DistanceMatrix distances, double maxDistance, double fixedPenalty) {
     210    private void CleanupTour(List<int> actualTour, DistanceMatrix distances, double maxDistance, double pointVisitingCosts) {
    211211      // Sort the points on the tour according to their costs savings when removed
    212212      var distanceSavings = (
    213213        from removePosition in Enumerable.Range(1, actualTour.Count - 2)
    214         let saving = distances.CalculateRemovementSaving(actualTour, removePosition, fixedPenalty)
     214        let saving = distances.CalculateRemovementSaving(actualTour, removePosition, pointVisitingCosts)
    215215        orderby saving descending
    216216        select new SavingInfo { Index = removePosition, Saving = saving }
    217217      ).ToList();
    218218
    219       double tourLength = distances.CalculateTourLength(actualTour, fixedPenalty);
     219      double tourLength = distances.CalculateTourLength(actualTour, pointVisitingCosts);
    220220
    221221      // As long as the created path is infeasible, remove elements
     
    223223        // Remove the point that frees the largest distance
    224224        // Note, distance savings are not updated after removal
    225         tourLength -= distances.CalculateRemovementSaving(actualTour, distanceSavings[0].Index, fixedPenalty);
     225        tourLength -= distances.CalculateRemovementSaving(actualTour, distanceSavings[0].Index, pointVisitingCosts);
    226226        actualTour.RemoveAt(distanceSavings[0].Index);
    227227
Note: See TracChangeset for help on using the changeset viewer.