Changeset 3649


Ignore:
Timestamp:
Feb 17, 2011 4:27:33 PM (9 years ago)
Author:
jdsiiro
Message:

Updating GDP to track changes in log handling within Pyomo ([3616:3617])

Location:
coopr.gdp/trunk/coopr/gdp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • coopr.gdp/trunk/coopr/gdp/bigm.py

    r3423 r3649  
    1313from coopr.gdp import *
    1414
     15import logging
     16logger = logging.getLogger('coopr.pyomo')
    1517
    1618class BigM_Transforamtion(Plugin):
     
    105107                    n += ('_lo','_hi')[i]
    106108
    107                 if pyomo.debug("verbose"):
    108                     print "GDP(BigM): Promoting local constraint '%s' as '%s'"\
    109                           % (constraint.name, n)
     109                if __debug__ and logger.isEnabledFor(logging.DEBUG):
     110                    logger.debug("GDP(BigM): Promoting local constraint "
     111                                 "'%s' as '%s'", constraint.name, n)
    110112                M_expr = (m[i]-bounds[i])*(1-disjunct.indicator_var)
    111113                if i == 0:
     
    119121    def _xform_var(self, name, var, disjunct, instance):
    120122        # "Promote" the local variables up to the main model
    121         if pyomo.debug("verbose"):
    122             print "GDP(BigM): Promoting local variable '%s' as '%s'" % \
    123                   (var.name, name)
     123        if __debug__ and logger.isEnabledFor(logging.DEBUG):
     124            logger.debug("GDP(BigM): Promoting local variable '%s' as '%s'",
     125                         var.name, name)
    124126        instance._add_component(name, var)
    125127
     
    151153                            M[j] = None
    152154            elif degree != -1:
    153                 print "GDP(BigM): cannot estimate M for nonlinear "\
    154                       "expressions.\n\t(found while processing " + name + ")"
     155                logger.error("GDP(BigM): cannot estimate M for nonlinear "
     156                             "expressions.\n\t(found while processing %s)",
     157                             name)
    155158                return m
    156159
  • coopr.gdp/trunk/coopr/gdp/chull.py

    r3547 r3649  
    1414from coopr.pyomo.base.var import _VarValue
    1515from coopr.gdp import *
     16
     17import logging
     18logger = logging.getLogger('coopr.pyomo')
    1619
    1720class ConvexHull_Transforamtion(Plugin):
     
    119122    def _xform_var(self, name, var, varMap, disjunct, instance):
    120123        # "Promote" the local variables up to the main model
    121         if pyomo.debug("verbose"):
    122             print "GDP(cHull): Promoting local variable '%s' as '%s'" % \
    123                   (var.name, name)
     124        if __debug__ and logger.isEnabledFor(logging.DEBUG):
     125            logger.debug("GDP(cHull): Promoting local variable '%s' as '%s'",
     126                         var.name, name)
    124127        instance._add_component(name, var)
    125128
     
    152155               
    153156            if c.lower is not None:
    154                 if pyomo.debug("verbose"):
    155                     print "GDP(cHull): Promoting constraint '%s' as '%s_lo'" %\
    156                           (name, name)
     157                if __debug__ and logger.isEnabledFor(logging.DEBUG):
     158                    logger.debug("GDP(cHull): Promoting constraint " +
     159                                 "'%s' as '%s_lo'", name, name)
    157160                bound = c.lower() - constant
    158161                if bound != 0:
     
    164167                newC.construct()
    165168            if c.upper is not None:
    166                 if pyomo.debug("verbose"):
    167                     print "GDP(cHull): Promoting constraint '%s' as '%s_hi'" %\
    168                           (name, name)
     169                if __debug__ and logger.isEnabledFor(logging.DEBUG):
     170                    logger.debug("GDP(cHull): Promoting constraint " +
     171                                 "'%s' as '%s_hi'", name, name)
    169172                bound = c.upper() - constant
    170173                if bound != 0:
  • coopr.gdp/trunk/coopr/gdp/disjunct.py

    r3428 r3649  
    1414from pyutilib.misc.indent_io import StreamIndenter
    1515
     16import logging
     17logger = logging.getLogger('coopr.pyomo')
    1618
    1719class GDP_Error(Exception):
     
    6769
    6870    def construct(self, data=None):
    69         if pyomo.debug("verbose") or pyomo.debug("normal"):     #pragma:nocover
    70             print "Constructing disjunct "+self.name
     71        if __debug__ and logger.isEnabledFor(logging.DEBUG):
     72            logger.debug("Constructing disjunct %s", self.name)
    7173        if self._rule is None:
    7274            if self._no_rule_init is None:
    73                 msg = 'WARNING: No construction rule or expression ' \
    74                       "specified for disjunct '%s'"
    75                 print msg % self.name
     75                logger.warn("No construction rule or expression "
     76                            "specified for disjunct '%s'", self.name)
    7677            return
    7778        if self._constructed:
     
    9293        for val in self._index:
    9394            name = _generate_name(val)
    94             if pyomo.debug("verbose"):                      #pragma:nocover
    95                 print "   Constructing disjunct index "+str(name)
     95            if __debug__ and logger.isEnabledFor(logging.DEBUG):
     96                logger.debug("   Constructing disjunct index %s", str(name))
    9697            if val is None:
    9798                _self_rule(self, self.model)
     
    153154    def set_M(self, M_list):
    154155        if self._M is not None:
    155             print "WARNING: Discarding pre-defined M values for " + self.name
     156            logger.warn("Discarding pre-defined M values for %s", self.name)
    156157        self._M = M_list
    157158
     
    193194        idx = args[0:-1]
    194195        if len(idx)>1 and idx not in self.disj._index:
    195             print "WARNING: Constructing disjunction from " \
    196                 "unrecognized index: "+str(idx)
     196            logger.warn("Constructing disjunction from "
     197                        "unrecognized index: %s", str(idx))
    197198        elif len(idx) == 1 and idx[0] not in self.disj._index:
    198             print "WARNING: Constructing disjunction from " \
    199                 "unrecognized index: "+str(idx[0])
     199            logger.warn("Constructing disjunction from "
     200                        "unrecognized index: %s", str(idx[0]))
    200201
    201202        if self.disj._disjunction_rule is not None:
Note: See TracChangeset for help on using the changeset viewer.