Example #1
0
 def ub(self, ub):
     if self.equality.any():
         raise ValueError("The ub array can not be set "
                          "when there are indices of the "
                          "equality array that are True")
     if ub is None:
         ub = numpy.inf
     if isinstance(ub, numpy.ndarray):
         numpy.copyto(self._ub, ub)
     elif isinstance(ub, NumericValue):
         raise ValueError("ub must be set to "
                          "a simple numeric type "
                          "or a numpy array")
     else:
         self._ub.fill(ub)
Example #2
0
 def lb(self, lb):
     if self.equality.any():
         raise ValueError("The lb array can not be set "
                          "when there are indices of the "
                          "equality array that are True")
     if lb is None:
         lb = -numpy.inf
     if isinstance(lb, numpy.ndarray):
         numpy.copyto(self._lb, lb)
     elif isinstance(lb, NumericValue):
         raise ValueError("lb must be set to "
                          "a simple numeric type "
                          "or a numpy array")
     else:
         self._lb.fill(lb)
Example #3
0
 def rhs(self, rhs):
     if rhs is None:
         # None has a different meaning depending on the
         # context (lb or ub), so there is no way to
         # interpret this
         raise ValueError("Constraint right-hand side can not "
                          "be assigned a value of None.")
     elif isinstance(rhs, NumericValue):
         raise ValueError("rhs must be set to "
                          "a simple numeric type "
                          "or a numpy array")
     elif isinstance(rhs, numpy.ndarray):
         numpy.copyto(self._lb, rhs)
         numpy.copyto(self._ub, rhs)
     else:
         self._lb.fill(rhs)
         self._ub.fill(rhs)
     self._equality.fill(True)