From 519478ddb2c1b826d9cf92c8e28b08242ab02cab Mon Sep 17 00:00:00 2001 From: odow Date: Fri, 3 May 2024 19:20:13 +1200 Subject: [PATCH] Update --- docs/src/submodules/Utilities/overview.md | 18 +++++++++--------- src/Utilities/copy.jl | 14 +++++++++----- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/docs/src/submodules/Utilities/overview.md b/docs/src/submodules/Utilities/overview.md index 2e0d9e736e..61d4aa1d40 100644 --- a/docs/src/submodules/Utilities/overview.md +++ b/docs/src/submodules/Utilities/overview.md @@ -462,24 +462,24 @@ julia> A.m julia> A.colptr 4-element Vector{Int32}: 0 - 1 - 3 + 2 + 4 5 julia> A.rowval 5-element Vector{Int32}: 0 1 + 1 2 0 - 1 julia> A.nzval 5-element Vector{Float64}: + -4.0 1.0 1.0 2.0 - -4.0 1.0 ``` The lower and upper row bounds: @@ -502,15 +502,15 @@ The lower and upper variable bounds: ```jldoctest matrixofconstraints julia> dest.variables.lower 3-element Vector{Float64}: - 5.0 - -Inf 0.0 + -Inf + 5.0 julia> dest.variables.upper 3-element Vector{Float64}: - 5.0 - 10.0 1.0 + 10.0 + 5.0 ``` Because of larger variations between solvers, the objective can be queried using the standard MOI methods: @@ -522,7 +522,7 @@ julia> F = MOI.get(dest, MOI.ObjectiveFunctionType()) MathOptInterface.ScalarAffineFunction{Float64} julia> F = MOI.get(dest, MOI.ObjectiveFunction{F}()) -0.0 + 1.0 MOI.VariableIndex(3) + 2.0 MOI.VariableIndex(2) - 3.1 MOI.VariableIndex(1) +0.0 + 1.0 MOI.VariableIndex(1) + 2.0 MOI.VariableIndex(2) - 3.1 MOI.VariableIndex(3) ``` Thus, Clp.jl implements [`copy_to`](@ref) methods similar to the following: diff --git a/src/Utilities/copy.jl b/src/Utilities/copy.jl index 732075b85e..067acc80e0 100644 --- a/src/Utilities/copy.jl +++ b/src/Utilities/copy.jl @@ -500,7 +500,7 @@ struct _CopyVariablesWithSetCache Dict{MOI.VariableIndex,Int}(), Any[], Set{MOI.VariableIndex}(), - Tuple{Vector{MOI.VariableIndex},Any}[] + Tuple{Vector{MOI.VariableIndex},Any}[], ) end end @@ -521,7 +521,9 @@ function _build_copy_variables_with_set_cache( push!(cache.variable_cones, ([f], ci)) end end - push!(cache.constraints_not_added, indices) + if !isempty(indices) + push!(cache.constraints_not_added, indices) + end return end @@ -558,7 +560,9 @@ function _build_copy_variables_with_set_cache( push!(indices, ci) end end - push!(cache.constraints_not_added, indices) + if !isempty(indices) + push!(cache.constraints_not_added, indices) + end return end @@ -580,7 +584,7 @@ function _copy_variables_with_set(dest, src) if offset > 0 dest_x = MOI.add_variables(dest, offset) for i in 1:offset - index_map[vis_src[current_column + i]] = dest_x[i] + index_map[vis_src[current_column+i]] = dest_x[i] end end set = MOI.get(src, MOI.ConstraintSet(), ci) @@ -601,7 +605,7 @@ function _copy_variables_with_set(dest, src) if offset > 0 dest_x = MOI.add_variables(dest, offset) for i in 1:offset - index_map[vis_src[current_column + i]] = dest_x[i] + index_map[vis_src[current_column+i]] = dest_x[i] end end return index_map, vis_src, cache.constraints_not_added