Exemplo n.º 1
0
 def name(self, value):
     _glpk_validate_id(value)
     old_name = getattr(self, 'name', None)
     super(Constraint, Constraint).name.fset(self, value)
     self._name = value
     if self.problem is not None:
         glp_set_row_name(self.problem.problem, glp_find_row(self.problem.problem, old_name), str(value))
         self.problem.constraints.update_key(old_name)
Exemplo n.º 2
0
 def _index(self):
     try:
         i = glp_find_row(self.problem.problem, str(self.name))
         if i != 0:
             return i
         else:
             raise IndexError(
                 "Could not determine row index for variable %s" % self)
     except Exception:  # TODO Change to specific exception type
         return None
Exemplo n.º 3
0
 def index(self):
     try:
         i = glp_find_row(self.problem.problem, str(self.name))
         if i != 0:
             return i
         else:
             raise IndexError(
                 "Could not determine row index for variable %s" % self)
     except:
         return None
Exemplo n.º 4
0
 def name(self, value):
     _glpk_validate_id(value)
     old_name = getattr(self, 'name', None)
     super(Constraint, Constraint).name.fset(self, value)
     self._name = value
     if self.problem is not None:
         glp_set_row_name(self.problem.problem,
                          glp_find_row(self.problem.problem, old_name),
                          str(value))
         self.problem.constraints.update_key(old_name)
Exemplo n.º 5
0
 def index(self):
     try:
         i = glp_find_row(self.problem.problem, str(self.name))
         if i != 0:
             return i
         else:
             raise IndexError(
                 "Could not determine row index for variable %s" % self)
     except:
         return None
Exemplo n.º 6
0
 def _index(self):
     try:
         i = glp_find_row(self.problem.problem, str(self.name))
         if i != 0:
             return i
         else:
             raise IndexError(
                 "Could not determine row index for variable %s" % self)
     except Exception:  # TODO Change to specific exception type
         return None
Exemplo n.º 7
0
 def name(self, value):
     if len(value) > 256:
         raise ValueError(
             "GLPK does not support ID's longer than 256 characters")
     old_name = getattr(self, 'name', None)
     self._name = value
     if self.problem is not None:
         glp_set_row_name(self.problem.problem,
                          glp_find_row(self.problem.problem, old_name),
                          str(value))
         self.problem.constraints.update_key(old_name)
Exemplo n.º 8
0
 def name(self, value):
     old_name = getattr(self, 'name', None)
     self._name = value
     if self.problem is not None:
         glp_set_row_name(self.problem.problem, glp_find_row(self.problem.problem, old_name), str(value))
         self.problem.constraints.update_key(old_name)