org.matsim.contrib.dvrp.fleet.DvrpVehicleSpecification Java Examples
The following examples show how to use
org.matsim.contrib.dvrp.fleet.DvrpVehicleSpecification.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CreateFleetVehicles.java From matsim-maas with GNU General Public License v2.0 | 6 votes |
private void run() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); new MatsimNetworkReader(scenario.getNetwork()).readFile(networkFile.toString()); final int[] i = {0}; Stream<DvrpVehicleSpecification> vehicleSpecificationStream = scenario.getNetwork().getLinks().entrySet().stream() .filter(entry -> entry.getValue().getAllowedModes().contains(TransportMode.car)) // drt can only start on links with Transport mode 'car' .sorted((e1, e2) -> (random.nextInt(2) - 1)) // shuffle links .limit(numberOfVehicles) // select the first *numberOfVehicles* links .map(entry -> ImmutableDvrpVehicleSpecification.newBuilder() .id(Id.create("drt_" + i[0]++, DvrpVehicle.class)) .startLinkId(entry.getKey()) .capacity(seatsPerVehicle) .serviceBeginTime(operationStartTime) .serviceEndTime(operationEndTime) .build()); new FleetWriter(vehicleSpecificationStream).write(outputFile.toString()); }
Example #2
Source File: VehicleToVSGenerator.java From amodeus with GNU General Public License v2.0 | 6 votes |
@Override public List<DvrpVehicleSpecification> generateVehicles() { int generatedNumberOfVehicles = 0; List<DvrpVehicleSpecification> vehicles = new LinkedList<>(); placedVehicles = Array.zeros(virtualNetwork.getvNodesCount()); while (generatedNumberOfVehicles < operatorConfig.getGeneratorConfig().getNumberOfVehicles()) { ++generatedNumberOfVehicles; int vNodeIndex = getNextVirtualNode(); Link linkGen = getNextLink(virtualNetwork.getVirtualNode(vNodeIndex)); /** update placedVehicles */ placedVehicles.set(RealScalar.ONE::add, vNodeIndex); Id<DvrpVehicle> id = AmodeusIdentifiers.createVehicleId(operatorConfig.getMode(), generatedNumberOfVehicles); vehicles.add(ImmutableDvrpVehicleSpecification.newBuilder() // .id(id) // .serviceBeginTime(0.0) // .serviceEndTime(Double.POSITIVE_INFINITY) // .capacity(capacity) // .startLinkId(linkGen.getId()) // .build()); } return vehicles; }
Example #3
Source File: RandomDensityGenerator.java From amodeus with GNU General Public License v2.0 | 6 votes |
@Override public List<DvrpVehicleSpecification> generateVehicles() { long generatedVehicles = 0; List<DvrpVehicleSpecification> vehicles = new LinkedList<>(); while (generatedVehicles < operatorConfig.getGeneratorConfig().getNumberOfVehicles()) { ++generatedVehicles; int bound = network.getLinks().size(); int elemRand = MatsimRandom.getRandom().nextInt(bound); Link link = network.getLinks().values().stream().skip(elemRand).findFirst().get(); LOGGER.info("car placed at link " + link); Id<DvrpVehicle> id = AmodeusIdentifiers.createVehicleId(operatorConfig.getMode(), generatedVehicles); vehicles.add(ImmutableDvrpVehicleSpecification.newBuilder() // .id(id) // .serviceBeginTime(0.0) // .serviceEndTime(Double.POSITIVE_INFINITY) // .capacity(capacity) // .startLinkId(link.getId()) // .build()); } return vehicles; }
Example #4
Source File: AmodeusModeQSimModule.java From amodeus with GNU General Public License v2.0 | 6 votes |
@Override public Fleet get() { AmodeusGenerator generator = getModalInstance(AmodeusGenerator.class); Network network = getModalInstance(Network.class); List<DvrpVehicleSpecification> specifications = generator.generateVehicles(); List<DvrpVehicle> vehicles = new LinkedList<>(); for (DvrpVehicleSpecification specification : specifications) { if (Double.isFinite(specification.getServiceEndTime())) { throw new IllegalStateException("AV vehicles must have infinite service time"); } vehicles.add(new DvrpVehicleImpl(specification, network.getLinks().get(specification.getStartLinkId()))); } for (DvrpVehicle vehicle : vehicles) { vehicle.getSchedule().addTask(new AmodeusStayTask(vehicle.getServiceBeginTime(), vehicle.getServiceEndTime(), vehicle.getStartLink())); } return () -> vehicles.stream().collect(ImmutableMap.toImmutableMap(DvrpVehicle::getId, v -> v)); }
Example #5
Source File: DemoGenerator.java From amod with GNU General Public License v2.0 | 6 votes |
@Override public List<DvrpVehicleSpecification> generateVehicles() { long generatedVehicles = 0; List<DvrpVehicleSpecification> vehicles = new LinkedList<>(); while (generatedVehicles < operatorConfig.getGeneratorConfig().getNumberOfVehicles()) { ++generatedVehicles; /** select one of the 10 random links for placement */ int elemRand = MatsimRandom.getRandom().nextInt(randomLinks.size()); Link linkSel = randomLinks.stream().skip(elemRand).findFirst().get(); LOGGER.info("car placed at link " + linkSel); Id<DvrpVehicle> id = AmodeusIdentifiers.createVehicleId(operatorConfig.getMode(), generatedVehicles); vehicles.add(ImmutableDvrpVehicleSpecification.newBuilder() // .id(id) // .serviceBeginTime(0.0) // .serviceEndTime(Double.POSITIVE_INFINITY) // .capacity(capacity) // .startLinkId(linkSel.getId()) // .build()); } return vehicles; }
Example #6
Source File: PopulationDensityGenerator.java From amodeus with GNU General Public License v2.0 | 5 votes |
@Override public List<DvrpVehicleSpecification> generateVehicles() { List<DvrpVehicleSpecification> vehicles = new LinkedList<>(); Random random = new Random(randomSeed); int generatedNumberOfVehicles = 0; while (generatedNumberOfVehicles < numberOfVehicles) { generatedNumberOfVehicles++; // Multinomial selection double r = random.nextDouble(); Link selectedLink = linkList.get(0); for (Link link : linkList) { if (r <= cumulativeDensity.get(link)) { selectedLink = link; break; } } Id<DvrpVehicle> id = AmodeusIdentifiers.createVehicleId(mode, generatedNumberOfVehicles); vehicles.add(ImmutableDvrpVehicleSpecification.newBuilder() // .id(id) // .serviceBeginTime(0.0) // .serviceEndTime(Double.POSITIVE_INFINITY) // .capacity(capacity) // .startLinkId(selectedLink.getId()) // .build()); } return vehicles; }
Example #7
Source File: TestScenario.java From amodeus with GNU General Public License v2.0 | 5 votes |
@Override public List<DvrpVehicleSpecification> generateVehicles() { VehicleType vehicleType = VehicleUtils.getDefaultVehicleType(); vehicleType.getCapacity().setSeats(capacity); return Collections.singletonList(ImmutableDvrpVehicleSpecification.newBuilder() // .id(Id.create("vehicle", DvrpVehicle.class)) // .startLinkId(link.getId()) // .serviceBeginTime(0.0) // .serviceEndTime(Double.POSITIVE_INFINITY) // .capacity(capacity) // .build()); }
Example #8
Source File: AmodeusGenerator.java From amodeus with GNU General Public License v2.0 | votes |
List<DvrpVehicleSpecification> generateVehicles();