Skip to content

Commit

Permalink
Constrain number of high values to number of agents
Browse files Browse the repository at this point in the history
  • Loading branch information
chraibi committed Oct 22, 2024
1 parent e58592c commit e39989f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/motivation_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ def __post_init__(self) -> None:
if self.seed is not None:
random.seed(self.seed)

if self.number_high_value > self.nagents:
logging.warning(
f"Configuration error: {self.number_high_value} > {self.nagents}. Change value to match!"
)
self.number_high_value = self.nagents

high_value_agents = set(random.sample(self.agent_ids, self.number_high_value))
for n in self.agent_ids:
if n in high_value_agents:
Expand Down

0 comments on commit e39989f

Please sign in to comment.