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 and hopsy.Problem.b of the returned hopsy.Problem to have m+2n 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 the hopsy.round() function, uses PolyRound to remove redundant constraints and also rounds the polytope.

If lower_bound and upper_bound are both float, then every dimension i will be bound as lbxiub. If lower_bound` and upper_bound are both numpy.ndarray with appropriate length, then every dimension i will be bound as lbixiubi.

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 A and vector b in Axb.

  • 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:

hopsy.Problem