Skip to content

Instantly share code, notes, and snippets.

@macleginn
Created July 13, 2018 20:42
Show Gist options
  • Save macleginn/28737002276f3081edd8be02babc8cc0 to your computer and use it in GitHub Desktop.
Save macleginn/28737002276f3081edd8be02babc8cc0 to your computer and use it in GitHub Desktop.
using DataFrames;
using Feather;
# Заранее подготовленная таблица расстояний между этносами
dist_data = Feather.read("geodistances.feather");
@everywhere dist_array = Array{Int64}(926,926);
for i = 1:926
for j = 2:927
dist_array[i,j-1] = dist_data[i,j]
end
end
# Таблица распределений мотивов
motif_data = Feather.read("berezkin_new.feather");
@everywhere motif_array = Array{Int8}(926,2138);
for i = 1:926
for j = 1:2138
motif_array[i,j] = motif_data[i,j+12]
end
end
@everywhere nrws = size(motif_array)[1];
@everywhere ncls = size(motif_array)[2];
maximin_distances = SharedArray{Int64}(ncls, ncls);
for i = 1:ncls
for j = 1:ncls
maximin_distances[i,j] = 0
end
end
for i1 = 1:2137
@sync @parallel for i2 = (i1+1):2138
maximin1 = 0
maximin2 = 0
for i = 1:nrws
if motif_array[i,i1] == 0
continue
end
curbest = Inf
for j = 1:nrws
if motif_array[j,i2] == 0
continue
end
if curbest > dist_array[i,j]
curbest = dist_array[i,j]
end
end
if maximin1 < curbest
maximin1 = curbest
end
end
for i = 1:nrws
if motif_array[i,i2] == 0
continue
end
curbest = Inf
for j = 1:nrws
if motif_array[j,i1] == 0
continue
end
if curbest > dist_array[i,j]
curbest = dist_array[i,j]
end
end
if maximin2 < curbest
maximin2 = curbest
end
end
dst = max(maximin1, maximin2)
maximin_distances[i1,i2] = maximin_distances[i2,i1] = dst
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment