-
Notifications
You must be signed in to change notification settings - Fork 28
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
Anticipation Velocity Model (AVM) #1432
Open
chraibi
wants to merge
52
commits into
PedestrianDynamics:master
Choose a base branch
from
chraibi:CollisionFreeSpeedModelV3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
46c0bd8
Change version of jupedsim
chraibi 09001fb
First version compiles
chraibi 778523f
Running CollisionFreeSpeedModelV3.
chraibi 6e65c65
update example
chraibi 0e1838e
Rename model CollisionFreeSpeedModelV3 to AVM
chraibi f2344d9
remove unused imports
chraibi b7e4218
Implement direction of agents
chraibi 9c6b365
Implement boundaryRepulsion
chraibi ec801e4
Update the direction according to eq 7
chraibi de57a2e
validate parameters of the model
chraibi 42bb1db
Update functionality for walls behind walls
chraibi 681b518
Add anticipation and reaction times to C-API
chraibi 732f1a6
Fix bug in wall calculation
chraibi 7dfffef
rename get reaction time
chraibi 407bae0
Add two parameters and remove unused parameter from AVM API
chraibi f79dd6f
python bindings for AVM
chraibi efb7ca7
Add test can construct AVM
chraibi f83fbfa
Init new parameters in libjupedsim simulation
chraibi b7147a6
Add headon examples
chraibi c8df214
Wrong sign for wall influence
chraibi df7041f
Update velocity of agents
chraibi 21bcc41
Fix bug: Apply Update velocity of agents
chraibi 23305ae
Fix missmatch of neighbor and geometry parameters
chraibi f8a5ca1
Implement sliding walls
chraibi 269b608
Refactor sliding walls
chraibi bdd9299
Add notebook to compare all models
chraibi e6cf0e0
Update models for anticipation velocity model
chraibi 6f41508
Update notebook with time plots
chraibi 9cc1865
Add documentation for AVM
chraibi f2d88a7
link notebook to documentation
chraibi 920259f
Update model notebook
chraibi 3ca16f1
Add requirement for notebook
chraibi 6d37d3b
rename notebook and add it to index
chraibi 8fbc35d
Add more explanatory context to the notebook
chraibi 354da4b
Add tests for AVM and update AVM-parameters contraints
chraibi 9092048
merge two cells in the notebook
chraibi bf8d459
Add test default parameters of AVM
chraibi 0b9352f
update AVM default parameters
chraibi 5e124cf
update clang format
chraibi 264c09b
clang-format my code
chraibi 42da8e2
clangformating
chraibi c615170
clang-formating a bunch
chraibi 5710c4c
clang formatting
chraibi e339d71
sorting imports and ruffing
chraibi 0045715
use clang-format 18
chraibi 7db6421
clang format
chraibi 35da307
Fixed python formatting
Ozaq 9dfd0a4
Format cpp code to match newer clang-format version
Ozaq 7320f23
Fix formatting
Ozaq d19228b
set version to 1.3.0
chraibi 2444f89
update example 7
chraibi 9fbb00d
reformatting and restructuring the comparison-models notebook
chraibi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#! /usr/bin/env python3 | ||
|
||
# Copyright © 2012-2024 Forschungszentrum Jülich GmbH | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
import pathlib | ||
import sys | ||
|
||
import jupedsim as jps | ||
import shapely | ||
from shapely import Polygon | ||
|
||
|
||
def main(): | ||
room1 = Polygon([(0, 0), (10, 0), (10, 10), (0, 10)]) # Room 1 (10m x 10m) | ||
room2 = Polygon( | ||
[(15, 0), (25, 0), (25, 10), (15, 10)] | ||
) # Room 2 (10m x 10m) | ||
width = 0.8 | ||
num_agents = 10 | ||
corridor = Polygon( | ||
[ | ||
(10, 5 - width / 2), | ||
(15, 5 - width / 2), | ||
(15, 5 + width / 2), | ||
(10, 5 + width / 2), | ||
] | ||
) | ||
geometry = room1.union(room2).union(corridor) | ||
# geometry = shapely.GeometryCollection(shapely.box(0, -2.5, 50, 2.5)) | ||
# exit_polygon = shapely.box(48, -2.5, 50, 2.5) # | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove commented out code |
||
exit_polygon = Polygon([(24, 4.5), (25, 4.5), (25, 5.5), (24, 5.5)]) | ||
trajectory_file = "example_7.sqlite" | ||
simulation = jps.Simulation( | ||
model=jps.AnticipationVelocityModel(), | ||
geometry=geometry, | ||
trajectory_writer=jps.SqliteTrajectoryWriter( | ||
output_file=pathlib.Path(trajectory_file) | ||
), | ||
) | ||
|
||
exit_id = simulation.add_exit_stage(exit_polygon) | ||
journey = jps.JourneyDescription([exit_id]) | ||
journey_id = simulation.add_journey(journey) | ||
|
||
start_positions = jps.distribute_by_number( | ||
polygon=Polygon([(0, 0), (5, 0), (5, 10), (0, 10)]), | ||
# shapely.box(0, -2.5, 5, 2.5), | ||
number_of_agents=num_agents, | ||
distance_to_agents=0.5, | ||
distance_to_polygon=0.2, | ||
) | ||
|
||
for position in start_positions: | ||
simulation.add_agent( | ||
jps.AnticipationVelocityModelAgentParameters( | ||
journey_id=journey_id, | ||
stage_id=exit_id, | ||
position=position, | ||
radius=0.2, | ||
# strength_neighbor_repulsion=8, | ||
# range_neighbor_repulsion=0.1, | ||
# strength_geometry_repulsion=5, | ||
# range_geometry_repulsion=0.1, | ||
) | ||
) | ||
|
||
while simulation.agent_count() > 0 and simulation.iteration_count() < 3000: | ||
try: | ||
simulation.iterate() | ||
except KeyboardInterrupt: | ||
print("CTRL-C Received! Shutting down") | ||
sys.exit(1) | ||
print( | ||
f"Simulation completed after {simulation.iteration_count()} iterations ({simulation.elapsed_time()} s)" | ||
) | ||
print(f"{trajectory_file = }") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
253 changes: 253 additions & 0 deletions
253
libjupedsim/include/jupedsim/anticipation_velocity_model.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,253 @@ | ||
/* Copyright © 2012-2024 Forschungszentrum Jülich GmbH */ | ||
/* SPDX-License-Identifier: LGPL-3.0-or-later */ | ||
#pragma once | ||
|
||
#include "error.h" | ||
#include "export.h" | ||
#include "operational_model.h" | ||
#include "types.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* Opaque type for a Anticipation Velocity Model Builder | ||
*/ | ||
typedef struct JPS_AnticipationVelocityModelBuilder_t* JPS_AnticipationVelocityModelBuilder; | ||
|
||
/** | ||
* Creates a Anticipation Velocity Model builder. | ||
* @return the builder | ||
*/ | ||
JUPEDSIM_API JPS_AnticipationVelocityModelBuilder JPS_AnticipationVelocityModelBuilder_Create(); | ||
|
||
/** | ||
* Creates a JPS_OperationalModel of type Anticipation Velocity Model from the | ||
* JPS_AnticipationVelocityModelBuilder. | ||
* @param handle the builder to operate on | ||
* @param[out] errorMessage if not NULL: will be set to a JPS_ErrorMessage in case of an error | ||
* @return a JPS_AnticipationVelocityModel or NULL if an error occured. | ||
*/ | ||
JUPEDSIM_API JPS_OperationalModel JPS_AnticipationVelocityModelBuilder_Build( | ||
JPS_AnticipationVelocityModelBuilder handle, | ||
JPS_ErrorMessage* errorMessage); | ||
|
||
/** | ||
* Frees a JPS_AnticipationVelocityModelBuilder | ||
* @param handle to the JPS_AnticipationVelocityModelBuilder to free. | ||
*/ | ||
JUPEDSIM_API void | ||
JPS_AnticipationVelocityModelBuilder_Free(JPS_AnticipationVelocityModelBuilder handle); | ||
|
||
/** | ||
* Opaque type of Anticipation Velocity Model state | ||
*/ | ||
typedef struct JPS_AnticipationVelocityModelState_t* JPS_AnticipationVelocityModelState; | ||
|
||
/** | ||
* Read strength neighbor repulsion of this agent. | ||
* @param handle of the Agent to access. | ||
* @return strength neighbor repulsion of this agent | ||
*/ | ||
JUPEDSIM_API double JPS_AnticipationVelocityModelState_GetStrengthNeighborRepulsion( | ||
JPS_AnticipationVelocityModelState handle); | ||
|
||
/** | ||
* Write strength neighbor repulsion of this agent. | ||
* @param handle of the Agent to access. | ||
* @param strengthNeighborRepulsion of this agent. | ||
*/ | ||
JUPEDSIM_API void JPS_AnticipationVelocityModelState_SetStrengthNeighborRepulsion( | ||
JPS_AnticipationVelocityModelState handle, | ||
double strengthNeighborRepulsion); | ||
|
||
/** | ||
* Read range neighbor repulsion of this agent. | ||
* @param handle of the Agent to access. | ||
* @return range neighbor repulsion of this agent | ||
*/ | ||
JUPEDSIM_API double JPS_AnticipationVelocityModelState_GetRangeNeighborRepulsion( | ||
JPS_AnticipationVelocityModelState handle); | ||
|
||
/** | ||
* Write range neighbor repulsion of this agent. | ||
* @param handle of the Agent to access. | ||
* @param rangeNeighborRepulsion of this agent. | ||
*/ | ||
JUPEDSIM_API void JPS_AnticipationVelocityModelState_SetRangeNeighborRepulsion( | ||
JPS_AnticipationVelocityModelState handle, | ||
double rangeNeighborRepulsion); | ||
|
||
/** | ||
* Read strength geometry repulsion of this agent. | ||
* @param handle of the Agent to access. | ||
* @return strength geometry repulsion of this agent | ||
*/ | ||
JUPEDSIM_API double JPS_AnticipationVelocityModelState_GetStrengthGeometryRepulsion( | ||
JPS_AnticipationVelocityModelState handle); | ||
|
||
/** | ||
* Write strength geometry repulsion of this agent. | ||
* @param handle of the Agent to access. | ||
* @param strengthGeometryRepulsion of this agent. | ||
*/ | ||
JUPEDSIM_API void JPS_AnticipationVelocityModelState_SetStrengthGeometryRepulsion( | ||
JPS_AnticipationVelocityModelState handle, | ||
double strengthGeometryRepulsion); | ||
|
||
/** | ||
* Read range geometry repulsion of this agent. | ||
* @param handle of the Agent to access. | ||
* @return range geometry repulsion of this agent | ||
*/ | ||
JUPEDSIM_API double JPS_AnticipationVelocityModelState_GetRangeGeometryRepulsion( | ||
JPS_AnticipationVelocityModelState handle); | ||
|
||
/** | ||
* Write strength neighbor repulsion of this agent. | ||
* @param handle of the Agent to access. | ||
* @param rangeGeometryRepulsion of this agent. | ||
*/ | ||
JUPEDSIM_API void JPS_AnticipationVelocityModelState_SetRangeGeometryRepulsion( | ||
JPS_AnticipationVelocityModelState handle, | ||
double rangeGeometryRepulsion); | ||
|
||
/** | ||
* Read e0 of this agent. | ||
* @param handle of the Agent to access. | ||
* @return e0 of this agent | ||
*/ | ||
JUPEDSIM_API JPS_Point | ||
JPS_AnticipationVelocityModelState_GetE0(JPS_AnticipationVelocityModelState handle); | ||
|
||
/** | ||
* Write e0 of this agent. | ||
* @param handle of the Agent to access. | ||
* @param e0 of this agent. | ||
*/ | ||
JUPEDSIM_API void | ||
JPS_AnticipationVelocityModelState_SetE0(JPS_AnticipationVelocityModelState handle, JPS_Point e0); | ||
|
||
/** | ||
* Read time gap of this agent. | ||
* @param handle of the Agent to access. | ||
* @return time gap of this agent | ||
*/ | ||
JUPEDSIM_API double | ||
JPS_AnticipationVelocityModelState_GetTimeGap(JPS_AnticipationVelocityModelState handle); | ||
|
||
/** | ||
* Write time gap of this agent. | ||
* @param handle of the Agent to access. | ||
* @param time_gap of this agent. | ||
*/ | ||
JUPEDSIM_API void JPS_AnticipationVelocityModelState_SetTimeGap( | ||
JPS_AnticipationVelocityModelState handle, | ||
double time_gap); | ||
|
||
/** | ||
* Read tau of this agent. | ||
* @param handle of the Agent to access. | ||
* @return tau of this agent | ||
*/ | ||
JUPEDSIM_API double | ||
JPS_AnticipationVelocityModelState_GetTau(JPS_AnticipationVelocityModelState handle); | ||
|
||
/** | ||
* Write tau of this agent. | ||
* @param handle of the Agent to access. | ||
* @param tau of this agent. | ||
*/ | ||
JUPEDSIM_API void | ||
JPS_AnticipationVelocityModelState_SetTau(JPS_AnticipationVelocityModelState handle, double tau); | ||
|
||
/** | ||
* Read v0 of this agent. | ||
* @param handle of the Agent to access. | ||
* @return v0 of this agent | ||
*/ | ||
JUPEDSIM_API double | ||
JPS_AnticipationVelocityModelState_GetV0(JPS_AnticipationVelocityModelState handle); | ||
|
||
/** | ||
* Write v0 of this agent. | ||
* @param handle of the Agent to access. | ||
* @param v0 of this agent. | ||
*/ | ||
JUPEDSIM_API void | ||
JPS_AnticipationVelocityModelState_SetV0(JPS_AnticipationVelocityModelState handle, double v0); | ||
|
||
/** | ||
* Read radius of this agent. | ||
* @param handle of the Agent to access. | ||
* @return radius of this agent | ||
*/ | ||
JUPEDSIM_API double | ||
JPS_AnticipationVelocityModelState_GetRadius(JPS_AnticipationVelocityModelState handle); | ||
|
||
/** | ||
* Write radius of this agent in meters. | ||
* @param handle of the Agent to access. | ||
* @param radius (m) of this agent. | ||
*/ | ||
JUPEDSIM_API void JPS_AnticipationVelocityModelState_SetRadius( | ||
JPS_AnticipationVelocityModelState handle, | ||
double radius); | ||
|
||
/** | ||
* Describes parameters of an Agent in Anticipation Velocity Model | ||
*/ | ||
typedef struct JPS_AnticipationVelocityModelAgentParameters { | ||
/** | ||
* Position of the agent. | ||
* The position needs to inside the accessible area. | ||
*/ | ||
JPS_Point position{0, 0}; | ||
/** | ||
* Defines the journey this agent will take use | ||
*/ | ||
JPS_JourneyId journeyId = 0; | ||
/** | ||
* Defines the current stage of its journey | ||
*/ | ||
JPS_StageId stageId = 0; | ||
|
||
/** | ||
* @param time_gap of the agents using this profile (T in the OV-function) | ||
*/ | ||
double time_gap = 1.; | ||
/** | ||
*@param v0 of the agents using this profile(desired speed) double radius; | ||
*/ | ||
double v0 = 1.2; | ||
/** | ||
*@param radius of the agent in 'meters' | ||
*/ | ||
double radius = 0.2; | ||
|
||
/** | ||
* Strength of the repulsion from neighbors | ||
*/ | ||
double strengthNeighborRepulsion{8.0}; | ||
|
||
/** | ||
* Range of the repulsion from neighbors | ||
*/ | ||
double rangeNeighborRepulsion{0.1}; | ||
|
||
/** | ||
* Strength of the repulsion from geometry boundaries | ||
*/ | ||
double strengthGeometryRepulsion{5.0}; | ||
|
||
/** | ||
* Range of the repulsion from geometry boundaries | ||
*/ | ||
double rangeGeometryRepulsion{0.02}; | ||
|
||
} JPS_AnticipationVelocityModelAgentParameters; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the version bump, 1.3.0 is still unreleased