-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from scioip34/feature/interactive-tool
Feature/interactive tool
- Loading branch information
Showing
11 changed files
with
1,108 additions
and
126 deletions.
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
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 |
---|---|---|
@@ -1,43 +1,62 @@ | ||
from contextlib import ExitStack | ||
|
||
from abm.simulation.sims import Simulation | ||
from abm.simulation.isims import PlaygroundSimulation | ||
|
||
from xvfbwrapper import Xvfb | ||
|
||
import os | ||
# loading env variables from dotenv file | ||
from dotenv import dotenv_values | ||
|
||
EXP_NAME = os.getenv("EXPERIMENT_NAME", "") | ||
|
||
|
||
def start(parallel=False): | ||
def start(parallel=False, headless=False): | ||
root_abm_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) | ||
envconf = dotenv_values(os.path.join(root_abm_dir, f"{EXP_NAME}.env")) | ||
sim = Simulation(N=int(float(envconf["N"])), | ||
T=int(float(envconf["T"])), | ||
v_field_res=int(envconf["VISUAL_FIELD_RESOLUTION"]), | ||
agent_fov=float(envconf['AGENT_FOV']), | ||
framerate=int(float(envconf["INIT_FRAMERATE"])), | ||
with_visualization=bool(int(float(envconf["WITH_VISUALIZATION"]))), | ||
width=int(float(envconf["ENV_WIDTH"])), | ||
height=int(float(envconf["ENV_HEIGHT"])), | ||
show_vis_field=bool(int(float(envconf["SHOW_VISUAL_FIELDS"]))), | ||
show_vis_field_return=bool(int(envconf['SHOW_VISUAL_FIELDS_RETURN'])), | ||
pooling_time=int(float(envconf["POOLING_TIME"])), | ||
pooling_prob=float(envconf["POOLING_PROBABILITY"]), | ||
agent_radius=int(float(envconf["RADIUS_AGENT"])), | ||
N_resc=int(float(envconf["N_RESOURCES"])), | ||
min_resc_perpatch=int(float(envconf["MIN_RESOURCE_PER_PATCH"])), | ||
max_resc_perpatch=int(float(envconf["MAX_RESOURCE_PER_PATCH"])), | ||
min_resc_quality=float(envconf["MIN_RESOURCE_QUALITY"]), | ||
max_resc_quality=float(envconf["MAX_RESOURCE_QUALITY"]), | ||
patch_radius=int(float(envconf["RADIUS_RESOURCE"])), | ||
regenerate_patches=bool(int(float(envconf["REGENERATE_PATCHES"]))), | ||
agent_consumption=int(float(envconf["AGENT_CONSUMPTION"])), | ||
ghost_mode=bool(int(float(envconf["GHOST_WHILE_EXPLOIT"]))), | ||
patchwise_exclusion=bool(int(float(envconf["PATCHWISE_SOCIAL_EXCLUSION"]))), | ||
teleport_exploit=bool(int(float(envconf["TELEPORT_TO_MIDDLE"]))), | ||
vision_range=int(float(envconf["VISION_RANGE"])), | ||
visual_exclusion=bool(int(float(envconf["VISUAL_EXCLUSION"]))), | ||
show_vision_range=bool(int(float(envconf["SHOW_VISION_RANGE"]))), | ||
use_ifdb_logging=bool(int(float(envconf["USE_IFDB_LOGGING"]))), | ||
save_csv_files=bool(int(float(envconf["SAVE_CSV_FILES"]))), | ||
parallel=parallel | ||
) | ||
vscreen_width = int(float(envconf["ENV_WIDTH"])) + 100 | ||
vscreen_height = int(float(envconf["ENV_HEIGHT"])) + 100 | ||
with ExitStack() if not headless else Xvfb(width=vscreen_width, height=vscreen_height) as xvfb: | ||
sim = Simulation(N=int(float(envconf["N"])), | ||
T=int(float(envconf["T"])), | ||
v_field_res=int(envconf["VISUAL_FIELD_RESOLUTION"]), | ||
agent_fov=float(envconf['AGENT_FOV']), | ||
framerate=int(float(envconf["INIT_FRAMERATE"])), | ||
with_visualization=bool(int(float(envconf["WITH_VISUALIZATION"]))), | ||
width=int(float(envconf["ENV_WIDTH"])), | ||
height=int(float(envconf["ENV_HEIGHT"])), | ||
show_vis_field=bool(int(float(envconf["SHOW_VISUAL_FIELDS"]))), | ||
show_vis_field_return=bool(int(envconf['SHOW_VISUAL_FIELDS_RETURN'])), | ||
pooling_time=int(float(envconf["POOLING_TIME"])), | ||
pooling_prob=float(envconf["POOLING_PROBABILITY"]), | ||
agent_radius=int(float(envconf["RADIUS_AGENT"])), | ||
N_resc=int(float(envconf["N_RESOURCES"])), | ||
min_resc_perpatch=int(float(envconf["MIN_RESOURCE_PER_PATCH"])), | ||
max_resc_perpatch=int(float(envconf["MAX_RESOURCE_PER_PATCH"])), | ||
min_resc_quality=float(envconf["MIN_RESOURCE_QUALITY"]), | ||
max_resc_quality=float(envconf["MAX_RESOURCE_QUALITY"]), | ||
patch_radius=int(float(envconf["RADIUS_RESOURCE"])), | ||
regenerate_patches=bool(int(float(envconf["REGENERATE_PATCHES"]))), | ||
agent_consumption=int(float(envconf["AGENT_CONSUMPTION"])), | ||
ghost_mode=bool(int(float(envconf["GHOST_WHILE_EXPLOIT"]))), | ||
patchwise_exclusion=bool(int(float(envconf["PATCHWISE_SOCIAL_EXCLUSION"]))), | ||
teleport_exploit=bool(int(float(envconf["TELEPORT_TO_MIDDLE"]))), | ||
vision_range=int(float(envconf["VISION_RANGE"])), | ||
visual_exclusion=bool(int(float(envconf["VISUAL_EXCLUSION"]))), | ||
show_vision_range=bool(int(float(envconf["SHOW_VISION_RANGE"]))), | ||
use_ifdb_logging=bool(int(float(envconf["USE_IFDB_LOGGING"]))), | ||
save_csv_files=bool(int(float(envconf["SAVE_CSV_FILES"]))), | ||
parallel=parallel | ||
) | ||
sim.write_batch_size = 100 | ||
sim.start() | ||
|
||
|
||
def start_headless(): | ||
start(headless=True) | ||
|
||
|
||
def start_playground(): | ||
sim = PlaygroundSimulation() | ||
sim.start() |
Oops, something went wrong.