@Override public Location getLocation() { return service.getLocation(); }
@Override public Location getLocation() { return pickup.getLocation(); }
private double calcDist(Service i, Service j) { return calcDist(i.getLocation(), j.getLocation()); }
private double calcDist(Service s_i, Service s_j) { double distance; try { distance = costs.getTransportCost(s_i.getLocation(), s_j.getLocation(), 0.0, null, null); return distance; } catch (IllegalStateException e) { // now try the euclidean distance between these two services } EuclideanServiceDistance euclidean = new EuclideanServiceDistance(); distance = euclidean.getDistance(s_i, s_j); return distance; }
@Override public double getDistance(Job i, Job j) { double avgCost = 0.0; if (i instanceof Service && j instanceof Service) { if (i.equals(j)) { avgCost = 0.0; } else { Service s_i = (Service) i; Service s_j = (Service) j; if (s_i.getLocation().getCoordinate() == null || s_j.getLocation().getCoordinate() == null) throw new IllegalStateException("cannot calculate euclidean distance. since service coords are missing"); avgCost = EuclideanDistanceCalculator.calculateDistance(s_i.getLocation().getCoordinate(), s_j.getLocation().getCoordinate()); } } else { throw new UnsupportedOperationException( "currently, this class just works with shipments and services."); } return avgCost; }
private double calcDist(Service i, Shipment j) { double c_ij1 = calcDist(i.getLocation(), j.getPickupLocation()); double c_ij2 = calcDist(i.getLocation(), j.getDeliveryLocation()); return (c_ij1 + c_ij2) / 2.0; }
private void setEndLocation(VehicleRoute route, Service service) { route.getEnd().setLocation(service.getLocation()); }
private void renderService(Graph g, Service service, Label label) { Node n = g.addNode(makeId(service.getId(), service.getLocation().getId())); if (label.equals(Label.ID)) n.addAttribute("ui.label", service.getId()); n.addAttribute("x", service.getLocation().getCoordinate().getX()); n.addAttribute("y", service.getLocation().getCoordinate().getY()); if (service.getType().equals("pickup")) n.setAttribute("ui.class", "pickup"); if (service.getType().equals("delivery")) n.setAttribute("ui.class", "delivery"); }
private void addLocationToTentativeLocations(Job job) { if (job instanceof Service) { Location location = ((Service) job).getLocation(); // tentative_coordinates.put(location.getId(), location.getCoordinate()); addLocationToTentativeLocations(location); } else if (job instanceof Shipment) { Shipment shipment = (Shipment) job; Location pickupLocation = shipment.getPickupLocation(); addLocationToTentativeLocations(pickupLocation); // tentative_coordinates.put(pickupLocation.getId(), pickupLocation.getCoordinate()); Location deliveryLocation = shipment.getDeliveryLocation(); addLocationToTentativeLocations(deliveryLocation); // tentative_coordinates.put(deliveryLocation.getId(), deliveryLocation.getCoordinate()); } }
private double scoreService(InsertionData best, Job job) { Location location = ((Service) job).getLocation(); double maxDepotDistance = 0; if (location != null) { maxDepotDistance = Math.max( getDistance(best.getSelectedVehicle().getStartLocation(), location), getDistance(best.getSelectedVehicle().getEndLocation(), location) ); } return Math.max(timeWindowParam * (((Service) job).getTimeWindow().getEnd() - ((Service) job).getTimeWindow().getStart()), minTimeWindowScore) + depotDistanceParam * maxDepotDistance; }
List<Location> locations = new ArrayList<Location>(); for (Vehicle v : vrpBuilder.getAddedVehicles()) locations.add(v.getStartLocation()); for (Job j : vrpBuilder.getAddedJobs()) locations.add(((Service) j).getLocation()); vrpBuilder.setRoutingCost(getGEOMatrix(locations)); } else if (edgeType.equals("EXPLICIT")) {
xmlConfig.setProperty(shipmentPathString + "(" + counter + ")[@id]", service.getId()); xmlConfig.setProperty(shipmentPathString + "(" + counter + ")[@type]", service.getType()); if (service.getLocation().getId() != null) xmlConfig.setProperty(shipmentPathString + "(" + counter + ").location.id", service.getLocation().getId()); if (service.getLocation().getCoordinate() != null) { xmlConfig.setProperty(shipmentPathString + "(" + counter + ").location.coord[@x]", service.getLocation().getCoordinate().getX()); xmlConfig.setProperty(shipmentPathString + "(" + counter + ").location.coord[@y]", service.getLocation().getCoordinate().getY()); if (service.getLocation().getIndex() != Location.NO_INDEX) { xmlConfig.setProperty(shipmentPathString + "(" + counter + ").location.index", service.getLocation().getIndex());
private void addJob(Job job) { if (job instanceof Service) { Service service = (Service) job; addNode(service.getId(), service.getLocation().getCoordinate()); markService(service); } else if (job instanceof Shipment) { Shipment shipment = (Shipment) job; String fromNodeId = getFromNodeId(shipment); addNode(fromNodeId, shipment.getPickupLocation().getCoordinate()); String toNodeId = getToNodeId(shipment); addNode(toNodeId, shipment.getDeliveryLocation().getCoordinate()); markShipment(shipment); if (renderShipments) { Edge e = graph.addEdge("shipment_" + fromNodeId + "_" + toNodeId, fromNodeId, toNodeId, true); e.addAttribute("ui.class", "shipment"); } } }
Service service = (Service) job; Service.Builder skillServiceBuilder; if (service.getLocation().getCoordinate().getY() < 50.) { skillServiceBuilder = Service.Builder.newInstance(service.getId() + "_skill2").setServiceTime(service.getServiceDuration()) .setLocation(Location.Builder.newInstance().setId(service.getLocation().getId()) .setCoordinate(service.getLocation().getCoordinate()).build()).setTimeWindow(service.getTimeWindow()) .addSizeDimension(0, service.getSize().get(0)); skillServiceBuilder.addRequiredSkill("skill2"); skillServiceBuilder = Service.Builder.newInstance(service.getId() + "_skill1").setServiceTime(service.getServiceDuration()) .setLocation( Location.Builder.newInstance().setId(service.getLocation().getId()) .setCoordinate(service.getLocation().getCoordinate()).build() ).setTimeWindow(service.getTimeWindow()) .addSizeDimension(0, service.getSize().get(0));
private double calcDist(Service s_i, Service s_j) { double distance; try { distance = costs.getTransportCost(s_i.getLocation(), s_j.getLocation(), 0.0, null, null); return distance; } catch (IllegalStateException e) { // now try the euclidean distance between these two services } EuclideanServiceDistance euclidean = new EuclideanServiceDistance(); distance = euclidean.getDistance(s_i, s_j); return distance; }
} else if (job instanceof Service) { Service service = (Service) job; Coordinate coord = getCoordinate(service.getLocation().getCoordinate()); XYDataItem dataItem = new XYDataItem(coord.getX() * scalingFactor, coord.getY() * scalingFactor); activities.add(dataItem);
private double calcDist(Service i, Shipment j) { double c_ij1 = calcDist(i.getLocation(), j.getPickupLocation()); double c_ij2 = calcDist(i.getLocation(), j.getDeliveryLocation()); return (c_ij1 + c_ij2) / 2.0; }
private void renderService(Graph g, Service service, Label label) { Node n = g.addNode(makeId(service.getId(), service.getLocation().getId())); if (label.equals(Label.ID)) n.addAttribute("ui.label", service.getId()); n.addAttribute("x", service.getLocation().getCoordinate().getX()); n.addAttribute("y", service.getLocation().getCoordinate().getY()); if (service.getType().equals("pickup")) n.setAttribute("ui.class", "pickup"); if (service.getType().equals("delivery")) n.setAttribute("ui.class", "delivery"); }
private double scoreService(InsertionData best, Job job) { Location location = ((Service) job).getLocation(); double maxDepotDistance = 0; if (location != null) { maxDepotDistance = Math.max( getDistance(best.getSelectedVehicle().getStartLocation(), location), getDistance(best.getSelectedVehicle().getEndLocation(), location) ); } return Math.max(timeWindowParam * (((Service) job).getTimeWindow().getEnd() - ((Service) job).getTimeWindow().getStart()), minTimeWindowScore) + depotDistanceParam * maxDepotDistance; }
static CarrierService createCarrierService(Service service) { CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(Id.create(service.getId(), CarrierService.class), Id.create(service.getLocation().getId(), Link.class)); serviceBuilder.setCapacityDemand(service.getSize().get(0)); serviceBuilder.setServiceDuration(service.getServiceDuration()); serviceBuilder.setServiceStartTimeWindow(TimeWindow.newInstance(service.getTimeWindow().getStart(), service.getTimeWindow().getEnd())); return serviceBuilder.build(); }