Skip to content

odys.solvers.outcome

What a solver run returns. SolveStatus is public (result.solver_status); SolveOutcome is internal: the solver returns it and OptimalDispatchResults is built from it.

See Results in the User Guide for reading the status of a run.

What a solver run returns: status, termination condition, objective value and solution.

SolveOutcome

Bases: BaseModel

Result of solving a model, independent of the problem it was built from.

Without a solution, the objective value is None and the solution is empty.

Source code in src/odys/solvers/outcome.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class SolveOutcome(BaseModel):
    """Result of solving a model, independent of the problem it was built from.

    Without a solution, the objective value is `None` and the solution is empty.
    """

    model_config = ConfigDict(frozen=True, extra="forbid", arbitrary_types_allowed=True)

    status: SolveStatus
    termination_condition: str
    objective_value: float | None
    solution: xr.Dataset

    @property
    def has_solution(self) -> bool:
        """Whether the solver returned a solution."""
        return self.objective_value is not None

has_solution property

Whether the solver returned a solution.

SolveStatus

Bases: StrEnum

Status reported by the solver.

A solution is available only with OK, and not always then: a time limit reached before a feasible solution is found also reports OK. Check SolveOutcome.has_solution.

Source code in src/odys/solvers/outcome.py
 9
10
11
12
13
14
15
16
17
18
19
20
class SolveStatus(StrEnum):
    """Status reported by the solver.

    A solution is available only with `OK`, and not always then: a time limit reached before a feasible
    solution is found also reports `OK`. Check `SolveOutcome.has_solution`.
    """

    OK = "ok"
    WARNING = "warning"
    ERROR = "error"
    ABORTED = "aborted"
    UNKNOWN = "unknown"