Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/03/10 11:15:22 (14 years ago)
Author:
svonolfe
Message:

Worked on the evaluators and on the project structure of the VRP plugin - WIP (#1177)

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP
Files:
1 added
1 copied

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/SingleDepotVRPEvaluator.cs

    r4362 r4363  
    3131using HeuristicLab.Optimization;
    3232using HeuristicLab.PluginInfrastructure;
    33 using HeuristicLab.Problems.VehicleRouting.Interfaces.Variants;
     33using HeuristicLab.Problems.VehicleRouting.Variants;
    3434using HeuristicLab.Problems.VehicleRouting.Encodings;
    35 using HeuristicLab.Problems.VehicleRouting.DomainModel;
    3635
    37 namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances.Evaluation {
     36
     37namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances {
    3838  [Item("SingleDepotVRPEvaluator", "Represents a single depot VRP evaluator.")]
    3939  [StorableClass]
    4040  public class SingleDepotVRPEvaluator: VRPEvaluator {
    4141    protected override void EvaluateTour(VRPEvaluation eval, IVRPProblemInstance instance, Tour tour) {
     42      double distance = 0.0;
     43      double quality = 0.0;
    4244
     45      //simulate a tour, start and end at depot
     46      for (int i = 0; i <= tour.Stops.Count; i++) {
     47        int start = 0;
     48        if (i > 0)
     49          start = tour.Stops[i - 1];
     50        int end = 0;
     51        if (i < tour.Stops.Count)
     52          end = tour.Stops[i];
     53
     54        //drive there
     55        double currentDistace = instance.GetDistance(start, end);
     56        distance += currentDistace;
     57      }
     58
     59      //Fleet usage
     60      quality += instance.FleetUsageFactor.Value;
     61      //Distance
     62      quality += instance.DistanceFactor.Value * distance;
     63
     64      eval.Distance = distance;
     65      eval.VehicleUtilization = 1;
     66
     67      eval.Quality = quality;
    4368    }
    4469   
Note: See TracChangeset for help on using the changeset viewer.