monee io¶
native (OMEF JSON)¶
Native JSON (de)serialization for monee Network.
The native format is a plain dict (JSON-friendly) with this shape:
{
"version": 2,
"grids": {name: {"model_type": str, "values": {...}}},
"nodes": [{"id", "grid_id", "child_ids", "position",
"active", "name", "values", "model_type"}],
"childs": [{"id", "active", "name", "values", "model_type"}],
"branches": [{"id", "from_node", "to_node", "grid_id", "grid_ids",
"active", "name", "values", "model_type"}],
"compounds":[{"id", "connected_to", "values", "model_type"}],
}
Each model attribute in a values block is encoded with full fidelity:
plain scalars pass through unchanged, while Var,
Const and Intermediate
are tagged with a reserved __type__ key so they round-trip exactly
(Var keeps its bounds, integer flag and name).
The reader stays backward compatible with the legacy format produced by older
versions and by monee.io.matpower (untagged {"value", "max", "min"}
Var dicts).
Both the public, solver-visible attributes of a model and its JSON-encodable
private attributes (e.g. a storage’s _p_max / _lossy) are serialized, so
models whose behaviour is configured through private state round-trip faithfully.
Private attributes holding object references (grids, sub-models) are skipped on
purpose - they are rebuilt by the compound create() / branch init() hooks.
Known limitations (not represented in the native format): user-supplied
network.constraint / network.objective callables, network-level
extensions registered via add_extension (linepack, LTC, islanding), and
non-default formulations applied with apply_formulation - the latter are
re-derived from the default formulation rules on load.
- monee.io.native.FORMAT_VERSION = 2¶
Bumped whenever the on-disk structure changes in a non-additive way.
- monee.io.native.iter_concrete_grids(grid)[source]¶
Yield the concrete grid object(s) backing a component.
Single-grid components carry their grid directly. Multi-grid branches (coupling points that span e.g. a power and a gas grid) carry a
dictmapping grid type -> grid (and sometimes alistof grids). Yield every distinct concrete grid that exposes aname, in a stable order.
- monee.io.native.model_to_dict(model)[source]¶
Encode a model’s full state.
All public (solver-visible) attributes are serialized; private attributes are serialized only when JSON-encodable, since non-encodable ones hold object references that are rebuilt by
create()/init()on load. A public attribute that cannot be encoded is a genuine gap and raises.
- monee.io.native.network_to_native_dict(network: monee.model.network.Network)[source]¶
Serialize network to the native, JSON-friendly
dictform.- Return type:
- monee.io.native.write_omef_network(file, network: monee.model.network.Network)[source]¶
Serialize network to file as native JSON.
matpower¶
pandapower (experimental)¶
simbench (experimental)¶
CIM / CGMES (experimental)¶
- class monee.io.from_cim.CimImportReport(buses: int = 0, lines: int = 0, transformers: int = 0, loads: int = 0, generators: int = 0, ext_grids: int = 0, skipped: dict = <factory>)[source]¶
Bases:
objectSummary of what was mapped and what was skipped, for transparency.
- monee.io.from_cim.cim_objects_to_network(objects, gen_sign=-1.0)[source]¶
Build a monee
Networkfrom a{mRID: cim_object}mapping.objects is CIMpy’s merged topology dict. gen_sign maps the CGMES SSH terminal sign convention to generation magnitude (default
-1treats a negative SSHpas generation). Returns(network, CimImportReport).
- monee.io.from_cim.import_cim_files(file_list, cgmes_version='cgmes_v2_4_15', gen_sign=-1.0)[source]¶
Import CGMES XML/zip files into a monee
Network.- Parameters:
file_list – Path(s) accepted by
cimpy.cim_import- the EQ/TP/SSH (and optionally SV) profile files of one CGMES model.cgmes_version – CIMpy version tag, e.g.
"cgmes_v2_4_15"or"cgmes_v3_0_0".gen_sign – Sign applied to SSH machine setpoints (see
cim_objects_to_network()).
- Returns:
The electrical
Networkand aCimImportReport.- Return type:
(network, report)
ESDL (experimental)¶
- class monee.io.from_esdl.EsdlImportReport(nodes: int = 0, el_branches: int = 0, gas_pipes: int = 0, heat_pipes: int = 0, loads: int = 0, sources: int = 0, skipped: dict = <factory>)[source]¶
Bases:
objectSummary of what was mapped and what was skipped, for transparency.