State#
- class State#
State wrapper for Python
- __contains__(key: int) bool#
- __len__() int#
- __repr__() str#
- items() list[tuple[int, float]]#
- keys() list[int]#
- load_qplib_solution(path: str, *, num_variables: int) State#
Load a published QPLIB
.solfile into aState.Pass the variable count of the original QPLIB instance as
num_variables. Omitted variables receive zero. The standard QPLIB solution namesxN,bN, andiNmap to OMMX IDN - 2;objvaris ignored because the objective is computed byevaluate(). Custom names and other solvers'.solformats are not supported. Names are case insensitive.Malformed input, duplicate IDs, nonfinite values, and out-of-range IDs raise
ValueErrorwith a line number. File read failures raiseRuntimeError. Loading does not check bounds or feasibility.>>> import tempfile >>> from pathlib import Path >>> from ommx import State >>> with tempfile.TemporaryDirectory() as directory: ... path = Path(directory) / "example.sol" ... _ = path.write_text("objvar 12\nx2 0.5\nb4 1\n") ... state = State.load_qplib_solution(str(path), num_variables=3) >>> state.entries {0: 0.5, 1: 0.0, 2: 1.0}
- set(key: int, value: float) None#
- to_v1_bytes() bytes#
- values() list[float]#
- property entries: dict[int, float]#