Skip to content

Commit

Permalink
Updated memory, newer plots
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Miguel Lopez committed Oct 10, 2023
1 parent 47f670a commit 3e4fc7c
Show file tree
Hide file tree
Showing 34 changed files with 216 additions and 136 deletions.
123 changes: 85 additions & 38 deletions memoria/capitulos/capitulo4.tex

Large diffs are not rendered by default.

Binary file modified memoria/figs/diseno/lane_comparisons/laptimes.pdf
Binary file not shown.
Binary file not shown.
Binary file modified memoria/figs/diseno/rl_comparisons/all_laptimes.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed memoria/figs/diseno/rl_comparisons/dir_comps.png
Binary file not shown.
Binary file added memoria/figs/diseno/rl_comparisons/directions.pdf
Binary file not shown.
Binary file removed memoria/figs/diseno/rl_comparisons/ecdf.png
Binary file not shown.
Binary file removed memoria/figs/diseno/rl_comparisons/laptimes.png
Binary file not shown.
Binary file not shown.
Binary file removed memoria/figs/diseno/rl_comparisons/track.png
Binary file not shown.
Binary file added memoria/figs/diseno/rl_comparisons/tracks.pdf
Binary file not shown.
Binary file modified memoria/memoria.pdf
Binary file not shown.
104 changes: 63 additions & 41 deletions qlearning_trainings/plot_train_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import matplotlib.animation as animation
import scienceplots

from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QListWidget, QPushButton
# from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QListWidget, QPushButton
import os
import sys

Expand All @@ -13,7 +13,7 @@
laptopRoute = "/home/chuismi/Desktop/robotica/cuarto/tfg/2022-tfg-luismiguel-lopez/qlearning_trainings/"
pcRoute = "/home/luismi/Desktop/tfg/2022-tfg-luismiguel-lopez/qlearning_trainings/"

USING_ROUTE = laptopRoute
USING_ROUTE = "/home/fcasdev/tfglm/2022-tfg-luismiguel-lopez/qlearning_trainings/"

EPISODE_N = 0
EPISODE_ITS = 1
Expand All @@ -22,48 +22,48 @@
DECAY_FACTOR = 4


class CsvPicker(QWidget):
def __init__(self, path):
super(CsvPicker, self).__init__()
# class CsvPicker(QWidget):
# def __init__(self, path):
# super(CsvPicker, self).__init__()

self.path = path
self.file = None
# self.path = path
# self.file = None

self.initUI()
# self.initUI()

def initUI(self):
self.setWindowTitle("File Chooser")
layout = QVBoxLayout()
# def initUI(self):
# self.setWindowTitle("File Chooser")
# layout = QVBoxLayout()

self.list_widget = QListWidget()
# self.list_widget = QListWidget()

# Add files to the list widget
for file_name in os.listdir(self.path):
if os.path.isfile(os.path.join(self.path, file_name)):
if "_results.csv" in file_name:
self.list_widget.addItem(file_name)
# # Add files to the list widget
# for file_name in os.listdir(self.path):
# if os.path.isfile(os.path.join(self.path, file_name)):
# if "_results.csv" in file_name:
# self.list_widget.addItem(file_name)

layout.addWidget(self.list_widget)
# layout.addWidget(self.list_widget)

selectCSV = QPushButton("Select")
selectCSV.clicked.connect(self.fileSelected)
layout.addWidget(selectCSV)
# selectCSV = QPushButton("Select")
# selectCSV.clicked.connect(self.fileSelected)
# layout.addWidget(selectCSV)

self.setLayout(layout)
# self.setLayout(layout)

def fileSelected(self):
selected_item = self.list_widget.currentItem()
if selected_item:
self.file = selected_item.text()
self.close()
# def fileSelected(self):
# selected_item = self.list_widget.currentItem()
# if selected_item:
# self.file = selected_item.text()
# self.close()

def closeEvent(self, event):
if self.file is None:
self.file = ""
# def closeEvent(self, event):
# if self.file is None:
# self.file = ""

global csvFileRoute
csvFileRoute = os.path.join(self.path, self.file)
super(CsvPicker, self).closeEvent(event)
# global csvFileRoute
# csvFileRoute = os.path.join(self.path, self.file)
# super(CsvPicker, self).closeEvent(event)


def getCSVdata(name, column):
Expand Down Expand Up @@ -125,6 +125,24 @@ def iterationsNumber(episodes, iterations):
# Save the plot as a PNG image
plt.savefig(csvFileRoute.replace(".csv", "") + "_iterations.png")

def plotDataInSubplot(episodes, iterations, reward, decayf):
print("pepe")
fig, ax = plt.subplots(1, 3, figsize=(18, 5))
ax[0].plot(episodes, iterations)
ax[0].set_title('Número de iteraciones por episodios')
ax[0].set_ylabel('Iteraciones')
ax[0].set_xlabel('Episodios')
ax[1].plot(episodes, decayf)
ax[1].set_title('Variación de Epsilon durante el entrenamiento')
ax[1].set_ylabel('Epsilon')
ax[1].set_xlabel('Episodios')
ax[2].plot(episodes, reward)
ax[2].set_title('Evolución de la recompensa acumulada por episodio')
ax[2].set_ylabel('Recompensa acumulada')
ax[2].set_xlabel('Episodios')
for axis in ax:
axis.autoscale()
plt.savefig(csvFileRoute.replace(".csv", "") + "_training.pdf")

def plotAll():
episodes = getCSVdata(csvFileRoute, EPISODE_N)
Expand All @@ -133,17 +151,21 @@ def plotAll():
sense = getCSVdata(csvFileRoute, SENSE)
decayFactor = getCSVdata(csvFileRoute, DECAY_FACTOR)

rewardAccum(episodes, reward)
episodeEpsilon(episodes, decayFactor)
iterationsNumber(episodes, episodeIts)
# rewardAccum(episodes, reward)
# episodeEpsilon(episodes, decayFactor)
# iterationsNumber(episodes, episodeIts)
plotDataInSubplot(episodes, episodeIts, reward, decayFactor)


def main():
path = USING_ROUTE
app = QApplication(sys.argv)
csvPicker = CsvPicker(path)
csvPicker.show()
app.exec_()
path = USING_ROUTE + "racing_bunch_actions_results.csv"
global csvFileRoute
csvFileRoute = path

# app = QApplication(sys.argv)
# csvPicker = CsvPicker(path)
# csvPicker.show()
# app.exec_()

plotAll()

Expand Down
Binary file removed vision_measures/ace_speedway_bg.png
Binary file not shown.
Binary file modified vision_measures/all_CPU_usage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vision_measures/all_controller_value.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vision_measures/all_direction_changes.pdf
Binary file not shown.
Binary file modified vision_measures/all_direction_changes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vision_measures/all_laptimes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vision_measures/all_memory_usage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vision_measures/all_tracks_described.pdf
Binary file not shown.
Binary file modified vision_measures/all_tracks_described.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 3e4fc7c

Please sign in to comment.