qaekwy.model.modeller

This module provides the Modeller class, which is the primary interface for building optimization models.

Modeller

The Modeller class encapsulates all the components of an optimization model, including variables, constraints, and objectives.

Methods

__init__()

Initializes a new, empty Modeller instance.

add_variable(variable)

Adds a variable to the model.

  • Parameters:
    • variable (Variable | ArrayVariable): The variable to add.
  • Returns: The Modeller instance, for method chaining.

add_constraint(constraint)

Adds a constraint to the model.

  • Parameters:
    • constraint (AbstractConstraint | Expression): The constraint to add. If an Expression is provided, it is automatically wrapped in a RelationalExpression.
  • Returns: The Modeller instance, for method chaining.

add_objective(objective)

Adds an optimization objective to the model.

  • Parameters:
    • objective (SpecificMinimum | SpecificMaximum): The objective to add.
  • Returns: The Modeller instance, for method chaining.

set_searcher(searcher)

Sets the search strategy for the solver.

  • Parameters:
    • searcher (SearcherType): The search strategy to use.
  • Returns: The Modeller instance, for method chaining.

set_cutoff(cutoff)

Sets a cutoff condition to terminate the search early.

  • Parameters:
    • cutoff (Cutoff): The cutoff condition.
  • Returns: The Modeller instance, for method chaining.

set_callback_url(callback_url)

Sets a URL to be called when a solution is found.

  • Parameters:
    • callback_url (str): The callback URL.
  • Returns: The Modeller instance, for method chaining.

set_solution_limit(solution_limit)

Sets the maximum number of solutions to find.

  • Parameters:
    • solution_limit (int): The maximum number of solutions.
  • Returns: The Modeller instance, for method chaining.

to_json()

Serializes the model to a JSON-compatible dictionary.

  • Returns: A dict representing the model.

from_json(json_data)

Creates a Modeller instance from a JSON representation.

  • Parameters:
    • json_data (dict): The JSON data.
  • Returns: A Modeller instance.