Model Components#

API Reference > Modeling > Model Components

The model component schema classes represent individual elements of an optimization model. These classes define the structure and properties of constraints, variables, objectives, and model notation used throughout the DecisionAI platform.

Purpose:

  • Define the schema for optimization model components

  • Provide structured access to model elements

  • Enable serialization and communication of model data

  • Support model analysis and manipulation

Constraints#

Schema class for representing optimization constraints.

Constraint#

Represents a single optimization constraint.

class decision_ai.client.schemas.constraint.Constraint(*, code: str | None = None, math_formulation: str | None = None, description: str | None = None, is_user_constraint: bool | None = None, incompatible: bool | None = None, incompatibility_reason: str | None = None, enabled: bool = True, priority: Literal['hard', 'A', 'B', 'C'] = 'hard')#

Bases: BaseModel

A constraint of a model.

code#

The code of the constraint. Defaults to None.

Type:

str | None, optional

math_formulation#

The math formulation of the constraint. Defaults to None.

Type:

str | None, optional

description#

The description of the constraint. Defaults to None.

Type:

str | None, optional

is_user_constraint#

Whether the constraint is a user constraint. Defaults to None.

Type:

bool | None, optional

incompatible#

Whether the constraint is incompatible with the current input data. Defaults to None.

Type:

bool | None, optional

incompatibility_reason#

The reason the constraint being incompatible with the current input data. Defaults to None.

Type:

str | None, optional

enabled#

Whether the constraint is enabled. Defaults to True.

Type:

bool, optional

priority#

The priority level for soft constraints. Defaults to “hard”.

Type:

Priority, optional

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Key Properties:

  • Code - The constraint code/expression

  • Math Formulation - Mathematical representation of the constraint

  • Description - Human-readable description

  • Priority - Constraint priority (for soft constraints)

  • Enabled - Whether the constraint is active

  • Is User Constraint - Whether it was added by a user

Variables#

Schema class for representing optimization variables.

Variable#

Represents a single optimization variable.

class decision_ai.client.schemas.variable.Variable(*, code: str | None = None, description: str | None = None, is_user_variable: bool | None = None, type_hint: str | None = None, enabled: bool = True, mathematical_latex_notation: str | None = None, notation_explanation: str | None = None)#

Bases: BaseModel

A class to store the variables of a model.

code#

The code of the variable.

Type:

str | None

description#

The description of the variable.

Type:

str | None

is_user_variable#

Whether the variable is a user variable.

Type:

bool | None

type_hint#

The type hint of the variable.

Type:

str | None

enabled#

Whether the variable is enabled.

Type:

bool

mathematical_latex_notation#

The mathematical notation in LaTeX format.

Type:

str | None

notation_explanation#

Explanation of the mathematical notation.

Type:

str | None

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Key Properties:

  • Code - The variable code/definition

  • Description - Human-readable description

  • Type Hint - Variable type information

  • Enabled - Whether the variable is active

  • Is User Variable - Whether it was added by a user

Objective#

Schema for representing the optimization objective function.

class decision_ai.client.schemas.objective.Objective(*, code: str | None = None, description: str | None = None, math_formulation: str | None = None, incompatible: bool | None = None, incompatibility_reason: str | None = None)#

Bases: BaseModel

A class to store the objective of a model.

code#

The code of the objective.

Type:

str | None

description#

The description of the objective.

Type:

str | None

math_formulation#

The mathematical formulation of the objective.

Type:

str | None

incompatible#

Whether the objective is incompatible.

Type:

bool | None

incompatibility_reason#

The reason the objective is incompatible.

Type:

str | None

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Key Properties:

  • Code - The objective function code

  • Description - Human-readable description

  • Math Formulation - Mathematical representation of the objective

Model Notation#

Classes for representing mathematical notation and model documentation.

Notation#

Represents mathematical notation used in the model.

class decision_ai.client.schemas.summary.Notation(*, input_or_variable_name: str, mathematical_latex_notation: str, explanation: str)#

Bases: BaseModel

A class to store the notations of a model.

input_or_variable_name#

The name of the input or variable.

Type:

str

mathematical_latex_notation#

The mathematical notation wrapped with $…$.

Type:

str

explanation#

The explanation of the notation.

Type:

str

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

OptModelNotations#

Collection of notations for a complete optimization model.

class decision_ai.client.schemas.summary.OptModelNotations(*, input_notations: list[Notation] | None = None, variable_notations: list[Notation] | None = None)#

Bases: BaseModel

A class to store the notations of a model.

input_notations#

The input notations. Defaults to None.

Type:

list[Notation] | None, optional

variable_notations#

The variable notations. Defaults to None.

Type:

list[Notation] | None, optional

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Usage Examples#

Working with Constraints:

# Access constraints from a model
constraints = model.get_constraints()

# Iterate through constraints
for constraint_id, constraint in constraints.items():
    print(f"Constraint {constraint_id}:")
    print(f"Code: {constraint.code}")
    print(f"Priority: {constraint.priority}")
    print(f"Enabled: {constraint.enabled}")

Working with Variables:

# Access variables from a model
variables = model.get_variables()

# Iterate through variables
for var_id, variable in variables.items():
    print(f"Variable {var_id}:")
    print(f"Code: {variable.code}")
    print(f"Type: {variable.type_hint}")
    print(f"Enabled: {variable.enabled}")

Back to: API Reference (API Reference Overview)