source: trunk/coopr/pyomo/base/pyomo.py @ 1768

Last change on this file since 1768 was 1768, checked in by wehart, 11 years ago

Rework of Coopr to use the new PyUtilib? package decomposition.

NOTE: to use Coopr with this update, we need to work with a new version of coopr_install.

File size: 1.7 KB
Line 
1#  _________________________________________________________________________
2#
3#  Coopr: A COmmon Optimization Python Repository
4#  Copyright (c) 2008 Sandia Corporation.
5#  This software is distributed under the BSD License.
6#  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
7#  the U.S. Government retains certain rights in this software.
8#  For more information, see the Coopr README.txt file.
9#  _________________________________________________________________________
10
11from pyutilib.enum import Enum
12import pyutilib.plugin.core
13from plugin import *
14
15Debug = Enum('none', 'reader', 'preprocess', 'instance', 'all', 'verbose', 'generate', 'normal')
16
17_debug = []
18
19def debug(val=Debug.all):
20  if val not in Debug:
21     raise ValueError, "Bad debugging type: "+str(val)
22  if _debug is True:
23     return True
24  if Debug.all in _debug:
25     return True
26  if type(val) is str:
27     tmp = getattr(Debug,val)
28  else:
29     tmp=val
30  return tmp is not Debug.none and tmp in _debug
31
32def set_debugging(*args):
33    global _debug
34    _debug = []
35    if args == ():
36       args=["all"]
37    for val in args:
38      if type(val) is str:
39         if val not in Debug:
40            raise ValueError, "Unknown debugging tag: "+val
41         _debug.append( getattr(Debug,val) )
42      else:
43         _debug.append(val)
44
45
46def predefined_sets():
47    ep = pyutilib.plugin.core.ExtensionPoint(IPyomoSet)
48    ans = []
49    for item in ep:
50        ans.append( (item.name,item.doc) )
51    return ans
52
53
54def model_components():
55    ep = pyutilib.plugin.core.ExtensionPoint(IModelComponent)
56    ans = []
57    for item in ep:
58        ans.append( (item.name,item.doc) )
59    return ans
Note: See TracBrowser for help on using the repository browser.