-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plotter2.py
42 lines (34 loc) · 1.19 KB
/
Plotter2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# (UniPd 2008818) Mattia Toffolon
# Plotter for QAP problems' solutions
##!/usr/bin/env python
# encoding: utf-8
import matplotlib.pyplot as plt
import numpy as np
import random as rnd
import seaborn as sns
import sys
if __name__=='__main__':
assert(len(sys.argv) == 2)
f = open(sys.argv[1], 'r')
params = f.readline().split(' ')
n1 = int(params[0])
n2 = int(params[1])
n = n1*n2
d = int(params[2])
S = np.zeros((n1, n2), dtype=int)
for i in range(n):
l = f.readline().split(' ')
S[int(i/n2), i%n2] = int(l[1])
f.close()
k = 40
R = np.zeros((n1*k, n2*k), dtype=int)
for i in range(n1*k):
for j in range(n2*k):
R[i,j] = S[i%n1, j%n2]
plt.subplot(1,2,1)
sns.heatmap(S, linewidths=.5, linecolor='#bcbcbc', cmap='Greys', cbar=False, square=True, xticklabels=False, yticklabels=False)
plt.subplot(1,2,2)
sns.heatmap(R, linewidths=.5, linecolor='#ffffff', cmap='Greys', cbar=False, square=True, xticklabels=False, yticklabels=False)
plt.subplots_adjust(wspace=0.75)
plt.savefig(f'/home/mattiatoffolon/UniPd/Tesi/QAP/Document/images/grey_{n}_{d}.eps', format='eps', bbox_inches='tight')
plt.show()