Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed May 3, 2024
1 parent 1367ac3 commit 519478d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
18 changes: 9 additions & 9 deletions docs/src/submodules/Utilities/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
14 changes: 9 additions & 5 deletions src/Utilities/copy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 519478d

Please sign in to comment.