add frequency plot + fix error in one of the plots + make output bigger

This commit is contained in:
Joeri Exelmans 2024-12-16 16:34:53 +01:00
parent 87dfce723b
commit 8d5b9e2c2d
2 changed files with 44 additions and 17 deletions

View file

@ -1,7 +1,7 @@
import os
from pypdevs.simulator import Simulator
from plot_template import make_plot_ships_script, make_plot_box_script
from plot_template import make_plot_ships_script, make_plot_box_script, make_plot_frequency_script
# from system_solution import * # Teacher's solution
from system import *
@ -42,6 +42,7 @@ outdir = "assignment_output"
plots_ships = []
plots_box = []
plots_freq = []
os.makedirs(outdir, exist_ok=True)
@ -88,18 +89,13 @@ for priority in priorities:
raise Exception("There was an IndexError, meaning that fewer ships have made it to the sink than expected.\nYour model is not (yet) correct.") from e
# Generate gnuplot code:
plots_ships.append(make_plot_ships_script(
priority=priorities[priority],
strategy=strategies[strategy],
max_waits=max_wait_durations,
gen_num=gen_num,
))
plots_box.append(make_plot_box_script(
priority=priorities[priority],
strategy=strategies[strategy],
max_waits=max_wait_durations,
gen_num=gen_num,
))
for f, col in [(make_plot_ships_script, plots_ships), (make_plot_box_script, plots_box), (make_plot_frequency_script, plots_freq)]:
col.append(f(
priority=priorities[priority],
strategy=strategies[strategy],
max_waits=max_wait_durations,
gen_num=gen_num,
))
# Finally, write out a single gnuplot script that plots everything
with open(f'{outdir}/plot.gnuplot', 'w') as f:
@ -107,3 +103,4 @@ with open(f'{outdir}/plot.gnuplot', 'w') as f:
f.write('\n\n'.join(plots_ships))
# then do the box plots
f.write('\n\n'.join(plots_box))
f.write('\n\n'.join(plots_freq))