-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use a specific vehicleType for drt vehicles? #3121
Comments
@michalmac maybe you could shed light on this since you are the author of |
Dear @markusstraub sorry for the late repy. Always had your post in my mind but not the time to look into the code. I'm using the
Sorry I have no shareable code available. |
Thanks a lot @steffenaxer for taking the time to answer! I followed your advice and came up with the example code below, but when comparing the output to the files I already have I see no difference. So your workflow is also loading vehicle xml files via config (and not somehow in code)? As mentioned above I debugged the vehicle creation process and did not see a way for To be clear: there is no problem in having drt vehicles with the correct id, but everything specified in the public static void main(String[] args) {
String vehicleId = "testVehicleId";
VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("customType", VehicleType.class));
vehicleType.setMaximumVelocity(8.33333);
vehicleType.getCapacity().setSeats(5);
Vehicle vehicle = VehicleUtils.createVehicle(Id.createVehicleId(vehicleId), vehicleType);
Vehicles vehicles = VehicleUtils.createVehiclesContainer();
vehicles.addVehicleType(vehicleType);
vehicles.addVehicle(vehicle);
List<DvrpVehicleSpecification> dvrpSpecs = new ArrayList<>();
dvrpSpecs.add(ImmutableDvrpVehicleSpecification
.newBuilder()
.id(Id.create(vehicleId, DvrpVehicle.class))
.startLinkId(Id.createLinkId("1234"))
.capacity(4)
.serviceBeginTime(0d)
.serviceEndTime(86400d).build());
new FleetWriter(dvrpSpecs.stream()).write("/tmp/vehicles_fleet.xml");
new MatsimVehicleWriter(vehicles).writeFile("/tmp/vehicles.xml");
} |
@markusstraub sorry, now I got your point. Yes I would support your finding. You are absolutely right. The |
Not sure if this is what you're looking for but this worked for me once, based on: and
|
I think the java way is quite clear, @markusstraub asked for a solution that natively works only controlled by configs. |
Thank you for the hint, @nkuehnel, I will look into it as immediate solution. Long-term it would be great if the |
I very much agree that it would be nice to have this consistent. |
I try to set a maximum velocity for drt vehicles and tried to do this via
vehicleDefinitions
like this:in combination with
.. but this does not work.
Why? Apparently
vehicleType
is only parsed for main modes (anddrt
must not be defined as main mode): see PrepareForSimImpl.getVehicleTypesForAllNetworkAndMainModes.The
VrpAgentSource
called inQSim.createAgents
was constructed with this vehicle type.This happens because
VrpAgentSourceQSimModule
gets the default vehicle type after callinggetModalInstance(VehicleType.class))
.I guess in the end it all boils down to
DrtModeModule
calling a FleetModule constructor that simply instantiates the default vehicle type. There is no way I see viaconfig.xml
to call this constructor instead:public FleetModule(String mode, URL fleetSpecificationUrl, VehicleType vehicleType)
So my question is: is there a way to properly configure a vehicle type for DVRP / DRT vehicles to e.g. set a maximum velocity? Ideally via the
config.xml
.The text was updated successfully, but these errors were encountered: