Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
from_model.py
Go to the documentation of this file.
1# Copyright 2010-2025 Google LLC
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14"""Utilities for finding the model associated with a variable/constraint etc.
15
16This file is an implementation detail and not part of the MathOpt public API.
17"""
18
19from typing import Protocol
20from ortools.math_opt.python.elemental import elemental
21
22
23class FromModel(Protocol):
24
25 __slots__ = ()
26
27 @property
28 def elemental(self) -> elemental.Elemental: ...
29
30
31def model_is_same(e1: FromModel, e2: FromModel) -> None:
32 if e1.elemental is not e2.elemental:
33 raise ValueError(
34 f"Expected two elements from the same model, but observed {e1} from"
35 f" model named: '{e1.elemental.model_name!r}', and {e2} from model"
36 f" named: '{e2.elemental.model_name!r}'."
37 )
None model_is_same(FromModel e1, FromModel e2)
Definition from_model.py:31