hopsy.add_box_constraints#
- class hopsy.add_box_constraints(problem: Problem, lower_bound: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], upper_bound: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], simplify=True)#
Adds box constraints to all dimensions. This will extend
hopsy.Problem.A
andhopsy.Problem.b
of the returnedhopsy.Problem
to have rows. Box constraints are added naively, meaning that we do neither check whether the dimension may be already somehow bound nor check whether the very same constraint already exists. You can remove redundant constraints efficiently using the PolyRound toolbox or by using thehopsy.round()
function, uses PolyRound to remove redundant constraints and also rounds the polytope.If
lower_bound
andupper_bound
are bothfloat
, then every dimension will be bound as . If lower_bound` andupper_bound
are bothnumpy.ndarray
with appropriate length, then every dimension will be bound as .Note: if equality constraints have already been added, the box constraints only apply to the reduced, full space. To apply box constraints to the full space, apply box constraints before equality constraints. This function will print a warning if it detects that equality constraints have already been added.
- Parameters:
problem (hopsy.Problem) – Problem which should be constrained and which contains the matrix
and vector in .lower_bound (numpy.ndarray[float64[n,1]] or float) – Specifies the lower bound(s).
upper_bound (numpy.ndarray[float64[n,1]] or float) – Specifies the upper bound(s).
- Returns:
A
hopsy.Problem
bounded in all dimensions.- Return type: