} else { Service s = Service.Builder.newInstance("" + nodeIndex).setLocation(Location.newInstance(nodeIndex)) .setTimeWindow(TimeWindow.newInstance(Double.parseDouble(twTokens[0]), Double.parseDouble(twTokens[1]))).build(); builder.addJob(s);
Service service = Service.Builder.newInstance("" + (counter - 10)).addSizeDimension(0, demand) .setLocation(Location.Builder.newInstance().setCoordinate(coord).setId(customerId).build()).setServiceTime(serviceTime) .setTimeWindow(TimeWindow.newInstance(start, end)).build(); vrpBuilder.addJob(service);
Service service = Service.Builder.newInstance(customerId).addSizeDimension(0, demand) .setLocation(Location.Builder.newInstance().setCoordinate(coord).setId(customerId).build()).setServiceTime(serviceTime) .setTimeWindow(TimeWindow.newInstance(start, end)).build(); vrpBuilder.addJob(service);
private Service buildStop(ODLTableReadOnly table, int row, StopsTableDefn dfn, Service.Builder builder) { LatLong ll = dfn.latLong.getLatLong(table, row,false); Location location = Location.newInstance(locs.addLatLong(ll)); builder.setLocation(location); // validate and add quantities for (int q = 0; q < dfn.quantityIndices.length; q++) { builder.addSizeDimension(q, dfn.getQuantity(table, row, q)); } // validate and set service duration if (dfn.serviceDuration != -1) { builder.setServiceTime(dfn.getDuration(table, row).getTotalMilliseconds()); } // validate and set time window ODLTime[] tw = dfn.getTW(table, row); if (tw != null) { builder.setTimeWindow(new TimeWindow(tw[0].getTotalMilliseconds(), tw[1].getTotalMilliseconds())); } // add required skills for(String skill: getSkillsArray((String)table.getValueAt(row, dfn.requiredSkills))){ builder.addRequiredSkill(skill); } return builder.build(); }
static Service createService(CarrierService carrierService, Coord locationCoord) { Location.Builder locationBuilder = Location.Builder.newInstance(); locationBuilder.setId(carrierService.getLocationLinkId().toString()); if(locationCoord != null) { locationBuilder.setCoordinate(Coordinate.newInstance(locationCoord.getX(), locationCoord.getY())); } Location location = locationBuilder.build(); Builder serviceBuilder = Service.Builder.newInstance(carrierService.getId().toString()); serviceBuilder.addSizeDimension(0, carrierService.getCapacityDemand()); serviceBuilder.setLocation(location).setServiceTime(carrierService.getServiceDuration()) .setTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow.newInstance(carrierService.getServiceStartTimeWindow().getStart(), carrierService.getServiceStartTimeWindow().getEnd())); return serviceBuilder.build(); }
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"); Location.Builder.newInstance().setId(service.getLocation().getId()) .setCoordinate(service.getLocation().getCoordinate()).build() ).setTimeWindow(service.getTimeWindow()) .addSizeDimension(0, service.getSize().get(0)); skillServiceBuilder.addRequiredSkill("skill1");