Skip to content

Commit

Permalink
move constraints_list method
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Mar 13, 2023
1 parent abd7274 commit f62e30c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
22 changes: 22 additions & 0 deletions src/Interfaces/AbstractPolyhedron_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,28 @@ isconvextype(::Type{<:AbstractPolyhedron}) = true

is_polyhedral(::AbstractPolyhedron) = true

"""
constraints_list(A::AbstractMatrix{N}, b::AbstractVector)
Convert a matrix-vector representation to a linear-constraint representation.
### Input
- `A` -- matrix
- `b` -- vector
### Output
A list of linear constraints.
"""
function constraints_list(A::AbstractMatrix, b::AbstractVector)
m = size(A, 1)
@assert m == length(b) "a matrix with $m rows is incompatible with a " *
"vector of length $(length(b))"

return [HalfSpace(A[i, :], b[i]) for i in 1:m]
end

"""
∈(x::AbstractVector, P::AbstractPolyhedron)
Expand Down
22 changes: 0 additions & 22 deletions src/Sets/HalfSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -310,28 +310,6 @@ function constraints_list(hs::HalfSpace)
return [hs]
end

"""
constraints_list(A::AbstractMatrix{N}, b::AbstractVector)
Convert a matrix-vector representation to a linear-constraint representation.
### Input
- `A` -- matrix
- `b` -- vector
### Output
A list of linear constraints.
"""
function constraints_list(A::AbstractMatrix, b::AbstractVector)
m = size(A, 1)
@assert m == length(b) "a matrix with $m rows is incompatible with a " *
"vector of length $(length(b))"

return [HalfSpace(A[i, :], b[i]) for i in 1:m]
end

"""
constrained_dimensions(hs::HalfSpace)
Expand Down

0 comments on commit f62e30c

Please sign in to comment.