def __init__(self, *args, **kwds): """ Constructor """ if kwds.pop("filter", None) is not None: raise TypeError( "'filter' is not a valid keyword argument for ContinuousSet") #if kwds.pop("within", None) is not None: # raise TypeError("'within' is not a valid keyword argument for ContinuousSet") if kwds.pop("dimen", None) is not None: raise TypeError( "'dimen' is not a valid keyword argument for ContinuousSet") if kwds.pop("virtual", None) is not None: raise TypeError( "'virtual' is not a valid keyword argument for ContinuousSet") if kwds.pop("validate", None) is not None: raise TypeError( "'validate' is not a valid keyword argument for ContinuousSet") if len(args) != 0: raise TypeError("A ContinuousSet expects no arguments") kwds.setdefault('ctype', ContinuousSet) kwds.setdefault('ordered', Set.SortedOrder) self._type = ContinuousSet self._changed = False self.concrete = True self.virtual = False self._fe = [] self._discretization_info = {} OrderedSimpleSet.__init__(self, **kwds)
def __init__(self, *args, **kwds): """ Constructor """ if kwds.pop("filter", None) is not None: raise TypeError("'filter' is not a valid keyword argument for " "ContinuousSet") # if kwds.pop("within", None) is not None: # raise TypeError("'within' is not a valid keyword argument for " # ContinuousSet") if kwds.pop("dimen", None) is not None: raise TypeError("'dimen' is not a valid keyword argument for " "ContinuousSet") if kwds.pop("virtual", None) is not None: raise TypeError("'virtual' is not a valid keyword argument for " "ContinuousSet") if kwds.pop("validate", None) is not None: raise TypeError("'validate' is not a valid keyword argument for " "ContinuousSet") if len(args) != 0: raise TypeError("A ContinuousSet expects no arguments") kwds.setdefault('ctype', ContinuousSet) kwds.setdefault('ordered', Set.SortedOrder) self._type = ContinuousSet self._changed = False self.concrete = True self.virtual = False self._fe = [] self._discretization_info = {} OrderedSimpleSet.__init__(self, **kwds)
def construct(self, values=None): OrderedSimpleSet.construct(self, values) for val in self.value: if type(val) is tuple: raise ValueError("ContinuousSet cannot contain tuples") if val.__class__ not in native_numeric_types: raise ValueError( "ContinuousSet can only contain numeric values") if self._bounds is None: raise ValueError("ContinuousSet '%s' must have at least two values indicating "\ "the range over which a differential equation is to be discretized" % (self.name)) if self._bounds[0].__class__ not in native_numeric_types: raise ValueError("Bounds on ContinuousSet must be numeric values") if self._bounds[1].__class__ not in native_numeric_types: raise ValueError("Bounds on ContinuousSet must be numeric values") # TBD: If a user specifies bounds they will be added to the set # unless the user specified bounds have been overwritten during # OrderedSimpleSet construction. This can lead to some unintuitive # behavior when the ContinuousSet is both initialized with values and # bounds are specified. The current implementation is consistent # with how 'Set' treats this situation. if self._bounds[0] not in self.value: self.add(self._bounds[0]) self._sort() if self._bounds[1] not in self.value: self.add(self._bounds[1]) self._sort() if len(self) < 2: raise ValueError("ContinuousSet '%s' must have at least two values indicating "\ "the range over which a differential equation is to be discretized" % (self.name)) self._fe = sorted(self)
def construct(self, values=None): """ Constructs a :py:class:`ContinuousSet` component """ timer = ConstructionTimer(self) OrderedSimpleSet.construct(self, values) for val in self.value: if type(val) is tuple: raise ValueError("ContinuousSet cannot contain tuples") if val.__class__ not in native_numeric_types: raise ValueError("ContinuousSet can only contain numeric " "values") if self._bounds is None: raise ValueError("ContinuousSet '%s' must have at least two values" " indicating the range over which a differential " "equation is to be discretized" % self.name) # If bounds were set using pyomo parameters, get their values lb = value(self._bounds[0]) ub = value(self._bounds[1]) self._bounds = (lb, ub) if self._bounds[0].__class__ not in native_numeric_types: raise ValueError("Bounds on ContinuousSet must be numeric values") if self._bounds[1].__class__ not in native_numeric_types: raise ValueError("Bounds on ContinuousSet must be numeric values") # TBD: If a user specifies bounds they will be added to the set # unless the user specified bounds have been overwritten during # OrderedSimpleSet construction. This can lead to some unintuitive # behavior when the ContinuousSet is both initialized with values and # bounds are specified. The current implementation is consistent # with how 'Set' treats this situation. if self._bounds[0] not in self.value: self.add(self._bounds[0]) self._sort() if self._bounds[1] not in self.value: self.add(self._bounds[1]) self._sort() if len(self) < 2: raise ValueError("ContinuousSet '%s' must have at least two values" " indicating the range over which a differential " "equation is to be discretized" % self.name) self._fe = sorted(self) timer.report()
def construct(self, values=None): """ Constructs a :py:class:`ContinuousSet` component """ timer = ConstructionTimer(self) OrderedSimpleSet.construct(self, values) for val in self.value: if type(val) is tuple: raise ValueError("ContinuousSet cannot contain tuples") if val.__class__ not in native_numeric_types: raise ValueError("ContinuousSet can only contain numeric " "values") if self._bounds is None: raise ValueError("ContinuousSet '%s' must have at least two values" " indicating the range over which a differential " "equation is to be discretized" % self.name) # If bounds were set using pyomo parameters, get their values lb = value(self._bounds[0]) ub = value(self._bounds[1]) self._bounds = (lb, ub) if self._bounds[0].__class__ not in native_numeric_types: raise ValueError("Bounds on ContinuousSet must be numeric values") if self._bounds[1].__class__ not in native_numeric_types: raise ValueError("Bounds on ContinuousSet must be numeric values") # TBD: If a user specifies bounds they will be added to the set # unless the user specified bounds have been overwritten during # OrderedSimpleSet construction. This can lead to some unintuitive # behavior when the ContinuousSet is both initialized with values and # bounds are specified. The current implementation is consistent # with how 'Set' treats this situation. if self._bounds[0] not in self.value: self.add(self._bounds[0]) self._sort() if self._bounds[1] not in self.value: self.add(self._bounds[1]) self._sort() if len(self) < 2: raise ValueError("ContinuousSet '%s' must have at least two values" " indicating the range over which a differential " "equation is to be discretized" % self.name) self._fe = sorted(self) timer.report()