OMMX Python SDK 3.0.x#

Note

Python SDK 3.0.0 contains breaking API changes. A migration guide is available in the Python SDK v2 to v3 Migration Guide.

Unreleased#

Indicator Constraint support (#789, #790, #795, #796)#

IndicatorConstraint is now a first-class feature in OMMX. An indicator constraint expresses a conditional relationship: a constraint f(x) <= 0 (or f(x) = 0) is enforced only when a user-defined binary indicator variable z = 1. When z = 0, the constraint is unconditionally satisfied.

Use Constraint.with_indicator() to create an IndicatorConstraint from an existing constraint. The PySCIPOpt Adapter converts these into SCIP’s addConsIndicator:

from ommx.v1 import DecisionVariable, Instance
from ommx_pyscipopt_adapter import OMMXPySCIPOptAdapter

b = DecisionVariable.binary(0)
x = DecisionVariable.continuous(1, lower=0, upper=10)

# b = 1 → x <= 5
ic = (x <= 5).with_indicator(b)

instance = Instance.from_components(
    decision_variables=[b, x],
    objective=x,
    constraints=[b >= 1],  # Force b = 1
    indicator_constraints=[ic],
    sense=Instance.MAXIMIZE,
)

solution = OMMXPySCIPOptAdapter.solve(instance)
assert abs(solution.objective - 5.0) < 1e-6

Evaluation results#

After solving, Solution and SampleSet provide DataFrames for indicator constraints:

The indicator_active column disambiguates between “the indicator was OFF (constraint trivially satisfied)” and “the indicator was ON and the constraint was satisfied.” Note that indicator constraints do not have dual variables, as dual values are not well-defined for conditional constraints.

Relax and restore#

Indicator constraints support the same relax/restore workflow as regular constraints:

removed_reasons_df separation#

As part of this work, removed_reason is no longer a column in constraints_df. Instead, removed_reasons_df is available as a separate table on both Solution and SampleSet, which can be joined with constraints_df:

# Regular constraints
df = solution.constraints_df.join(solution.removed_reasons_df)

# Indicator constraints
df = solution.indicator_constraints_df.join(solution.indicator_removed_reasons_df)

Adapter Capability model (#790, #814)#

As specialized constraint types (such as IndicatorConstraint) are added and support varies across solvers, an Adapter Capability model has been introduced. Adapters declare their supported capabilities via ADDITIONAL_CAPABILITIES, and Instance.reduce_capabilities() converts any constraint type outside that set into regular constraints (Big-M for indicator / SOS1, linear equality for one-hot) before solving. Callers can inspect Instance.required_capabilities to see which non-standard types an instance currently carries.

from ommx.v1 import AdditionalCapability
from ommx.adapter import SolverAdapter

class MySolverAdapter(SolverAdapter):
    ADDITIONAL_CAPABILITIES = frozenset({AdditionalCapability.Indicator})

Currently, the PySCIPOpt Adapter declares indicator and SOS1 support. Each OMMX Adapter will need changes to support Python SDK 3.0.0 — specifically, calling super().__init__(instance) so that unsupported capabilities are converted automatically.

3.0.0 Alpha 1#

Static Badge

See the GitHub Release above for full details. The following summarizes the main changes. This is a pre-release version. APIs may change before the final release.

Complete Rust re-export of ommx.v1 and ommx.artifact types (#770, #771, #774, #775, #782)#

Python SDK 3.0.0 is fully based on Rust/PyO3. In 2.0.0, the core implementation was rewritten in Rust while Python wrapper classes remained for compatibility. In 3.0.0, those Python wrappers are removed entirely — all types in ommx.v1 and ommx.artifact are now direct re-exports from Rust, and the protobuf Python runtime dependency is eliminated. The .raw attribute that previously provided access to the underlying PyO3 implementation has also been removed.

Migration to Sphinx and ReadTheDocs hosting (#780, #785)#

In v2, the Sphinx-based API Reference and Jupyter Book-based documentation were each hosted on GitHub Pages. In v3, documentation has been fully migrated to Sphinx and is now hosted on ReadTheDocs. GitHub Pages will continue to host the documentation as of v2.5.1, but all future updates will be on ReadTheDocs only.