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
Files:
5 added
1 deleted
1 edited
5 copied
3 moved

Legend:

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

    r4362 r4363  
    44using System.Text;
    55
    6 namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances.Evaluation {
     6namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances {
    77  public class CVRPEvaluation: VRPEvaluation {
    88    public double Overload { get; set; }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP/CVRPProblemInstance.cs

    r4362 r4363  
    3131using HeuristicLab.Optimization;
    3232using HeuristicLab.PluginInfrastructure;
    33 using HeuristicLab.Problems.VehicleRouting.Interfaces.Variants;
     33using HeuristicLab.Problems.VehicleRouting.Variants;
    3434
    3535namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances {
     
    3737  [StorableClass]
    3838  public class CVRPProblemInstance: SingleDepotVRPProblemInstance, ICapacitatedProblemInstance {
    39     protected ValueParameter<DoubleValue> CapacityParameter {
    40       get { return (ValueParameter<DoubleValue>)Parameters["Capacity"]; }
     39    protected IValueParameter<DoubleValue> CapacityParameter {
     40      get { return (IValueParameter<DoubleValue>)Parameters["Capacity"]; }
    4141    }
    42     public IValueParameter<DoubleValue> OverloadPenaltyParameter {
     42    protected IValueParameter<DoubleValue> OverloadPenaltyParameter {
    4343      get { return (IValueParameter<DoubleValue>)Parameters["EvalOverloadPenalty"]; }
    4444    }
     
    5959      }
    6060    }
     61
     62    protected override IVRPEvaluator Evaluator {
     63      get {
     64        return new CVRPEvaluator();
     65      }
     66    }
    6167   
    6268    [StorableConstructor]
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP/CVRPTW/CVRPTWEvaluation.cs

    r4362 r4363  
    44using System.Text;
    55
    6 namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances.Evaluation {
     6namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances {
    77  public class CVRPTWEvaluation: CVRPEvaluation {
    88    public double Tardiness { get; set; }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP/CVRPTW/CVRPTWProblemInstance.cs

    r4362 r4363  
    3131using HeuristicLab.Optimization;
    3232using HeuristicLab.PluginInfrastructure;
    33 using HeuristicLab.Problems.VehicleRouting.Interfaces.Variants;
     33using HeuristicLab.Problems.VehicleRouting.Variants;
    3434
    3535namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances {
     
    3737  [StorableClass]
    3838  public class CVRPTWProblemInstance: CVRPProblemInstance, ITimeWindowedProblemInstance {
    39     protected ValueParameter<DoubleArray> ReadyTimeParameter {
    40       get { return (ValueParameter<DoubleArray>)Parameters["ReadyTime"]; }
     39    protected IValueParameter<DoubleArray> ReadyTimeParameter {
     40      get { return (IValueParameter<DoubleArray>)Parameters["ReadyTime"]; }
    4141    }
    42     protected ValueParameter<DoubleArray> DueTimeParameter {
    43       get { return (ValueParameter<DoubleArray>)Parameters["DueTime"]; }
     42    protected IValueParameter<DoubleArray> DueTimeParameter {
     43      get { return (IValueParameter<DoubleArray>)Parameters["DueTime"]; }
    4444    }
    45     protected ValueParameter<DoubleArray> ServiceTimeParameter {
    46       get { return (ValueParameter<DoubleArray>)Parameters["ServiceTime"]; }
     45    protected IValueParameter<DoubleArray> ServiceTimeParameter {
     46      get { return (IValueParameter<DoubleArray>)Parameters["ServiceTime"]; }
    4747    }
    4848
     
    8181      }
    8282    }
     83
     84    protected override IVRPEvaluator Evaluator {
     85      get {
     86        return new CVRPTWEvaluator();
     87      }
     88    }
    8389   
    8490    [StorableConstructor]
  • 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   
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/SingleDepotVRPProblemInstance.cs

    r4362 r4363  
    3131using HeuristicLab.Optimization;
    3232using HeuristicLab.PluginInfrastructure;
    33 using HeuristicLab.Problems.VehicleRouting.Interfaces.Variants;
    34 using HeuristicLab.Problems.VehicleRouting.ProblemInstances.Evaluation;
     33using HeuristicLab.Problems.VehicleRouting.Variants;
    3534
    3635namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances {
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPEvaluation.cs

    r4362 r4363  
    44using System.Text;
    55
    6 namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances.Evaluation {
     6namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances {
    77  public class VRPEvaluation {
    88    public double Quality { get; set; }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPEvaluator.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 {
     36namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances {
    3837  [Item("VRPEvaluator", "Represents a VRP evaluator.")]
    3938  [StorableClass]
     
    4443   
    4544    #region ISingleObjectiveEvaluator Members
    46 
    4745    public ILookupParameter<DoubleValue> QualityParameter {
    4846      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
    4947    }
     48    #endregion
    5049
    5150    public ILookupParameter<DoubleValue> DistanceParameter {
     
    5554      get { return (ILookupParameter<DoubleValue>)Parameters["VehiclesUtilized"]; }
    5655    }
    57 
    58     public ILookupParameter<DoubleValue> FleetUsageFactor {
    59       get { return (ILookupParameter<DoubleValue>)Parameters["EvalFleetUsageFactor"]; }
    60     }
    61     public ILookupParameter<DoubleValue> DistanceFactor {
    62       get { return (ILookupParameter<DoubleValue>)Parameters["EvalDistanceFactor"]; }
    63     }
    64 
    65     #endregion
    6656   
    6757    [StorableConstructor]
     
    7060    public VRPEvaluator() {
    7161      Parameters.Add(new LookupParameter<IVRPEncoding>("VRPTours", "The VRP tours which should be evaluated."));
    72 
    73       Parameters.Add(new LookupParameter<DoubleValue>("EvalFleetUsageFactor", "The fleet usage factor considered in the evaluation."));
    74       Parameters.Add(new LookupParameter<DoubleValue>("EvalDistanceFactor", "The distance factor considered in the evaluation."));
    7562
    7663      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The evaluated quality of the VRP solution."));
     
    8572    protected abstract void EvaluateTour(VRPEvaluation eval, IVRPProblemInstance instance, Tour tour);
    8673
    87     protected VRPEvaluation EvaluateTour(IVRPProblemInstance instance, Tour tour) {
    88       VRPEvaluation evaluation = CreateTourEvaluation();
    89       EvaluateTour(evaluation, instance, tour);
    90       return evaluation;
    91     }
    92 
    9374    protected virtual void InitResultParameters() {
    9475      QualityParameter.ActualValue = new DoubleValue(0);
     
    10182      VehcilesUtilizedParameter.ActualValue.Value += tourEvaluation.VehicleUtilization;
    10283      DistanceParameter.ActualValue.Value += tourEvaluation.Distance;
     84    }
     85
     86    protected VRPEvaluation EvaluateTour(IVRPProblemInstance instance, Tour tour) {
     87      VRPEvaluation evaluation = CreateTourEvaluation();
     88      EvaluateTour(evaluation, instance, tour);
     89      return evaluation;
    10390    }
    10491
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs

    r4362 r4363  
    3131using HeuristicLab.Optimization;
    3232using HeuristicLab.PluginInfrastructure;
    33 using HeuristicLab.Problems.VehicleRouting.DomainModel;
    3433
    3534namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances {
Note: See TracChangeset for help on using the changeset viewer.