# ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of Sandia, LLC, the U.S. Government retains certain rights in this
# software. This software is distributed under the 3-clause BSD License.
# ____________________________________________________________________________________
"""Big-M Generalized Disjunctive Programming transformation module."""
import logging
from pyomo.common.autoslots import AutoSlots
from pyomo.common.collections import ComponentMap
from pyomo.common.config import ConfigDict, ConfigValue
from pyomo.common.gc_manager import PauseGC
from pyomo.common.modeling import unique_component_name
from pyomo.common.deprecation import deprecated, deprecation_warning
from pyomo.contrib.cp.transform.logical_to_disjunctive_program import (
LogicalToDisjunctive,
)
from pyomo.core import (
Block,
BooleanVar,
Connector,
Constraint,
Param,
Set,
SetOf,
Var,
Expression,
SortComponents,
TraversalStrategy,
value,
RangeSet,
NonNegativeIntegers,
Binary,
Any,
)
from pyomo.core.base import TransformationFactory, Reference
import pyomo.core.expr as EXPR
from pyomo.gdp import Disjunct, Disjunction, GDP_Error
from pyomo.gdp.plugins.bigm_mixin import (
_BigM_MixIn,
_get_bigM_suffix_list,
_warn_for_unused_bigM_args,
)
from pyomo.gdp.plugins.gdp_to_mip_transformation import GDP_to_MIP_Transformation
from pyomo.gdp.transformed_disjunct import _TransformedDisjunct
from pyomo.gdp.util import is_child_of, _get_constraint_transBlock, _to_dict
from pyomo.core.util import target_list
from pyomo.network import Port
from pyomo.repn import generate_standard_repn
from weakref import ref as weakref_ref, ReferenceType
logger = logging.getLogger('pyomo.gdp.bigm')
class _BigMData(AutoSlots.Mixin):
__slots__ = ('bigm_src',)
def __init__(self):
# we will keep a map of constraints (hashable, ha!) to a tuple to
# indicate what their M value is and where it came from, of the form:
# ((lower_value, lower_source, lower_key), (upper_value, upper_source,
# upper_key)), where the first tuple is the information for the lower M,
# the second tuple is the info for the upper M, source is the Suffix or
# argument dictionary and None if the value was calculated, and key is
# the key in the Suffix or argument dictionary, and None if it was
# calculated. (Note that it is possible the lower or upper is
# user-specified and the other is not, hence the need to store
# information for both.)
self.bigm_src = {}
Block.register_private_data_initializer(_BigMData)