Result

The result contract shared by every ortidy solver.

Every solver returns a SolveResult carrying the user’s frame (with assignment columns added) plus a structured status, objective value, and solve metadata. This replaces the old print("no optimal solution"); return None pattern. A FEASIBLE solution is a success, not a failure.

class ortidy.result.SolveStatus(*values)[source]

Bases: str, Enum

Backend-neutral solve status.

The string values are stable and safe to compare against / serialize.

property is_success: bool

True for OPTIMAL and FEASIBLE — both are usable answers.

ortidy.result.from_cp_sat(status)[source]

Map a CP-SAT solve status to SolveStatus.

Accepts Any because the status type is an int in older OR-Tools and a CpSolverStatus enum in newer ones — this is a thin cross-version adapter.

Parameters:

status (Any)

Return type:

SolveStatus

ortidy.result.from_mip(status)[source]

Map a pywraplp linear-solver status code to SolveStatus.

Parameters:

status (int)

Return type:

SolveStatus

class ortidy.result.SolveResult(frame, status, objective=None, metadata=<factory>)[source]

Bases: object

Structured solver output.

Parameters:
frame

The result dataframe in the same backend the user passed in (pandas in → pandas out, Polars in → Polars out). None when no solution frame could be produced (e.g. infeasible models).

Type:

Any

status

A SolveStatus enum member.

Type:

ortidy.result.SolveStatus

objective

The objective value, when the solver reports one.

Type:

float | None

metadata

Solve metadata — wall_time (seconds), gap, solver name, and any solver-specific extras.

Type:

dict[str, Any]

property is_success: bool

True when the solver returned a usable answer (OPTIMAL/FEASIBLE).