Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Nov 20, 2023
1 parent 968365d commit d269bf2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/lp_matrix_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct LPMatrixData{T}
c::Vector{T}
c_offset::T
sense::MOI.OptimizationSense
variable_to_column::Dict{GenericVariableRef{T},Int}
variables::Vector{GenericVariableRef{T}}
affine_constraints::Vector{ConstraintRef}
variable_constraints::Vector{ConstraintRef}
end
Expand Down Expand Up @@ -53,9 +53,8 @@ The struct returned by [`lp_matrix_data`](@ref) has the fields:
* `c::Vector{T}`: the dense vector of linear objective coefficiennts
* `c_offset::T`: the constant term in the objective function.
* `sense::MOI.OptimizationSense`: the objective sense of the model.
* `variable_to_column::Dict{GenericVariableRef{T},Int}`: a dictionary mapping
JuMP [`GenericVariableRef`](@ref) to the 1-indexed column in the matrix
representation.
* `variables::Vector{GenericVariableRef{T}}`: a vector of [`GenericVariableRef`](@ref),
corresponding to order of the columns in the matrix form.
* `affine_constraints::Vector{ConstraintRef}`: a vector of [`ConstraintRef`](@ref),
corresponding to the order of rows in the matrix form.
Expand All @@ -68,7 +67,8 @@ If your model has integrality, use [`relax_integrality`](@ref) to remove integer
restrictions before calling [`lp_matrix_data`](@ref).
"""
function lp_matrix_data(model::GenericModel{T}) where {T}
columns = Dict(var => i for (i, var) in enumerate(all_variables(model)))
variables = all_variables(model)
columns = Dict(var => i for (i, var) in enumerate(variables))
n = length(columns)
cache = (;
x_l = fill(typemin(T), n),
Expand Down Expand Up @@ -97,7 +97,7 @@ function lp_matrix_data(model::GenericModel{T}) where {T}
cache.c,
cache.c_offset[],
MOI.get(model, MOI.ObjectiveSense()),
cache.variable_to_column,
variables,
cache.affine_constraints,
cache.bound_constraints,
)
Expand Down
2 changes: 1 addition & 1 deletion src/lp_sensitivity2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ function _standard_form_matrix(model::GenericModel{T}) where {T}
matrix = lp_matrix_data(model)
I = SparseArrays.spdiagm(fill(-one(T), length(matrix.affine_constraints)))
return (
columns = matrix.variable_to_column,
columns = Dict(x => i for (i, x) in enumerate(matrix.variables)),
lower = vcat(matrix.x_lower, matrix.b_lower),
upper = vcat(matrix.x_upper, matrix.b_upper),
A = hcat(matrix.A, I),
Expand Down

0 comments on commit d269bf2

Please sign in to comment.