Skip to content

4 allow for conditional events#17

Open
Hackatro wants to merge 5 commits into
mainfrom
4-allow-for-conditional-events
Open

4 allow for conditional events#17
Hackatro wants to merge 5 commits into
mainfrom
4-allow-for-conditional-events

Conversation

@Hackatro
Copy link
Copy Markdown
Contributor

@Hackatro Hackatro commented Jun 2, 2026

feat(events): finalize conditional event resolution + tests

Hackatro added 3 commits May 26, 2026 13:20
…PDL effects propagate only when their trigger condition is met

fix(tick_writer): correct enabled flag
refactor(agents): remove dead capacity_factor parameter
@Hackatro Hackatro linked an issue Jun 2, 2026 that may be closed by this pull request
"""
arg_scale = self.model.environment.get_shock_scale("farm_capacity_arg")
farm_capacity = 1.0 + arg_scale * (self.scenario.farm_capacity_arg - 1.0)
farm_capacity = self.model.environment.get_effective_value("farm_capacity_arg")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this call different to the other ones?
Above env.get_effective_value is called, here it's self.model.environment.get_effective_value. What am I missing?



def _move_split(self, upstream_list, share: float, capacity_factor: float = 1.0, shock_param: str = "", exclude_arg=False, exclude_usa=False):
def _move_split(self, upstream_list, share: float, param_name: str = "", exclude_arg=False, exclude_usa=False):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explicit excludes need to be removed in the future

# ------------------------------------------------------------------

def _move(self, upstream, capacity_factor: float = 1.0, shock_param: str = ""):
def _move(self, upstream, param_name: str = ""):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

param_name is too vague imo.
Should be a more descriptive name


# drought severity: use racker value if available
bra_scale = self.shock_scales.get("farm_capacity_bra", 0.0)
bra_value = self.get_effective_value("farm_capacity_bra")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explicit bra values should be made dynamic in the future



# --- Aggregation constants ---
_CAPACITY_PARAMS = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make dynamic in the future

edef = self._events.get(eid)
if edef is None:
continue
if self._evaluate_condition(edef.condition, day):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't it possible that a conditional event activates on the same simulation step as it's condition activated with this implementation?

if mapped is not None:
pct = _parse_percent(str(raw))
param = mapped
value = round(1.0 + pct / 100.0, 6)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the 1.0 + pct? doesn't this just add 1 % to all values?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow for conditional events

2 participants