source: trunk/coopr/pyomo/presolve/ @ 1290

Last change on this file since 1290 was 1290, checked in by wehart, 12 years ago

Rework of Pyomo to enable preprocessor actions to
manage all post-instance-generation activities. This includes

. New preprocess action classes in the pyomo/preprocess directory

. A simple preprocessor plugin, which simply applies preprocessor

actions in an order specified by the action-specific ranks

. The AMPL and CPXLP writers are no longer subclasses of the

problem_utils class (which will be removed shortly). Thus, these
classes are no longer directly responsible for how preprocessor
actions take place.

. The Constraint and Objective classes were reworked to integrate

their data into a single _data dictionary. This simplified
the management of id and label information.


. The preprocessors insert some data into the model and model data.

for example, variable id's and label's are specified, which are
what is used when writing out data to NL and LP files. Right now,
this is somewhat ad-hoc; I'm looking for a more systematic way
to managed this information.

. The preprocessors are very much tailored to the needs of the NL

and LP writers. We need to figure out a mechanism to tailoring
preprocessors to specific target solvers (e.g. tailoring
preprocessing for the NL writer, or tailoring preprocessing for
MILP models).

File size: 1.3 KB
1#  _________________________________________________________________________
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 FAST README.txt file.
9#  _________________________________________________________________________
11import pyutilib.plugin
12from coopr.pyomo.base import IPyomoPresolver, IPyomoPresolveAction
15class NumericVarLabelsPresolver(pyutilib.plugin.SingletonPlugin):
16    """
17    This plugin changes variables names to use a simple name that
18    uses the variable id.
19    """
21    pyutilib.plugin.implements(IPyomoPresolveAction)
23    def __init__(self, **kwds):
24        kwds['name'] = "numeric_varlabels"
25        pyutilib.plugin.Plugin.__init__(self, **kwds)
27    def rank(self):
28        return 1000
30    def presolve(self,model):
31        """
32        The main routine to perform the presolve
33        """
34        for id in model._var:
35            model._var[id].label = "x_"+str(id)
36            model._name_varmap[model._var[id].label] = model._var[id]
37        for id in model._con:
38            model._con[id].label = "c_"+str(id)
39        return model
Note: See TracBrowser for help on using the repository browser.