Add distance to csv, backport changes to python script from master branch
This commit is contained in:
parent
753b1b5ead
commit
2307fd2567
35
plot/main.py
35
plot/main.py
@ -46,12 +46,33 @@ def delay(arr: list[tuple[int, np.ndarray]]) -> np.ndarray:
|
||||
return delays
|
||||
|
||||
|
||||
def rb_allocate_distance(arr: list[tuple[int, np.ndarray]], distance) -> np.ndarray:
|
||||
allocate = np.zeros((size, 2))
|
||||
nb = 0
|
||||
arr.sort()
|
||||
for nb_users, data in arr:
|
||||
n = 0
|
||||
for x in data[:,6]:
|
||||
if int(x) == distance:
|
||||
n+=1
|
||||
allocate[nb, 0] = nb_users
|
||||
allocate[nb, 1] = n
|
||||
# print(n/data.shape[0])
|
||||
nb += 1
|
||||
return allocate
|
||||
|
||||
|
||||
np_arr: list[tuple[int, np.ndarray]] = list()
|
||||
for i in nb_files:
|
||||
np_arr.append((int(i.split(".")[0]), pd.read_csv(".." + os.sep + "export" + os.sep + i, delimiter=';').to_numpy()))
|
||||
|
||||
averages = mean_mkn(np_arr)
|
||||
available = rb_available(np_arr)
|
||||
|
||||
allocate_lp1 = rb_allocate_distance(np_arr, 150)
|
||||
allocate_lp2 = rb_allocate_distance(np_arr, 500)
|
||||
allocate_total = allocate_lp1[:, 1] + allocate_lp2[:, 1]
|
||||
|
||||
delays = delay(np_arr)
|
||||
delays.sort(axis=0)
|
||||
# Data for plotting
|
||||
@ -75,4 +96,18 @@ ax[1, 0].plot(delays[:, 0], delays[:, 1], marker="o")
|
||||
ax[1, 0].set(xlabel='number of users', ylabel='delays(ms)', title='Delay')
|
||||
ax[1, 0].grid()
|
||||
|
||||
available.sort(axis=0)
|
||||
|
||||
#ax[1, 1].scatter(allocate_lp1[:, 0], (allocate_lp1[:, 1]/(allocate_lp1[:, 1])+allocate_lp2[:, 1])*100)
|
||||
|
||||
ax[1, 1].plot(available[:, 0], (allocate_lp1[:, 1]/(allocate_lp1[:, 1]+allocate_lp2[:, 1])*100))
|
||||
|
||||
#ax[1, 1].scatter(allocate_lp2[:, 0], (allocate_lp2[:, 1]/(allocate_lp1[:, 1])+allocate_lp2[:, 1])*100)
|
||||
|
||||
ax[1, 1].plot(available[:, 0], (allocate_lp2[:, 1]/(allocate_lp1[:, 1]+allocate_lp2[:, 1])*100))
|
||||
|
||||
ax[1, 1].set(xlabel='number of users', ylabel='RB utilisés proche/loin/total', title='RB utilisés distance')
|
||||
ax[1, 1].grid()
|
||||
ax[1, 1].set_ylim([0, 100])
|
||||
|
||||
plt.show()
|
@ -120,7 +120,7 @@ public class Cell {
|
||||
for(int j = 0; j < frame[i].length; j++) {
|
||||
ResourceBlock ur = frame[i][j];
|
||||
if(ur.getUser() != null) {
|
||||
String data = (tick + ";" + i + ";" + j + ";" + this.users.indexOf(ur.getUser()) + ";" + ur.getBandwidth() + ";" + delayAverage +";" + id + "\n");
|
||||
String data = (tick + ";" + i + ";" + j + ";" + this.users.indexOf(ur.getUser()) + ";" + ur.getBandwidth() + ";" + delayAverage +";" + ur.getUser().getDistance() + ";" + id + "\n");
|
||||
try{
|
||||
outputDataFile.write(data.getBytes());
|
||||
}catch(IOException e){
|
||||
|
@ -86,7 +86,7 @@ public class Main {
|
||||
try {
|
||||
//préparation à exportation des données de chaque cellule
|
||||
FileOutputStream output = new FileOutputStream("export" + File.separator + (usersCell1.size()) + ".csv", true);
|
||||
output.write("tick;x;y;user;bandwidth;delay;cell;\n".getBytes());
|
||||
output.write("tick;x;y;user;bandwidth;delay;distance;cell;\n".getBytes());
|
||||
|
||||
//création des cellules
|
||||
Cell cell1 = new Cell(0, schedulerCell1, frame1, usersCell1, output);
|
||||
|
Reference in New Issue
Block a user