Skip to content

Commit

Permalink
Add tests for setting agent parameters of social force model
Browse files Browse the repository at this point in the history
  • Loading branch information
schroedtert committed May 17, 2024
1 parent 9edd305 commit 03e566e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python_modules/jupedsim/jupedsim/models/social_force.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(self, backing) -> None:
self._obj = backing

@property
def velocity(self) -> float:
def velocity(self) -> tuple[float, float]:
"""velocity of this agent."""
return self._obj.test_value

Expand Down
47 changes: 47 additions & 0 deletions systemtest/test_model_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,50 @@ def test_set_model_parameters_generalized_centrifugal_force_model(

sim.agent(agent_id).model.b_max = 9.0
assert sim.agent(agent_id).model.b_max == 9.0


@pytest.fixture
def simulation_with_social_force_model():
return jps.Simulation(
model=jps.SocialForceModel(),
geometry=[(0, 0), (10, 0), (10, 10), (0, 10)],
)


def test_set_model_parameters_social_force_model(
simulation_with_social_force_model,
):
sim = simulation_with_social_force_model
wp = sim.add_waypoint_stage((10, 1), 0.5)
journey_id = sim.add_journey(jps.JourneyDescription([wp]))

agent = jps.SocialForceModelAgentParameters(
journey_id=journey_id,
stage_id=wp,
position=(1, 1),
)
agent_id = sim.add_agent(agent)

sim.agent(agent_id).model.velocity = (2.0, -2.0)
assert sim.agent(agent_id).model.velocity == (2.0, -2.0)

sim.agent(agent_id).model.mass = 3.0
assert sim.agent(agent_id).model.mass == 3.0

sim.agent(agent_id).model.desiredSpeed = 4.0
assert sim.agent(agent_id).model.desiredSpeed == 4.0

sim.agent(agent_id).model.reactionTime = 5.0
assert sim.agent(agent_id).model.reactionTime == 5.0

sim.agent(agent_id).model.agentScale = 6.0
assert sim.agent(agent_id).model.agentScale == 6.0

sim.agent(agent_id).model.obstacleScale = 7.0
assert sim.agent(agent_id).model.obstacleScale == 7.0

sim.agent(agent_id).model.ForceDistance = 8.0
assert sim.agent(agent_id).model.ForceDistance == 8.0

sim.agent(agent_id).model.radius = 9.0
assert sim.agent(agent_id).model.radius == 9.0

0 comments on commit 03e566e

Please sign in to comment.