As others have mentioned, the problem you posted can be formulated as a feasibility LP. Here is how to use the LazySets.jl API for such problem.
The set p
constructed below represents the entire solution set of the problem.
using LazySets, ModelingToolkit, Plots
# define modeling variables
vars = @variables x y z
# input the polyhedron in constraint representation
p = HPolyhedron([x + 2y + 3z == 10,
2x + 4y + 10z == 20,
4x + y + z < 10], vars)
# remove redundant inequalities
remove_redundant_constraints!(p)
# print the list of constraints
constraints_list(p)
5-element Array{HalfSpace{Float64,Array{Float64,1}},1}:
HalfSpace{Float64,Array{Float64,1}}([1.0, 2.0, 3.0], 10.0)
HalfSpace{Float64,Array{Float64,1}}([-1.0, -2.0, -3.0], -10.0)
HalfSpace{Float64,Array{Float64,1}}([2.0, 4.0, 10.0], 20.0)
HalfSpace{Float64,Array{Float64,1}}([-2.0, -4.0, -10.0], -20.0)
HalfSpace{Float64,Array{Float64,1}}([4.0, 1.0, 1.0], 10.0)
# get the matrix representation Ax <= b (where <= is taken component-wise)
tosimplehrep(p)
([1.0 2.0 3.0; -1.0 -2.0 -3.0; … ; -2.0 -4.0 -10.0; 4.0 1.0 1.0], [10.0, -10.0, 20.0, -20.0, 10.0])
There are many methods applicable to polyhedra in constraint representation. For instance,
# check emptiness
isempty(p)
false
# query an element
z = an_element(p)
3-element Array{Float64,1}:
1.4285714285714286
4.285714285714286
0.0
# check membership
z ∈ p
true
-z ∈ p
false
# solution found in another comment using Clp optimizer
[0.0, 5.0, 0.0] ∈ p
true
# check inclusion
Ball2(z, 0.1) ⊆ p
false
# lazy projection
q = Projection(p, 1:2)
LinearMap{Float64,HPolyhedron{Float64,Array{Float64,1}},Float64,SparseArrays.SparseMatrixCSC{Float64,Int64}}(
[1, 1] = 1.0
[2, 2] = 1.0, HPolyhedron{Float64,Array{Float64,1}}(HalfSpace{Float64,Array{Float64,1}}[HalfSpace{Float64,Array{Float64,1}}([1.0, 2.0, 3.0], 10.0), HalfSpace{Float64,Array{Float64,1}}([-1.0, -2.0, -3.0], -10.0), HalfSpace{Float64,Array{Float64,1}}([2.0, 4.0, 10.0], 20.0), HalfSpace{Float64,Array{Float64,1}}([-2.0, -4.0, -10.0], -20.0), HalfSpace{Float64,Array{Float64,1}}([4.0, 1.0, 1.0], 10.0)]))
I stop there, but please note that to work in high dimensions in an efficient manner it is often a good idea to make lazy operations as above (in the call to Projection
). The code that I showed is not limited to 3D, you can try with @variables x[1:100]
.