Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/redundancy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ function Base.show(io::IO, message::_RedundantMessage)
print(io, "` is redundant.")
end

function _is_redundant(rep::Representation, )

function _redundant_indices(rep::Representation, model::MOI.ModelLike, T::Type,
hull, indices, clean)
red_indices = Int[]
Expand All @@ -205,7 +207,7 @@ function _redundant_indices(rep::Representation, model::MOI.ModelLike, T::Type,
MOI.set(model, MOI.ConstraintSet(), ci, MOI.EqualTo{T}(ai))
end
#if !isone(length(indices)) &&
if is_feasible(model, _RedundantMessage(element, idx))
if is_feasible(model, _RedundantMessage(element, idx))
MOI.delete(model, λ[i])
push!(red_indices, i)
else
Expand Down Expand Up @@ -246,6 +248,11 @@ function nonredundant_halfspaces(vr::HRepresentation, model, T, hull, clean)
return _nonredundant(vr, model, T, hull, halfspaces(vr), clean)
end

struct RedundancyChecker{M,T}
model::M
hull::Vector{MOI.ScalarAffineFunction{T}}
end

"""
removehredundancy(hr::HRepresentation, solver)

Expand Down Expand Up @@ -294,7 +301,7 @@ function removevredundancy(vr::VRepresentation, solver)
# TODO It's much more efficient to remove redundant lines with `removeduplicates`.
# Moreover, linearity may have already been detected.
# The only advantage over `removeduplicates` is that it does not alter
# the lines, it just remove the redundant ones.
# the lines, it just removes the redundant ones.
nr_lines = nonredundant_lines(vr, model, T, hull, true)
nr_rays = nonredundant_rays(vr, model, T, hull, true)
nr_points = nonredundant_points(vr, model, T, hull, false)
Expand All @@ -304,7 +311,7 @@ end
_dim_for_hull(h::HRepresentation) = fulldim(h) + 1
_dim_for_hull(v::VRepresentation) = fulldim(v)
function _zero_hull(rep::Representation, T::Type)
return [zero(MOI.ScalarAffineFunction{T}) for i in 1:_dim_for_hull(rep)]
return [zero(MOI.ScalarAffineFunction{T}) for _ in 1:_dim_for_hull(rep)]
end
_coord_for_hull(h::HRepElement) = [h.a; h.β]
_coord_for_hull(r::VRepElement) = coord(r)
Expand Down
2 changes: 1 addition & 1 deletion src/repelemop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ end
function support_function_model(h::AbstractVector, rep::Rep, solver)
length(h) != fulldim(rep) && throw(DimensionMismatch())
model, T = layered_optimizer(solver)
x, cx = MOI.add_constrained_variables(model, PolyhedraOptSet(rep))
x, _ = MOI.add_constrained_variables(model, PolyhedraOptSet(rep))
MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE)
MOI.set(model, MOI.ObjectiveFunction{MOI.ScalarAffineFunction{T}}(), _dot(h, x, T))
return model
Expand Down
Loading