feat: solve() accepts objective_factors and objective_mode

Add objective_factors and objective_mode as optional parameters to solve().
Resolve defaults at function entry and validate using existing _validate_objective.
Normalize objective_factors to ensure all required keys (EBSC) are present.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Pagwin 2026-06-11 19:22:59 -04:00
parent 8a775dd941
commit ead700adf4
No known key found for this signature in database
GPG key ID: 81137023740CA260

View file

@ -1015,8 +1015,18 @@ def solve(
verbose=True, verbose=True,
fixed_choices=FIXED_CHOICES, fixed_choices=FIXED_CHOICES,
resource_constraints=None, resource_constraints=None,
objective_factors=None,
objective_mode=None,
): ):
if objective_factors is None:
objective_factors = OBJECTIVE_FACTORS
if objective_mode is None:
objective_mode = OBJECTIVE_MODE
_validate_objective(objective_factors, objective_mode)
# Normalized copy: every key present, missing keys = 0.
obj_factors = {k: objective_factors.get(k, 0) for k in "EBSC"}
# ---- build the city list ----------------------------------------- # ---- build the city list -----------------------------------------
# cities: list[tuple[int, dict]] where the dict has keys "type" and # cities: list[tuple[int, dict]] where the dict has keys "type" and
# "adjacent_to". TODO: adjacency unused; for Industrialist agent. # "adjacent_to". TODO: adjacency unused; for Industrialist agent.