-
Notifications
You must be signed in to change notification settings - Fork 180
faq 118390785
Billy Charlton edited this page Sep 5, 2018
·
2 revisions
by Kai Nagel on 2017-10-30 07:10:34
The code example RunAgentSourceExample
in matsim-code-examples says
@Override public Mobsim get() {
final QSim qsim = QSimUtils.createDefaultQSim( scenario, events );
qsim.addAgentSource(new AgentSource() {
@Override
public void insertAgentsIntoMobsim() {
// insert traveler agent:
final MobsimAgent ag = new MyMobsimAgent(qsim.getScenario(), qsim.getSimTimer());
qsim.insertAgentIntoMobsim(ag);
// insert vehicle:
final Vehicle vehicle = VehicleUtils.getFactory().createVehicle(Id.create(ag.getId(), Vehicle.class), VehicleUtils.getDefaultVehicleType());
final Id<Link> linkId4VehicleInsertion = Id.createLinkId(1);
qsim.createAndParkVehicleOnLink(vehicle, linkId4VehicleInsertion);
}
});
return qsim;
}
However, most people seem to be inserting the agents directly:
@Override public Mobsim get() {
final QSim qsim = QSimUtils.createDefaultQSim( scenario, events );
// insert traveler agent:
final MobsimAgent ag = new MyMobsimAgent(qsim.getScenario(), qsim.getSimTimer());
qsim.insertAgentIntoMobsim(ag);
// insert vehicle:
final Vehicle vehicle = VehicleUtils.getFactory().createVehicle(Id.create(ag.getId(), Vehicle.class), VehicleUtils.getDefaultVehicleType());
final Id<Link> linkId4VehicleInsertion = Id.createLinkId(1);
qsim.createAndParkVehicleOnLink(vehicle, linkId4VehicleInsertion);
return qsim;
}
When is the more complicated first version necessary, and why?
You are viewing an archive of the previous MATSim Q&A site. The real site is now at https://matsim.org/faq