el1xr_opt.Modules.oM_Features#
- class el1xr_opt.Modules.oM_Features.Feature(name, flag, default=0, makes_integer=False, makes_cone=False, module=None, doc='')[source]#
Bases:
object
- el1xr_opt.Modules.oM_Features.apply_flag_defaults(parameters_dict)[source]#
Give every catalogue flag a default so a case whose Option file predates the flag still runs (no KeyError). Existing values are left untouched.
- el1xr_opt.Modules.oM_Features.network_mode_class(mode)[source]#
Problem class implied by a network mode.
- el1xr_opt.Modules.oM_Features.select_balance_mode(model)[source]#
Read and validate the balance formulation for a model. Defaults to ‘nodal’ when the case predates the flag (apply_flag_defaults seeds it).
- el1xr_opt.Modules.oM_Features.balance_compatible_with_network(balance_mode, network_mode)[source]#
Whether a balance formulation can express a network mode. Always True – balance (bookkeeping) and network mode (physics) are orthogonal axes. The helper exists to validate the names and to make the orthogonality explicit: arc works with the AC and three-phase modes too (carrying active+reactive power and both line ends), and the branch-flow modes are arc-based by construction.
- el1xr_opt.Modules.oM_Features.require_balance_mode_implemented(model)[source]#
Guard for the in-core build: only ‘nodal’ is wired into the main model. Selecting ‘arc’ raises with a pointer to the modernization plan, rather than silently building a nodal model. Returns the validated mode (‘nodal’).
- el1xr_opt.Modules.oM_Features.detect_problem_class(model)[source]#
Classify the built model by inspecting its variables, constraints and objective. Robust and feature-agnostic: it reflects what was actually built, not what flags claim. Returns one of LP/MILP/QP/MIQP/SOCP/MISOCP/NLP/MINLP.
- el1xr_opt.Modules.oM_Features.register_cost(model, var_name, kind='ps')[source]#
Register a cost-component variable for the objective aggregation.
- el1xr_opt.Modules.oM_Features.register_revenue(model, var_name, kind='ps')[source]#
Register a revenue-component variable for the objective aggregation.
- el1xr_opt.Modules.oM_Features.seed_objective_registry(model)[source]#
Seed the registry with the model’s built-in cost/revenue components, in the original order, so the aggregation is identical to the previous hard-coded sum. Features may register additional terms after this.
- el1xr_opt.Modules.oM_Features.aggregate_terms(model, optmodel, p, sc, terms)[source]#
Sum the registered
termsfor one (period, scenario), by kind.
- el1xr_opt.Modules.oM_Features.register_horizon_constant(model, cost_var, amount)[source]#
Declare a per-(period, scenario) cost that is CONSTANT over the horizon.
cost_varis the cost-component Var name (removed from every window’s recourse) andamountis the once-counted full-horizon scalar (added to the master).
- el1xr_opt.Modules.oM_Features.register_horizon_threshold(model, cost_var, native_constraints, quantity_var, count, items, node_of, coeff_of, subgroups, level_subgroup)[source]#
Declare a ‘sum of the N largest <quantity> per <subgroup>’ peak charge for the threshold-LP reformulation. Fields (see
el1xr_temporal_bendersfor the use):cost_var native peak-cost Var name (pinned to 0; the LP replaces it) native_constraints native peak constraint names to deactivate quantity_var metered quantity Var name, indexed (period, scenario, n, node) count N, the number of peaks items the charge-bearing keys (e.g. the retailers) node_of item -> node, to index the quantity Var coeff_of item -> cost per unit threshold (already divided by N) subgroups the per-period subgroups the top-N is taken within (months) level_subgroup attr name of the (load level, subgroup) membership pairs on the built model (e.g. ``n2m``)
- el1xr_opt.Modules.oM_Features.register_horizon_unsupported(model, reason)[source]#
Mark a horizon-coupling charge the temporal split cannot decompose yet, so the decomposition raises a clear error instead of returning a wrong objective.
- el1xr_opt.Modules.oM_Features.seed_horizon_coupling(model)[source]#
Seed the built-in (electricity) horizon-coupling descriptors on
model.Reads
model.Parand the sets only, so it runs on a structure-only model (oM_Sequence.build_structure). The electricity fixed network charge is a constant; the peak demand charge is the sum of the N largest grid imports per month per retailer (a threshold). A Daily-tariff peak charge is not yet supported by the reformulation, so it is marked unsupported rather than mis-handled. A new sector with such a charge appends its own descriptor here.
- el1xr_opt.Modules.oM_Features.check_solver_for_model(model, solver)[source]#
Detect the model’s class and check the chosen solver can solve it.
Returns
(problem_class, ok, message).okis False only when the class is known-incompatible with a known solver (e.g. a SOCP case on HiGHS); the message also lists the solvers and builders that do support the class.