# Changeset 2064

Ignore:
Timestamp:
Dec 29, 2009 5:16:16 PM (10 years ago)
Message:

Misc rework of variable presolving. Now, model
statistics are stored in a more obvious location, and using more
verbose names.

Location:
coopr.pyomo/trunk/coopr/pyomo
Files:
4 edited

Unmodified
Removed
• ## coopr.pyomo/trunk/coopr/pyomo/base/PyomoModel.py

 r2053 import pyutilib.plugin.core from pyutilib.math import * from pyutilib.misc import quote_split, tuplize from pyutilib.misc import quote_split, tuplize, Container from coopr.opt import ProblemFormat, ResultsFormat, guess_format self._con = {} self._obj = {} # # Model statistics # self.statistics = Container() def components(self, ctype=None): def nvariables(self): return len(self._var) return self.statistics.number_of_variables def variable(self, name): def nconstraints(self): return len(self._con) return self.statistics.number_of_constraints def constraint(self, name): def nobjectives(self): return len(self._obj) return self.statistics.number_of_objectives def objective(self, name):
• ## coopr.pyomo/trunk/coopr/pyomo/base/var.py

 r2025 return True return False def is_binary(self): return self.var.is_binary() def is_integer(self): return self.var.is_integer() def is_continuous(self): return self.var.is_continuous() def simplify(self, model): except KeyError: raise KeyError, "Unknown index " + str(ndx) + " in variable " + self.name def is_binary(self): return isinstance(self.domain, BooleanSet) def is_integer(self): return isinstance(self.domain, IntegerSet) def is_continuous(self): return not (self.is_binary() or self.is_integer()) def simplify(self, model):
• ## coopr.pyomo/trunk/coopr/pyomo/io/ampl.py

 r1992 # LINE 2 # print >>OUTPUT, " " + str(model.vnum), nc, no, nrange, str(neqn) +\ print >>OUTPUT, " " + str(model.statistics.number_of_variables), nc, no, nrange, str(neqn) +\ "\t# vars, constraints, objectives, ranges, eqns" # # LINE 8 # nsno = model.vnum nsno = model.statistics.number_of_variables ngc = ngo = 0 for key in Obj: # "k" lines # n1 = model.vnum - 1 n1 = model.statistics.number_of_variables - 1 print >>OUTPUT, "k" + str(n1) ktot = 0
• ## coopr.pyomo/trunk/coopr/pyomo/presolve/identify_vars.py

 r1993 tmp.id = self.vnum model._var[self.vnum] = tmp if model._var[self.vnum].is_binary(): model.statistics.number_of_binary_variables += 1 elif model._var[self.vnum].is_integer(): model.statistics.number_of_integer_variables += 1 else: model.statistics.number_of_continuous_variables +=1 self.vnum += 1 # self.cnum=0 self.onum=0 model.statistics.number_of_binary_variables = 0 model.statistics.number_of_integer_variables = 0 model.statistics.number_of_continuous_variables = 0 # # Indicate that all variables are unused model._con[self.cnum] = C._data[cndx] self.cnum += 1 model.vnum=self.vnum model.cnum=self.cnum model.onum=self.onum model.statistics.number_of_variables=self.vnum model.statistics.number_of_constraints=self.cnum model.statistics.number_of_objectives=self.onum return model
Note: See TracChangeset for help on using the changeset viewer.