Skip to main content
Glama
ortools_models.py1.61 kB
from enum import Enum from typing import Any from pydantic import BaseModel, Field class VariableType(str, Enum): """Enum for supported variable types in OR-Tools.""" BOOLEAN = "boolean" INTEGER = "integer" INTERVAL = "interval" class Variable(BaseModel): """Model representing a variable in an OR-Tools problem.""" name: str type: VariableType domain: tuple[int, int] | None = None # For integer variables shape: list[int] | None = None # For array variables description: str = "" class Constraint(BaseModel): """Model representing a constraint in an OR-Tools problem.""" expression: str description: str = "" class ObjectiveType(str, Enum): """Enum for optimization objective types.""" MINIMIZE = "minimize" MAXIMIZE = "maximize" FEASIBILITY = "feasibility" # Just find a feasible solution class Objective(BaseModel): """Model representing an optimization objective.""" type: ObjectiveType = ObjectiveType.FEASIBILITY expression: str | None = None class Problem(BaseModel): """Model representing a complete OR-Tools constraint programming problem.""" variables: list[Variable] constraints: list[Constraint] objective: Objective | None = None parameters: dict[str, Any] = Field(default_factory=dict) description: str = "" class Solution(BaseModel): """Model representing a solution to an OR-Tools problem.""" values: dict[str, Any] is_feasible: bool status: str objective_value: float | None = None statistics: dict[str, Any] = Field(default_factory=dict)

Implementation Reference

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sdiehl/usolver'

If you have feedback or need assistance with the MCP directory API, please join our Discord server