# How can i use sets created using LasySets.jl with Convex.jl variables?

Is there a way i can create LazySets Polyhedron and use it as a variable in my optimization program that uses Convex.jl, use them in constraints i want to add to the problem?.

I don’t think there’s any interoperability already set up for those two packages. I think you can use Polyhedra.jl to create a constraint for JuMP.jl, however: http://juliapolyhedra.github.io/Polyhedra.jl/stable/optimization/#Polyhedra.linear_objective_solver.

Thanks.

Integration of LazySets.jl types with JuMP is implemented in the package InvariantSets.jl (thanks to @uweschler). We should probably refactor that conversion code to LazySets.jl and make it available when users load JuMP.

With respecto to Convex.jl I’m not aware of such conversions but I guess it shouldn’t be too hard
(PRs welcome).

3 Likes

Nice! If InvariantSets.jl worked on the MathOptInterface (MOI) level instead of the JuMP level, then support for Convex should be even easier (since both Convex and JuMP are MOI frontends). MOI can be a bit harder to work with than JuMP though so maybe it’s not worth it.

1 Like

Do you have a use case or MWE of the kind of problem you want to address?

Note that constraints can be added easily in this way:

``````using LazySets, Convex, SCS

A, b = tosimplehrep(X)
end
``````

Example use:

``````function supfunc(d::AbstractVector, X::LazySet; solver=SCS.Optimizer(verbose=false))
x = Variable(length(d))
add_constraint!(x, X) # x ∈ X
xᵀd = dot(x, d)
solve!(maximize(xᵀd), solver)
return evaluate(xᵀd)
end

X = rand(VPolygon)
d = ones(2)

supfunc(d, X) ≈ ρ(d, X)  # ρ is defined on LazySets for each set / lazy operation
true
``````
2 Likes

hi @mforets, yes, i have tried to describe the use-case here 3D bin packaging using Convex.jl