Service service = Service.Builder.newInstance(id) .setLocation(Location.Builder.newInstance().setId(id) .setCoordinate(coords[index]).setIndex(index).build()) .addSizeDimension(0, demands[index]).build(); vrpBuilder.addJob(service);
Service service = Service.Builder.newInstance("" + (i + 1)) .addTimeWindow(random.nextInt(50), 200) .addTimeWindow(220 + random.nextInt(50), 350) .addTimeWindow(400 + random.nextInt(50), 550) .setServiceTime(1) .setLocation(Location.newInstance(random.nextInt(50), random.nextInt(50))).build(); vrpBuilder.addJob(service); Service service = Service.Builder.newInstance(""+(i+51)) .setServiceTime(2) .setLocation(Location.newInstance(50 + random.nextInt(20), 20 + random.nextInt(25))).build(); vrpBuilder.addJob(service); Service service = Service.Builder.newInstance("100") .addTimeWindow(50, 80) .setServiceTime(10) .setLocation(Location.newInstance(40, 1)).build(); vrpBuilder.addJob(service);
createVehicles(vehicleFile, costScenario, customerId, coord, start, end); } else { 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);
Integer index = dimension.getInt("[@index]"); Integer value = dimension.getInt(""); builder.addSizeDimension(index, value); if (name != null) builder.setName(name); builder.setLocation(locationBuilder.build()); builder.setServiceTime(serviceConfig.getDouble("duration")); builder.addTimeWindow(TimeWindow.newInstance(twConfig.getDouble("start"), twConfig.getDouble("end"))); String cleaned = skillString.replaceAll("\\s", ""); String[] skillTokens = cleaned.split("[,;]"); for (String skill : skillTokens) builder.addRequiredSkill(skill.toLowerCase()); Service service = builder.build(); serviceMap.put(service.getId(), 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(); }
public Builder<T> addTimeWindow(double earliest, double latest) { return addTimeWindow(TimeWindow.newInstance(earliest, latest)); }
@Override public Service.Builder createBuilder(String serviceType, String id, Integer size) { if (serviceType.equals("pickup")) { if (size != null) return Pickup.Builder.newInstance(id).addSizeDimension(0, size); else return Pickup.Builder.newInstance(id); } else if (serviceType.equals("delivery")) { if (size != null) return Delivery.Builder.newInstance(id).addSizeDimension(0, size); else return Delivery.Builder.newInstance(id); } else { if (size != null) return Service.Builder.newInstance(id).addSizeDimension(0, size); else return Service.Builder.newInstance(id); } } }
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(); }
Service shipment1 = Service.Builder.newInstance("1").addSizeDimension(0, 1).setLocation(Location.newInstance(5, 7)).build(); Service shipment2 = Service.Builder.newInstance("2").addSizeDimension(0, 1).setLocation(Location.newInstance(5, 13)).build(); Service shipment3 = Service.Builder.newInstance("3").addSizeDimension(0, 1).setLocation(Location.newInstance(15, 7)).build(); Service shipment4 = Service.Builder.newInstance("4").addSizeDimension(0, 1).setLocation(Location.newInstance(15, 13)).build(); Service shipment5 = Service.Builder.newInstance("5").addSizeDimension(0, 1).setLocation(Location.newInstance(55, 57)).build(); Service shipment6 = Service.Builder.newInstance("6").addSizeDimension(0, 1).setLocation(Location.newInstance(55, 63)).build(); Service shipment7 = Service.Builder.newInstance("7").addSizeDimension(0, 1).setLocation(Location.newInstance(65, 57)).build(); Service shipment8 = Service.Builder.newInstance("8").addSizeDimension(0, 1).setLocation(Location.newInstance(65, 63)).build();
Delivery delivery1 = Delivery.Builder.newInstance("5").addSizeDimension(0, 1).setLocation(loc(Coordinate.newInstance(4, 8))).build(); Delivery delivery2 = Delivery.Builder.newInstance("6").addSizeDimension(0, 1).setLocation(loc(Coordinate.newInstance(4, 12))).build(); Delivery delivery3 = Delivery.Builder.newInstance("7").addSizeDimension(0, 1).setLocation(loc(Coordinate.newInstance(16, 8))).build(); Delivery delivery4 = Delivery.Builder.newInstance("8").addSizeDimension(0, 1).setLocation(loc(Coordinate.newInstance(16, 12))).build();
depotCoord = Coordinate.newInstance(Double.parseDouble(tokens[1]), Double.parseDouble(tokens[2])); } else { Service.Builder serviceBuilder = Service.Builder.newInstance(tokens[0]).addSizeDimension(0, Integer.parseInt(tokens[3])); serviceBuilder.setLocation(Location.newInstance(Double.parseDouble(tokens[1]), Double.parseDouble(tokens[2]))); vrpBuilder.addJob(serviceBuilder.build());
Service service1 = Service.Builder.newInstance("1") .addTimeWindow(50,100) .addTimeWindow(20,35) .addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(10, 0)).build(); Service service2 = Service.Builder.newInstance("2") .addSizeDimension(WEIGHT_INDEX, 1) .setLocation(Location.newInstance(20, 0)).setServiceTime(10).build(); Service service3 = Service.Builder.newInstance("3") .addTimeWindow(5, 10) .addTimeWindow(35, 50) .addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(30, 0)).build(); Service service4 = Service.Builder.newInstance("4") .addTimeWindow(20, 40) .addTimeWindow(45, 80) .addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(40, 0)).build(); Service service5 = Service.Builder.newInstance("5") .addTimeWindow(5,10) .addTimeWindow(20, 40) .addTimeWindow(60,100) .addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(20, 0)).build();
Integer index = dimension.getInt("[@index]"); Integer value = dimension.getInt(""); builder.addSizeDimension(index, value); if (name != null) builder.setName(name); builder.setLocation(locationBuilder.build()); builder.setServiceTime(serviceConfig.getDouble("duration")); builder.addTimeWindow(TimeWindow.newInstance(twConfig.getDouble("start"), twConfig.getDouble("end"))); String cleaned = skillString.replaceAll("\\s", ""); String[] skillTokens = cleaned.split("[,;]"); for (String skill : skillTokens) builder.addRequiredSkill(skill.toLowerCase()); Service service = builder.build(); serviceMap.put(service.getId(), service);
Service service1 = Service.Builder.newInstance("1").addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(5, 7)).build(); Service service2 = Service.Builder.newInstance("2").addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(5, 13)).build(); Service service3 = Service.Builder.newInstance("3").addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(15, 7)).build(); Service service4 = Service.Builder.newInstance("4").addSizeDimension(WEIGHT_INDEX, 1).addRequiredSkill("drill").setLocation(Location.newInstance(15, 13)).build();
Service service1 = Service.Builder.newInstance("1").addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(5, 7)).build(); Service service2 = Service.Builder.newInstance("2").addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(5, 13)).build(); Service service3 = Service.Builder.newInstance("3").addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(15, 7)).build(); Service service4 = Service.Builder.newInstance("4").addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(15, 13)).build();
double serviceTime = Double.parseDouble(tokens[3].trim()); int demand = Integer.parseInt(tokens[4].trim()); Service service = Service.Builder.newInstance(id).addSizeDimension(0, demand).setServiceTime(serviceTime) .setLocation(Location.Builder.newInstance().setId(id).setCoordinate(customerCoord).build()).build(); vrpBuilder.addJob(service); } else if (counter <= (nOfCustomers + nOfDepots + nOfDepots)) {
Pickup pickup1 = Pickup.Builder.newInstance("1").addSizeDimension(0, 1).setLocation(Location.newInstance(5, 7)).build(); Delivery delivery1 = Delivery.Builder.newInstance("2").addSizeDimension(0, 1).setLocation(Location.newInstance(5, 13)).build(); Pickup pickup2 = Pickup.Builder.newInstance("3").addSizeDimension(0, 1).setLocation(Location.newInstance(15, 7)).build(); Delivery delivery2 = Delivery.Builder.newInstance("4").addSizeDimension(0, 1).setLocation(Location.newInstance(15, 13)).build();
Service service1 = Service.Builder.newInstance("1").setPriority(1).addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(5, 7)).build(); Service service2 = Service.Builder.newInstance("2").addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(5, 13)).build(); Service service3 = Service.Builder.newInstance("3").addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(15, 7)).build(); Service service4 = Service.Builder.newInstance("4").setPriority(1).addSizeDimension(WEIGHT_INDEX, 1).setLocation(Location.newInstance(15, 13)).build();
Service s1 = Service.Builder.newInstance("s1") .addRequiredSkill("driver1") .setName("install new device") .setLocation(Location.newInstance(2, 2)).build(); Service s2 = Service.Builder.newInstance("s2") .addRequiredSkill("driver3") .setName("deliver key") .setLocation(Location.newInstance(2, 4)).build(); Service s3 = Service.Builder.newInstance("s3") .addRequiredSkill("driver1") .setName("repair heater") .setLocation(Location.newInstance(-2, 2)).build(); Service s4 = Service.Builder.newInstance("s4") .addRequiredSkill("driver3") .setName("get key") .setLocation(Location.newInstance(-2.3, 4)).build(); Service s5 = Service.Builder.newInstance("s5") .addRequiredSkill("driver1") .setName("cleaning") .setLocation(Location.newInstance(1, 5)).build(); Service s6 = Service.Builder.newInstance("s6") .addRequiredSkill("driver3") .setName("use key") .setLocation(Location.newInstance(-2, 3)).build();
Pickup pickup1 = Pickup.Builder.newInstance("1").addSizeDimension(0, 1).setLocation(Location.newInstance(5, 7)).build(); Delivery delivery1 = Delivery.Builder.newInstance("2").addSizeDimension(0, 1).setLocation(Location.newInstance(5, 13)).build(); Pickup pickup2 = Pickup.Builder.newInstance("3").addSizeDimension(0, 1).setLocation(Location.newInstance(15, 7)).build(); Delivery delivery2 = Delivery.Builder.newInstance("4").addSizeDimension(0, 1).setLocation(Location.newInstance(15, 13)).build();