Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/01/10 11:13:46 (14 years ago)
Author:
svonolfe
Message:

Merged r4351 of the VRP feature branch into trunk (#1039)

Location:
trunk/sources/HeuristicLab.Problems.VehicleRouting
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting

  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VehicleRoutingProblem.cs

    r4179 r4352  
    3434using HeuristicLab.Problems.VehicleRouting.Encodings.Alba;
    3535using HeuristicLab.Problems.VehicleRouting.Encodings.General;
     36using HeuristicLab.Problems.VehicleRouting.Encodings.Prins;
    3637
    3738namespace HeuristicLab.Problems.VehicleRouting {
     
    176177    private BestVRPSolutionAnalyzer BestVRPSolutionAnalyzer {
    177178      get { return operators.OfType<BestVRPSolutionAnalyzer>().FirstOrDefault(); }
     179    }
     180    private BestAverageWorstVRPToursAnalyzer BestAverageWorstVRPToursAnalyzer {
     181      get { return operators.OfType<BestAverageWorstVRPToursAnalyzer>().FirstOrDefault(); }
    178182    }
    179183    #endregion
     
    314318      operators = new List<IOperator>();
    315319      operators.Add(new BestVRPSolutionAnalyzer());
     320      operators.Add(new BestAverageWorstVRPToursAnalyzer());
    316321      ParameterizeAnalyzer();
    317       operators.AddRange(ApplicationManager.Manager.GetInstances<IVRPOperator>().Cast<IOperator>());
     322      operators.AddRange(ApplicationManager.Manager.GetInstances<IVRPOperator>().Cast<IOperator>().OrderBy(op => op.Name));
    318323      ParameterizeOperators();
    319324      UpdateMoveEvaluators();
     
    333338    }
    334339    private void ParameterizeSolutionCreator() {
    335       SolutionCreator.CitiesParameter.Value = new IntValue(Coordinates.Rows - 1);
    336340      SolutionCreator.VehiclesParameter.ActualName = VehiclesParameter.Name;
    337341      SolutionCreator.CoordinatesParameter.ActualName = CoordinatesParameter.Name;
     
    367371      BestVRPSolutionAnalyzer.OverloadParameter.ActualName = Evaluator.OverloadParameter.ActualName;
    368372      BestVRPSolutionAnalyzer.TardinessParameter.ActualName = Evaluator.TardinessParameter.ActualName;
     373      BestVRPSolutionAnalyzer.TravelTimeParameter.ActualName = Evaluator.TravelTimeParameter.ActualName;
     374      BestVRPSolutionAnalyzer.VehiclesUtilizedParameter.ActualName = Evaluator.VehcilesUtilizedParameter.ActualName;
    369375      BestVRPSolutionAnalyzer.VRPToursParameter.ActualName = SolutionCreator.VRPToursParameter.ActualName;
    370376      BestVRPSolutionAnalyzer.ResultsParameter.ActualName = "Results";
     377
     378      BestAverageWorstVRPToursAnalyzer.DistanceParameter.ActualName = Evaluator.DistanceParameter.ActualName;
     379      BestAverageWorstVRPToursAnalyzer.OverloadParameter.ActualName = Evaluator.OverloadParameter.ActualName;
     380      BestAverageWorstVRPToursAnalyzer.TardinessParameter.ActualName = Evaluator.TardinessParameter.ActualName;
     381      BestAverageWorstVRPToursAnalyzer.TravelTimeParameter.ActualName = Evaluator.TravelTimeParameter.ActualName;
     382      BestAverageWorstVRPToursAnalyzer.VehiclesUtilizedParameter.ActualName = Evaluator.VehcilesUtilizedParameter.ActualName;
     383      BestAverageWorstVRPToursAnalyzer.ResultsParameter.ActualName = "Results";
    371384    }
    372385    private void ParameterizeOperators() {
     
    387400      }
    388401
     402      foreach (IPrinsOperator op in Operators.OfType<IPrinsOperator>()) {
     403        op.FleetUsageFactor.ActualName = FleetUsageFactor.Name;
     404        op.TimeFactor.ActualName = TimeFactor.Name;
     405        op.DistanceFactor.ActualName = DistanceFactor.Name;
     406        op.OverloadPenalty.ActualName = OverloadPenalty.Name;
     407        op.TardinessPenalty.ActualName = TardinessPenalty.Name;
     408      }
     409
    389410      foreach (IVRPMoveEvaluator op in Operators.OfType<IVRPMoveEvaluator>()) {
    390411        op.FleetUsageFactor.ActualName = FleetUsageFactor.Name;
     
    427448      DueTime = new DoubleArray(parser.Duetimes);
    428449      ServiceTime = new DoubleArray(parser.Servicetimes);
     450
     451      OnReset();
     452    }
     453
     454    public void ImportFromTSPLib(string tspFileName) {
     455      TSPLIBParser parser = new TSPLIBParser(tspFileName);
     456      parser.Parse();
     457
     458      this.Name = parser.Name;
     459
     460      int problemSize = parser.Demands.Length;
     461
     462      Coordinates = new DoubleMatrix(parser.Vertices);
     463      if (parser.Vehicles != -1)
     464        Vehicles.Value = parser.Vehicles;
     465      else
     466        Vehicles.Value = problemSize - 1;
     467      Capacity.Value = parser.Capacity;
     468      Demand = new DoubleArray(parser.Demands);
     469      ReadyTime = new DoubleArray(problemSize);
     470      DueTime = new DoubleArray(problemSize);
     471      ServiceTime = new DoubleArray(problemSize);
     472
     473      for (int i = 0; i < problemSize; i++) {
     474        ReadyTime[i] = 0;
     475        DueTime[i] = int.MaxValue;
     476        ServiceTime[i] = 0;
     477      }
     478
     479      if (parser.Distance != -1) {
     480        DueTime[0] = parser.Distance;
     481      }
     482
     483      if (parser.Depot != 1)
     484        throw new Exception("Invalid depot specification");
     485
     486      if (parser.WeightType != TSPLIBParser.TSPLIBEdgeWeightType.EUC_2D)
     487        throw new Exception("Invalid weight type");
     488
     489      OnReset();
     490    }
     491
     492    public void ImportFromORLib(string orFileName) {
     493      ORLIBParser parser = new ORLIBParser(orFileName);
     494      parser.Parse();
     495
     496      this.Name = parser.Name;
     497      int problemSize = parser.Demands.Length;
     498
     499      Coordinates = new DoubleMatrix(parser.Vertices);
     500      Vehicles.Value = problemSize - 1;
     501      Capacity.Value = parser.Capacity;
     502      Demand = new DoubleArray(parser.Demands);
     503      ReadyTime = new DoubleArray(problemSize);
     504      DueTime = new DoubleArray(problemSize);
     505      ServiceTime = new DoubleArray(problemSize);
     506
     507      ReadyTime[0] = 0;
     508      DueTime[0] = parser.MaxRouteTime;
     509      ServiceTime[0] = 0;
     510
     511      for (int i = 1; i < problemSize; i++) {
     512        ReadyTime[i] = 0;
     513        DueTime[i] = int.MaxValue;
     514        ServiceTime[i] = parser.ServiceTime;
     515      }
    429516
    430517      OnReset();
Note: See TracChangeset for help on using the changeset viewer.