# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2025
# 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.
# ___________________________________________________________________________
from pyomo.core import (
Var,
Block,
Constraint,
Param,
Set,
SetOf,
Suffix,
Expression,
Objective,
SortComponents,
value,
ConstraintList,
)
from pyomo.core.base import TransformationFactory, VarData
from pyomo.core.plugins.transform.hierarchy import Transformation
from pyomo.common.config import ConfigBlock, ConfigValue, NonNegativeFloat
from pyomo.common.modeling import unique_component_name
from pyomo.repn.standard_repn import generate_standard_repn
from pyomo.common.collections import ComponentMap, ComponentSet
from pyomo.opt import TerminationCondition
from pyomo.util.config_domains import ComponentDataSet
import logging
logger = logging.getLogger('pyomo.contrib.fme')
def _check_var_bounds_filter(constraint):
"""Check if the constraint is already implied by the variable bounds"""
# this is one of our constraints, so we know that it is >=.
min_lhs = 0
for v, coef in constraint['map'].items():
if coef > 0:
if v.lb is None:
return True # we don't have var bounds with which to imply the
# constraint...
min_lhs += coef * v.lb
elif coef < 0:
if v.ub is None:
return True # we don't have var bounds with which to imply the
# constraint...
min_lhs += coef * v.ub
# we do need value here since we didn't control v.lb and v.ub above.
if value(min_lhs) >= constraint['lower']:
return False # constraint implied by var bounds
return True
[docs]
def gcd(a, b):
while b != 0:
a, b = b, a % b
return abs(a)
[docs]
def lcm(ints):
a = ints[0]
for b in ints[1:]:
a = abs(a * b) // gcd(a, b)
return a