Skip to content

model_builder

Construct result atoms from evaluated constraint-handler variables.

ModelBuilder

Convert evaluated values and warnings into a fresh Python-side model.

__init__

__init__(ignored_warnings: dict[Kind, tuple[int, bool]]) -> None

Initialize warning filtering.

Parameters:

Name Type Description Default
ignored_warnings dict[Kind, tuple[int, bool]]

Warning kinds mapped to their literal and active-ignore flag.

required

add_multimap

add_multimap(symbol: Symbol, values: dict | Multimap) -> None

Convert multimap keys and their values to result atoms.

Parameters:

Name Type Description Default
symbol Symbol

Variable symbol.

required
values dict | Multimap

Mapping from keys to collections of values.

required

add_set

add_set(symbol: Symbol, values: set | frozenset) -> None

Convert a set value, retaining the existing bad-value fallback.

Parameters:

Name Type Description Default
symbol Symbol

Variable symbol.

required
values set | frozenset

Set elements to export.

required

add_value

add_value(symbol: Symbol, value: Any) -> None

Dispatch a variable value to its result-atom conversion.

Parameters:

Name Type Description Default
symbol Symbol

Variable symbol.

required
value Any

Evaluated value to export.

required

add_warnings

add_warnings(errors: Iterable[Warning]) -> None

Add warnings unless their ignore literal is active.

Parameters:

Name Type Description Default
errors Iterable[Warning]

Warnings to filter and export.

required

build

build(variables: Iterable[VariableType], evaluate_variables: Iterable[EvaluateVariable], errors: Iterable[Warning]) -> set[ResultAtom]

Build a fresh model without changing variable or solver state.

Parameters:

Name Type Description Default
variables Iterable[VariableType]

Variables whose values and warnings should be exported.

required
evaluate_variables Iterable[EvaluateVariable]

Explicit expression evaluations to export.

required
errors Iterable[Warning]

Additional optimization and propagator warnings.

required

Returns:

Type Description
set[ResultAtom]

A set of result atoms and non-ignored warnings.