PedestrianDynamics / jupedsim

JuPedSim is an open source pedestrian dynamics simulator
http://jupedsim.org
Other
37 stars 26 forks source link

Setting parameters of CollisionFreeSpeedModelV2 #1413

Closed chraibi closed 2 months ago

chraibi commented 2 months ago

I'm trying to change strength_neighbor_repulsion of the agents like so

simulation = jps.Simulation(
        model=jps.CollisionFreeSpeedModelV2(),
        geometry=geometry,
        dt=_time_step,
        trajectory_writer=jps.SqliteTrajectoryWriter(
            output_file=pathlib.Path(_trajectory_path), every_nth_frame=_fps
        ),
    )  

for agent_id in ped_ids:
        simulation.agent(agent_id).model.v0 = 2.0
        simulation.agent(agent_id).model.strength_neighbor_repulsion = 2.0
        print(simulation.agent(agent_id).model.v0,
              simulation.agent(agent_id).model.strength_neighbor_repulsion)

However, it seems I don't get it right and get as a result:

2.0 and 0.5 instead or 2.0 and 2.0

Edit: While v0 gets updated strength_neighbor_repulsion does not.

Any idea what I'm doing wrong?

Ozaq commented 2 months ago

Your code looks fine on first glance, I’ll have a look at it.

Ozaq commented 2 months ago

@chraibi I need an runnable example that exhibits this behaviour. I created a test for this case and cannot reproduce the bug.

This test passes and this test should do the same as you have provided in your example https://github.com/PedestrianDynamics/jupedsim/blob/1732ea43c99a365b3cf9c0c27f9702869f1b59ac/systemtest/test_model_properties.py#L50-L81

chraibi commented 2 months ago

@Ozaq: Thanks for taking the time!

I slightly adapted example1.py to reproduce this issue:

Just checked agent.model.range_neighbor_repulsion, agent.model.range_geometry_repulsion, and agent.model.strength_geometry_repulsion

all get updated as expected. Only agent.model.strength_neighbor_repulsion not.

Running the script in the link above gives me the following output:

Screenshot 2024-05-12 at 15 27 24
Ozaq commented 2 months ago

Yeah I found that issue for strength_neighbor_repulsion too when creating the test, this is already fixed on https://github.com/PedestrianDynamics/jupedsim/tree/1413-setting-parameters-of-collisionfreespeedmodelv2

In your original issue you mentioned that v0 would not update, could you reproduce this?

I plan on extending the test coverage for all models on this branch and the merging the fix.

chraibi commented 2 months ago

No, v0 get updated.

chraibi commented 2 months ago

Nice! Your fix works. Thank you!

Screenshot 2024-05-13 at 11 44 39