From f62e30c1021e68514801d0d23aff04ad291ac384 Mon Sep 17 00:00:00 2001 From: schillic Date: Mon, 13 Mar 2023 17:28:58 +0100 Subject: [PATCH] move constraints_list method --- .../AbstractPolyhedron_functions.jl | 22 +++++++++++++++++++ src/Sets/HalfSpace.jl | 22 ------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Interfaces/AbstractPolyhedron_functions.jl b/src/Interfaces/AbstractPolyhedron_functions.jl index 61fb11d699..9d606f77af 100644 --- a/src/Interfaces/AbstractPolyhedron_functions.jl +++ b/src/Interfaces/AbstractPolyhedron_functions.jl @@ -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) diff --git a/src/Sets/HalfSpace.jl b/src/Sets/HalfSpace.jl index c5fa9b19f7..aabb762c6b 100644 --- a/src/Sets/HalfSpace.jl +++ b/src/Sets/HalfSpace.jl @@ -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)