Skip to content
Merged
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
8 changes: 4 additions & 4 deletions src/MOI/list.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ function _add_list_variables!(m::Optimizer, hx_list::HxExpression, n::Int)
return indices
end

# ── MathOptVRP.List ─────────────────────────────────────────────────
# ── MathOptVRP.Permutation ──────────────────────────────────────────

function MOI.supports_add_constrained_variables(
::Optimizer,
::Type{MathOptVRP.List},
::Type{MathOptVRP.Permutation},
)
return true
end

function MOI.add_constrained_variables(m::Optimizer, set::MathOptVRP.List)
function MOI.add_constrained_variables(m::Optimizer, set::MathOptVRP.Permutation)
n = set.dimension
hx_list = list!(m.model, n)
# Pin the list's count so the solver can't pick a shorter list.
_add_hexaly_constraint!(m, eq(m.model, count_(m.model, hx_list), n))
indices = _add_list_variables!(m, hx_list, n)
cindex = MOI.ConstraintIndex{MOI.VectorOfVariables,MathOptVRP.List}(
cindex = MOI.ConstraintIndex{MOI.VectorOfVariables,MathOptVRP.Permutation}(
length(m.constraint_info) + 1,
)
m.constraint_info[cindex] =
Expand Down
2 changes: 1 addition & 1 deletion src/MOI/sum_distances_objective.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function _vector_affine_to_items(f::MOI.VectorAffineFunction)
end

# `MathOptVRP` node values are 1-based, while Hexaly lists and arrays are
# 0-based. List variables retain their identity here because the specialized
# 0-based. Permutation variables retain their identity here because the specialized
# lowering paths below access their raw parent list; constants are shifted for
# Hexaly array indexing.
function _shift_to_zero_based!(items, from::Int = 1)
Expand Down
2 changes: 1 addition & 1 deletion src/MOI/wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mutable struct VariableInfo
index::MOI.VariableIndex
variable::HxExpression
# When the variable is an element of a Hexaly `list` decision variable
# (e.g., via `MathOptVRP.List` or `MathOptVRP.Partition`), `parent_list` is that
# (e.g., via `MathOptVRP.Permutation` or `MathOptVRP.Partition`), `parent_list` is that
# list expression. `_build_sum_distances_expression` uses it to access
# the underlying list's variable count and elements.
parent_list::Union{Nothing,HxExpression}
Expand Down