Skip to content

Commit

Permalink
Merge pull request #29 from scioip34/feature/replay
Browse files Browse the repository at this point in the history
Feature/replay
  • Loading branch information
mezdahun authored Feb 18, 2022
2 parents 830b735 + f8c32c4 commit d81a8d3
Show file tree
Hide file tree
Showing 12 changed files with 1,074 additions and 102 deletions.
1 change: 1 addition & 0 deletions abm/contrib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
GREEN = (50, 150, 50)
PURPLE = (130, 0, 130)
GREY = (230, 230, 230)
DARK_GREY = (210, 210, 210)
YELLOW = (190, 175, 50)
RED = (255, 0, 0)
LIGHT_RED = (255, 180, 180)
Expand Down
8 changes: 8 additions & 0 deletions abm/contrib/ifdb_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
INFLUX_PSWD = "password"
INFLUX_DB_NAME = "home"

T = float(int(envconf["T"]))
if T <= 1000:
write_batch_size = T
else:
if T % 1000 != 0:
raise Exception("Simulation time (T) must be dividable by 1000 or smaller than 1000!")
write_batch_size = 1000

# SAVE_DIR is counted from the ABM parent directory.
SAVE_DIR = envconf.get("SAVE_ROOT_DIR", "abm/data/simulation_data")

Expand Down
87 changes: 87 additions & 0 deletions abm/data/metaprotocol/experiments/exp7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
description_text = """
Experiment file using the MetaRunner interfacing language to define a set of criteria for batch simulations
Title: Experiment 1
Goal: Understand the balance of social vs individual excitablility in fixed environment
Defined by: mezdahun and DominikDeffner @ github
"""
from abm.metarunner.metarunner import Tunable, Constant, MetaProtocol, TunedPairRestrain

# Defining fixed criteria for all automized simulations/experiments
fixed_criteria = [
Constant("USE_IFDB_LOGGING", 1),
Constant("SAVE_CSV_FILES", 1),
Constant("WITH_VISUALIZATION", 0), # how does the simulation speed scale with N
Constant("TELEPORT_TO_MIDDLE", 0),
Constant("GHOST_WHILE_EXPLOIT", 1),
Constant("PATCHWISE_SOCIAL_EXCLUSION", 1),
Constant("POOLING_TIME", 0),
Constant("MOV_EXP_VEL_MIN", 1),
Constant("MOV_EXP_VEL_MAX", 1),
Constant("MOV_REL_DES_VEL", 1),
Constant("SHOW_VISUAL_FIELDS", 0),
Constant("SHOW_VISUAL_FIELDS_RETURN", 0),
Constant("SHOW_VISION_RANGE", 0),
Constant("ENV_WIDTH", 500),
Constant("ENV_HEIGHT", 500),
Constant("VISUAL_FIELD_RESOLUTION", 1200),
Constant("VISUAL_EXCLUSION", 1),
Constant("VISION_RANGE", 1000),
Constant("AGENT_CONSUMPTION", 1),
Constant("RADIUS_AGENT", 10),
Constant("RADIUS_RESOURCE", 40),
Constant("MAX_RESOURCE_QUALITY", -1), # so that the minimum value will be used as definite
Constant("MAX_RESOURCE_PER_PATCH", -1), # so that the minimum value will be used as definite
Constant("MOV_EXP_TH_MIN", -0.25),
Constant("MOV_EXP_TH_MAX", 0.25),
Constant("MOV_REL_TH_MAX", 0.5),
Constant("CONS_STOP_RATIO", 0.1),
Constant("REGENERATE_PATCHES", 1),
Constant("DEC_FN", 0.5),
Constant("DEC_FR", 0.5),
Constant("DEC_TAU", 10),
Constant("DEC_BW", 0),
Constant("DEC_WMAX", 1),
Constant("DEC_BU", 0),
Constant("DEC_UMAX", 1),
Constant("DEC_GW", 0.085),
Constant("DEC_GU", 0.085),
Constant("DEC_TW", 0.5),
Constant("DEC_TU", 0.5)
]

# Defining decision param
sum_resources = 3000
num_patches = [1, 2, 3, 5, 6, 10]
criteria_exp = [
Constant("N", 10),
Constant("AGENT_FOV", 1), # unlimited
Tunable("DEC_EPSW", values_override=[0, 0.5, 0.75, 1, 2, 3]),
Constant("DEC_EPSU", 1),
Constant("MIN_RESOURCE_QUALITY", 0.25),
Tunable("MIN_RESOURCE_PER_PATCH", values_override=[int(sum_resources/np) for np in num_patches]),
Constant("DEC_SWU", 0),
Constant("DEC_SUW", 0),
Tunable("N_RESOURCES", values_override=num_patches),
Constant("T", 15000)
]

# Creating metaprotocol and add defined criteria
mp = MetaProtocol(experiment_name="Experiment7", num_batches=10, parallel=True,
description=description_text)
for crit in fixed_criteria:
mp.add_criterion(crit)
for crit in criteria_exp:
mp.add_criterion(crit)

# Locking the overall resource units in environment
constant_runits = TunedPairRestrain("N_RESOURCES", "MIN_RESOURCE_PER_PATCH", sum_resources)
mp.add_tuned_pair(constant_runits)

# Generating temporary env files with criterion combinations. Comment this out if you want to continue simulating due
# to interruption
mp.generate_temp_env_files()

# Running the simulations
mp.run_protocols()

2 changes: 1 addition & 1 deletion abm/environment/rescource.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, id, radius, position, env_size, color, window_pad, resc_units
self.position = np.array(position, dtype=np.float64) # saved
self.center = (self.position[0] + self.radius, self.position[1] + self.radius)
self.color = color
self.resc_left_color = (color[0]-20, color[1]-20, color[2]-20)
self.resc_left_color = colors.DARK_GREY
self.unit_per_timestep = quality # saved

# Environment related parameters
Expand Down
Loading

0 comments on commit d81a8d3

Please sign in to comment.