daily pastebin goal
19%
SHARE
TWEET

Untitled

a guest Sep 25th, 2017 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Location l0 = Location.newInstance(43.237235, 76.915048);
  2.        
  3.         VehicleImpl v1 = VehicleImpl.Builder
  4.                 .newInstance("1")
  5.                 .setStartLocation(l0)
  6.                 .setEarliestStart(0)
  7.                 .setReturnToDepot(true)
  8.                 .build();
  9.        
  10.         Location l1 = Location.newInstance(43.239652, 76.887614);
  11.         Location l2 = Location.newInstance(43.25796, 76.911608);
  12.         Location l3 = Location.newInstance(43.225228, 76.893875);
  13.         Location l4 = Location.newInstance(43.25796, 76.911608);
  14.  
  15.         ManhattanCosts costs = new ManhattanCosts();
  16.         costs.speed = 50;
  17.  
  18.         System.out.println(costs.getTransportCost(l1, l2, 160, null, v1));
  19.         System.out.println(costs.getTransportTime(l1, l2, 160, null, v1));
  20.        
  21.         System.out.println(costs.getTransportCost(l1, l3, 160, null, v1));
  22.         System.out.println(costs.getTransportTime(l1, l3, 160, null, v1));
  23.        
  24.         VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
  25.        
  26.         Service s1 = Service.Builder
  27.                 .newInstance("1")
  28.                 .setLocation(l1)
  29.                 .setTimeWindow(new TimeWindow(0, 300))
  30.                 .setServiceTime(10)
  31.                 .build();
  32.         Service s2 = Service.Builder
  33.                 .newInstance("2")
  34.                 .setLocation(l2)
  35.                 .setTimeWindow(new TimeWindow(0, 300))
  36.                 .setServiceTime(10)
  37.                 .build();
  38.         Service s3 = Service.Builder
  39.                 .newInstance("3")
  40.                 .setLocation(l3)
  41.                 .setTimeWindow(new TimeWindow(0, 300))
  42.                 .setServiceTime(10)
  43.                 .build();
  44.         Service s4 = Service.Builder
  45.                 .newInstance("4")
  46.                 .setLocation(l4)
  47.                 .setTimeWindow(new TimeWindow(0, 300))
  48.                 .setServiceTime(10)
  49.                 .build();
  50.        
  51.         vrpBuilder.addJob(s1);
  52.         vrpBuilder.addJob(s2);
  53.         vrpBuilder.addJob(s3);
  54.         vrpBuilder.addJob(s4);
  55.         vrpBuilder.addVehicle(v1);
  56.         vrpBuilder.setFleetSize(FleetSize.FINITE);
  57.        
  58.         vrpBuilder.setRoutingCost(new ManhattanCosts());
  59.        
  60.         VehicleRoutingProblem vrp = vrpBuilder.build();
  61.        
  62.         VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp)
  63.                 .setProperty(Jsprit.Parameter.FAST_REGRET, "true")
  64.                 .setProperty(Jsprit.Parameter.THREADS, "4")
  65.                 .buildAlgorithm();
  66.        
  67.        
  68.         Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
  69.  
  70.         SolutionPrinter.print(vrp, Solutions.bestOf(solutions), SolutionPrinter.Print.VERBOSE);
  71.  
  72. //        new Plotter(vrp, Solutions.bestOf(solutions)).setLabel(Plotter.Label.ID).plot("output/p01_solution.png", "p01");
  73.  
  74.         new GraphStreamViewer(vrp, Solutions.bestOf(solutions)).setRenderDelay(100).display();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top