Skip to content

Commit 0744299

Browse files
authored
[#124] Covering more cases in CI
Run CI on x86 architectures. - Loosen method arguments from int64 to int * remove warning from local rng * CI supporting x86 and testing multiples OS * Int64 -> Int * relax type constraints * relax in test * relax integer when unnecessary * ensure Int generic * remove type-specific tuple constraint
1 parent 69d8e4f commit 0744299

26 files changed

+344
-333
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,22 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
version:
13-
- '1.5'
14-
- '1.0'
15-
os:
16-
- ubuntu-latest
17-
arch:
18-
- x64
12+
include:
13+
- version: 'nightly'
14+
os: ubuntu-latest
15+
arch: x64
16+
- version: '1'
17+
os: ubuntu-latest
18+
arch: x64
19+
- version: '1.0'
20+
os: ubuntu-latest
21+
arch: x64
22+
- version: '1'
23+
os: ubuntu-latest
24+
arch: x86
25+
- version: '1'
26+
os: windows-latest
27+
arch: x64
1928
steps:
2029
- uses: actions/checkout@v2
2130
- uses: julia-actions/setup-julia@v1
@@ -37,4 +46,4 @@ jobs:
3746
- uses: julia-actions/julia-processcoverage@v1
3847
- uses: codecov/codecov-action@v1
3948
with:
40-
file: lcov.info
49+
file: lcov.info

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
*scratch*.jl
66
*.sublime*
77
/docs/build
8+
Manifest.toml

src/MOIWrapper.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function assign_constraint_row_ranges!(rowranges::Dict{Int, UnitRange{Int}}, idx
195195
LOCs = MOI.get(src, MOI.ListOfConstraints())
196196
sort!(LOCs, by=x-> sort_sets(x[2]))
197197
for (F, S) in LOCs
198-
# Returns Array of constraint indexes that match F,S, each constraint index is just a type-safe wrapper for Int64
198+
# Returns Array of constraint indexes that match F,S, each constraint index is just a type-safe wrapper for Int
199199
cis_src = MOI.get(src, MOI.ListOfConstraintIndices{F, S}())
200200
for ci_src in cis_src
201201
set = MOI.get(src, MOI.ConstraintSet(), ci_src)
@@ -577,7 +577,7 @@ function merge_sets(C::Array{COSMO.AbstractConvexSet{T}}) where {T <: AbstractFl
577577
end
578578

579579

580-
function merge_set!(merged_sets::Array{COSMO.AbstractConvexSet{T}, 1}, ind::Array{Int64, 1}, C::Array{<: COSMO.AbstractConvexSet, 1}, set_ind::Int64, set_type::DataType) where {T <: AbstractFloat}
580+
function merge_set!(merged_sets::Array{COSMO.AbstractConvexSet{T}, 1}, ind::Array{Int, 1}, C::Array{<: COSMO.AbstractConvexSet, 1}, set_ind::Int, set_type::DataType) where {T <: AbstractFloat}
581581
if length(ind) > 1
582582
combined_dim = sum(x -> x.dim, C[ind])
583583
else
@@ -587,7 +587,7 @@ function merge_set!(merged_sets::Array{COSMO.AbstractConvexSet{T}, 1}, ind::Arra
587587
return set_ind + 1
588588
end
589589

590-
function merge_box!(merged_sets::Array{COSMO.AbstractConvexSet{T}, 1}, ind::Array{Int64, 1}, C::Array{<: COSMO.AbstractConvexSet{T}, 1}, set_ind::Int64) where {T <: AbstractFloat}
590+
function merge_box!(merged_sets::Array{COSMO.AbstractConvexSet{T}, 1}, ind::Array{Int, 1}, C::Array{<: COSMO.AbstractConvexSet{T}, 1}, set_ind::Int) where {T <: AbstractFloat}
591591
if length(ind) > 1
592592
combined_dim = sum(x -> x.dim, C[ind])
593593
l = zeros(T, combined_dim)

src/algebra.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ function col_norms!(v::Array{Tf, 1},
6161
end
6262

6363
function col_norms!(v::Array{Tf, 1},
64-
A::SparseMatrixCSC{Tf,Ti}; reset::Bool = true) where{Tf <: AbstractFloat, Ti <: Integer}
64+
A::SparseMatrixCSC{Tf,Ti}; reset::Bool = true) where {Tf <: AbstractFloat, Ti <: Integer}
6565

6666
if reset
67-
fill!(v,0.)
67+
fill!(v, 0)
6868
end
6969

7070
@inbounds for i = eachindex(v)

src/chordal_decomposition.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ function find_sparsity_patterns!(ws::COSMO.Workspace)
4848
end
4949
end
5050

51-
analyse_sparsity_pattern!(ci::ChordalInfo, csp::Array{Int64, 1}, sets::Vector{AbstractConvexSet}, C::AbstractConvexSet, k::Int64, psd_row_range::UnitRange{Int64}, sp_ind::Int64, merge_strategy::Union{Type{<: AbstractMergeStrategy}, OptionsFactory{<: AbstractMergeStrategy}}) = sp_ind
51+
analyse_sparsity_pattern!(ci::ChordalInfo, csp::Array{Int, 1}, sets::Vector{AbstractConvexSet}, C::AbstractConvexSet, k::Int, psd_row_range::UnitRange{Int}, sp_ind::Int, merge_strategy::Union{Type{<: AbstractMergeStrategy}, OptionsFactory{<: AbstractMergeStrategy}}) = sp_ind
5252

53-
function analyse_sparsity_pattern!(ci::ChordalInfo, csp::Array{Int64, 1}, sets::Vector{AbstractConvexSet}, C::DecomposableCones{T}, k::Int64, psd_row_range::UnitRange{Int64}, sp_ind::Int64, merge_strategy::Union{Type{<: AbstractMergeStrategy}, OptionsFactory{<: AbstractMergeStrategy}}) where {T <: Real}
53+
function analyse_sparsity_pattern!(ci::ChordalInfo, csp::Array{Int, 1}, sets::Vector{AbstractConvexSet}, C::DecomposableCones{T}, k::Int, psd_row_range::UnitRange{Int}, sp_ind::Int, merge_strategy::Union{Type{<: AbstractMergeStrategy}, OptionsFactory{<: AbstractMergeStrategy}}) where {T <: Real}
5454
if length(csp) < C.dim
5555
return _analyse_sparsity_pattern(ci, csp, sets, C, k, psd_row_range, sp_ind, merge_strategy)
5656
else
@@ -59,7 +59,7 @@ function analyse_sparsity_pattern!(ci::ChordalInfo, csp::Array{Int64, 1}, sets::
5959
end
6060
end
6161

62-
function _analyse_sparsity_pattern(ci::ChordalInfo{T}, csp::Array{Int64, 1}, sets::Vector{AbstractConvexSet}, C::Union{PsdCone{T}, PsdConeTriangle{T}}, k::Int64, psd_row_range::UnitRange{Int64}, sp_ind::Int64, merge_strategy::Union{Type{<: AbstractMergeStrategy}, OptionsFactory{<: AbstractMergeStrategy}}) where {T <: AbstractFloat}
62+
function _analyse_sparsity_pattern(ci::ChordalInfo{T}, csp::Array{Int, 1}, sets::Vector{AbstractConvexSet}, C::Union{PsdCone{T}, PsdConeTriangle{T}}, k::Int, psd_row_range::UnitRange{Int}, sp_ind::Int, merge_strategy::Union{Type{<: AbstractMergeStrategy}, OptionsFactory{<: AbstractMergeStrategy}}) where {T <: AbstractFloat}
6363
ordering, nz_ind_map = find_graph!(ci, csp, C.sqrt_dim, C)
6464
sp = COSMO.SparsityPattern(ci.L, C.sqrt_dim, ordering, merge_strategy, psd_row_range, k, nz_ind_map)
6565
# if after analysis of SparsityPattern & clique merging only one clique remains, don't bother decomposing
@@ -74,10 +74,10 @@ function _analyse_sparsity_pattern(ci::ChordalInfo{T}, csp::Array{Int64, 1}, set
7474
end
7575
end
7676

77-
DenseEquivalent(C::COSMO.PsdCone{T}, dim::Int64) where {T <: AbstractFloat} = COSMO.DensePsdCone{T}(dim)
78-
DenseEquivalent(C::COSMO.PsdConeTriangle{T}, dim::Int64) where {T <: AbstractFloat} = COSMO.DensePsdConeTriangle{T}(dim)
77+
DenseEquivalent(C::COSMO.PsdCone{T}, dim::Int) where {T <: AbstractFloat} = COSMO.DensePsdCone{T}(dim)
78+
DenseEquivalent(C::COSMO.PsdConeTriangle{T}, dim::Int) where {T <: AbstractFloat} = COSMO.DensePsdConeTriangle{T}(dim)
7979

80-
function nz_rows(a::SparseMatrixCSC{T}, ind::UnitRange{Int64}, DROP_ZEROS_FLAG::Bool) where {T <: AbstractFloat}
80+
function nz_rows(a::SparseMatrixCSC{T}, ind::UnitRange{Int}, DROP_ZEROS_FLAG::Bool) where {T <: AbstractFloat}
8181
DROP_ZEROS_FLAG && dropzeros!(a)
8282
active = falses(length(ind))
8383
for r in a.rowval
@@ -96,14 +96,14 @@ function number_of_overlaps_in_rows(A::SparseMatrixCSC{T}) where {T <: AbstractF
9696
end
9797

9898

99-
function find_aggregate_sparsity(A::SparseMatrixCSC{T}, b::AbstractVector{T}, ind::UnitRange{Int64}, C::DecomposableCones{T}) where {T <: AbstractFloat}
99+
function find_aggregate_sparsity(A::SparseMatrixCSC{T}, b::AbstractVector{T}, ind::UnitRange{Int}, C::DecomposableCones{T}) where {T <: AbstractFloat}
100100
AInd = nz_rows(A, ind, false)
101101
# commonZeros = AInd[find(x->x==0,b[AInd])]
102102
bInd = findall(x -> x != 0, view(b, ind))
103103
commonNZeros = union(AInd, bInd)
104104
return commonNZeros
105105
end
106-
find_aggregate_sparsity(A::SparseMatrixCSC{T}, b::AbstractVector{T}, ind::UnitRange{Int64}, C::AbstractConvexSet{T}) where {T <: AbstractFloat} = Int64[]
106+
find_aggregate_sparsity(A::SparseMatrixCSC{T}, b::AbstractVector{T}, ind::UnitRange{Int}, C::AbstractConvexSet{T}) where {T <: AbstractFloat} = Int[]
107107

108108

109109
"""
@@ -157,7 +157,7 @@ function fill_dual_variables!(ws::COSMO.Workspace{T}, vars::COSMO.Variables{T})
157157
return nothing
158158
end
159159

160-
function add_sub_blocks!(s::SplitVector{T}, s_decomp::SplitVector{T}, μ::AbstractVector{T}, μ_decomp::AbstractVector{T}, ci::ChordalInfo{T}, C::CompositeConvexSet{T}, C0::CompositeConvexSet{T}, cone_map::Dict{Int64, Int64}) where {T <: AbstractFloat}
160+
function add_sub_blocks!(s::SplitVector{T}, s_decomp::SplitVector{T}, μ::AbstractVector{T}, μ_decomp::AbstractVector{T}, ci::ChordalInfo{T}, C::CompositeConvexSet{T}, C0::CompositeConvexSet{T}, cone_map::Dict{Int, Int}) where {T <: AbstractFloat}
161161
sp_arr = ci.sp_arr
162162
row_start = 1 # the row pointer in the decomposed problem
163163
row_ranges = get_set_indices(C0.sets) # the row ranges of the same cone (or "parent" cone) in the original problem
@@ -170,14 +170,14 @@ function add_sub_blocks!(s::SplitVector{T}, s_decomp::SplitVector{T}, μ::Abstra
170170
return nothing
171171
end
172172

173-
function add_blocks!(s::SplitVector{T}, μ::AbstractVector{T}, row_start::Int64, row_range::UnitRange{Int64}, sp_arr::Array{SparsityPattern, 1}, s_decomp::SplitVector{T}, μ_decomp::AbstractVector{T}, C::AbstractConvexSet{T}) where {T <: AbstractFloat}
173+
function add_blocks!(s::SplitVector{T}, μ::AbstractVector{T}, row_start::Int, row_range::UnitRange{Int}, sp_arr::Array{SparsityPattern, 1}, s_decomp::SplitVector{T}, μ_decomp::AbstractVector{T}, C::AbstractConvexSet{T}) where {T <: AbstractFloat}
174174

175175
@. s.data[row_range] = s_decomp.data[row_start:row_start + C.dim - 1]
176176
@. μ[row_range] = μ_decomp[row_start:row_start + C.dim - 1]
177177
return row_start + C.dim
178178
end
179179

180-
function add_blocks!(s::SplitVector{T}, μ::AbstractVector{T}, row_start::Int64, row_range::UnitRange{Int64}, sp_arr::Array{SparsityPattern, 1}, s_decomp::SplitVector{T}, μ_decomp::AbstractVector{T}, C::DecomposableCones{T}) where {T <: AbstractFloat}
180+
function add_blocks!(s::SplitVector{T}, μ::AbstractVector{T}, row_start::Int, row_range::UnitRange{Int}, sp_arr::Array{SparsityPattern, 1}, s_decomp::SplitVector{T}, μ_decomp::AbstractVector{T}, C::DecomposableCones{T}) where {T <: AbstractFloat}
181181
# load the appropriate sparsity_pattern
182182
sp = sp_arr[C.tree_ind]
183183
sntree = sp.sntree
@@ -217,9 +217,9 @@ function psd_completion!(ws::COSMO.Workspace)
217217
return nothing
218218
end
219219

220-
complete!::AbstractVector{T}, ::AbstractConvexSet{T}, sp_arr::Array{SparsityPattern}, sp_ind::Int64, rows::UnitRange{Int64}) where {T <: AbstractFloat} = sp_ind
220+
complete!::AbstractVector{T}, ::AbstractConvexSet{T}, sp_arr::Array{SparsityPattern}, sp_ind::Int, rows::UnitRange{Int}) where {T <: AbstractFloat} = sp_ind
221221

222-
function complete!::AbstractVector{T}, C::PsdCone{T}, sp_arr::Array{SparsityPattern}, sp_ind::Int64, rows::UnitRange{Int64}) where {T <: AbstractFloat}
222+
function complete!::AbstractVector{T}, C::PsdCone{T}, sp_arr::Array{SparsityPattern}, sp_ind::Int, rows::UnitRange{Int}) where {T <: AbstractFloat}
223223
sp = sp_arr[sp_ind]
224224

225225
μ_view = view(μ, rows)
@@ -234,7 +234,7 @@ function complete!(μ::AbstractVector{T}, C::PsdCone{T}, sp_arr::Array{SparsityP
234234
return sp_ind + 1
235235
end
236236

237-
function complete!::AbstractVector{T}, C::PsdConeTriangle{T}, sp_arr::Array{SparsityPattern}, sp_ind::Int64, rows::UnitRange{Int64}) where {T <: AbstractFloat}
237+
function complete!::AbstractVector{T}, C::PsdConeTriangle{T}, sp_arr::Array{SparsityPattern}, sp_ind::Int, rows::UnitRange{Int}) where {T <: AbstractFloat}
238238
sp = sp_arr[sp_ind]
239239

240240
μ_view = view(μ, rows)
@@ -250,7 +250,7 @@ end
250250

251251
# positive semidefinite completion (from Vandenberghe - Chordal Graphs..., p. 362)
252252
# input: A - positive definite completable matrix
253-
function psd_complete!(A::AbstractMatrix{T}, N::Int64, sntree::SuperNodeTree, p::Array{Int64}) where {T <: AbstractFloat}
253+
function psd_complete!(A::AbstractMatrix{T}, N::Int, sntree::SuperNodeTree, p::Array{Int}) where {T <: AbstractFloat}
254254

255255
# if a clique graph based merge strategy was used for this sparsity pattern, recompute a valid clique tree
256256
#recompute_clique_tree(sntree.strategy) && clique_tree_from_graph!(sntree, sntree.strategy)

src/clique_graph.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
compute_reduced_clique_graph!(sep::Array{Set{Int64}, 1}, snd::Array{Set{Int64}, 1})
2+
compute_reduced_clique_graph!(sep::Array{Set{Int}, 1}, snd::Array{Set{Int}, 1})
33
44
Compute the reduced clique graph (union of all clique trees) given an initial clique tree defined by its supernodes `snd` and separator `sep` sets.
55
@@ -13,14 +13,14 @@ computes the reduced clique graph in the following way:
1313
| Store the index of the separator which is the intersection C1 ∩ C2 in `iter`
1414
end
1515
"""
16-
function compute_reduced_clique_graph!(sep::Array{Set{Int64}, 1}, snd::Array{Set{Int64}, 1})
16+
function compute_reduced_clique_graph!(sep::Array{Set{Int}, 1}, snd::Array{Set{Int}, 1})
1717
# loop over separators by decreasing cardinality
1818
sort!(sep, by = x -> length(x), rev = true)
1919

20-
# edges = Array{Tuple{Int64, Int64}, 1}() # a list of edges in the reduced clique graph, higher clique index first
21-
rows = Int64[]
22-
cols = Int64[]
23-
# inter = Array{Int64, 1}() # the index of the separator which corresponds to the intersection of the two cliques
20+
# edges = Array{Tuple{Int, Int}, 1}() # a list of edges in the reduced clique graph, higher clique index first
21+
rows = Int[]
22+
cols = Int[]
23+
# inter = Array{Int, 1}() # the index of the separator which corresponds to the intersection of the two cliques
2424

2525
for (k, separator) in enumerate(sep)
2626
# find cliques that contain the separator
@@ -46,17 +46,17 @@ function compute_reduced_clique_graph!(sep::Array{Set{Int64}, 1}, snd::Array{Set
4646
end
4747

4848
"Check whether the `pair` of cliques are in different `components`."
49-
function is_unconnected(pair::Tuple{Int64, Int64}, components::Array{Set{Int64}, 1})
49+
function is_unconnected(pair::Tuple{Int, Int}, components::Array{Set{Int}, 1})
5050
component_ind = findfirst(x -> pair[1] x, components)
5151
return pair[2] components[component_ind]
5252
end
5353

5454
"Find the separator graph H given a separator and the relevant index-subset of cliques."
55-
function separator_graph(clique_ind::Array{Int64,1}, separator::Set{Int64}, snd::Array{Set{Int64}, 1})
55+
function separator_graph(clique_ind::Array{Int,1}, separator::Set{Int}, snd::Array{Set{Int}, 1})
5656

5757
# make the separator graph using a hash table
5858
# key: clique_ind --> edges to other clique indices
59-
H = Dict{Int64, Array{Int64, 1}}()
59+
H = Dict{Int, Array{Int, 1}}()
6060

6161
for pair in subsets(clique_ind, Val{2}())
6262
ca = pair[1]
@@ -77,26 +77,26 @@ function separator_graph(clique_ind::Array{Int64,1}, separator::Set{Int64}, snd:
7777
end
7878
# add unconnected cliques
7979
for v in clique_ind
80-
!haskey(H, v) && (H[v] = Int64[])
80+
!haskey(H, v) && (H[v] = Int[])
8181
end
8282
return H
8383
end
8484

8585
"Find connected components in undirected separator graph represented by `H`."
86-
function find_components(H::Dict{Int64, Array{Int64, 1}}, clique_ind::Array{Int64,1})
87-
visited = Dict{Int64, Bool}(v => false for v in clique_ind)
88-
components = Array{Set{Int64}, 1}()
86+
function find_components(H::Dict{Int, Array{Int, 1}}, clique_ind::Array{Int,1})
87+
visited = Dict{Int, Bool}(v => false for v in clique_ind)
88+
components = Array{Set{Int}, 1}()
8989
for v in clique_ind
9090
if visited[v] == false
91-
component = Set{Int64}()
91+
component = Set{Int}()
9292
push!(components, DFS_hashtable!(component, v, visited, H))
9393
end
9494
end
9595
return components
9696
end
9797

9898
"Depth first search on a hashtable `H`."
99-
function DFS_hashtable!(component::Set{Int64}, v::Int64, visited::Dict{Int64, Bool}, H::Dict{Int64, Array{Int64, 1}})
99+
function DFS_hashtable!(component::Set{Int}, v::Int, visited::Dict{Int, Bool}, H::Dict{Int, Array{Int, 1}})
100100
visited[v] = true
101101
push!(component, v)
102102
for n in H[v]
@@ -109,7 +109,7 @@ end
109109

110110

111111
"Check if s ∩ s2 == s3."
112-
function inter_equal(s::Set{Int64}, s2::Set{Int64}, s3::Set{Int64})
112+
function inter_equal(s::Set{Int}, s2::Set{Int}, s3::Set{Int})
113113
dim = 0
114114
len_s3 = length(s3)
115115
if length(s) < length(s2)
@@ -131,8 +131,8 @@ end
131131

132132

133133
"Given a list of edges, return an adjacency hash-table `table` with nodes from 1 to `num_vertices`."
134-
function compute_adjacency_table(edges::SparseMatrixCSC{Float64, Int64}, num_vertices::Int64)
135-
table = Dict(i => Set{Int64}() for i = 1:num_vertices)
134+
function compute_adjacency_table(edges::SparseMatrixCSC{Float64, Int}, num_vertices::Int)
135+
table = Dict(i => Set{Int}() for i = 1:num_vertices)
136136
r = edges.rowval
137137
c = edges.colptr
138138
for col = 1:num_vertices
@@ -146,7 +146,7 @@ function compute_adjacency_table(edges::SparseMatrixCSC{Float64, Int64}, num_ver
146146
end
147147

148148
"Check whether `edge` is permissible for a merge. An edge is permissible if for every common neighbor N, C_1 ∩ N == C_2 ∩ N or if no common neighbors exist."
149-
function ispermissible(edge::Tuple{Int64, Int64}, adjacency_table::Dict{Int64, Set{Int64}}, snd::Array{Set{Int64}, 1})
149+
function ispermissible(edge::Tuple{Integer, Integer}, adjacency_table::Dict{Int, Set{Int}}, snd::Array{Set{Int}, 1})
150150
c_1 = edge[1]
151151
c_2 = edge[2]
152152
common_neighbors = intersect(adjacency_table[c_1], adjacency_table[c_2])

0 commit comments

Comments
 (0)