Skip to content

Commit 54117bb

Browse files
committed
Added scroll areas to Experiment Window and tuned toy_problem graphs
1 parent 51dca1f commit 54117bb

File tree

8 files changed

+2473
-2385
lines changed

8 files changed

+2473
-2385
lines changed

MLC/GUI/Autogenerated/autogenerated.py

Lines changed: 428 additions & 402 deletions
Large diffs are not rendered by default.

MLC/GUI/Autogenerated/mlc_qtcreator/board_config_design.ui

Lines changed: 1174 additions & 1152 deletions
Large diffs are not rendered by default.

MLC/GUI/Autogenerated/mlc_qtcreator/experiment.ui

Lines changed: 844 additions & 825 deletions
Large diffs are not rendered by default.
162 KB
Binary file not shown.
204 KB
Binary file not shown.
242 KB
Binary file not shown.
439 KB
Binary file not shown.

templates/toy_problem.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import sys
2929
import time
3030

31+
from MLC.arduino.protocol import ArduinoUserInterface
3132
from MLC.mlc_parameters.mlc_parameters import Config
3233
from PyQt5.QtCore import Qt
3334

@@ -39,7 +40,7 @@ def individual_data(indiv):
3940

4041
config = Config.get_instance()
4142
artificial_noise = config.getint('EVALUATOR', 'artificialnoise')
42-
y_with_noise = y + [random.random() - 0.5 for _ in xrange(SAMPLES)] + artificial_noise * 500
43+
y_with_noise = y + [random.random() / 2 - 0.25 for _ in xrange(SAMPLES)] + artificial_noise * 500
4344

4445
if isinstance(indiv.get_formal(), str):
4546
formal = indiv.get_formal().replace('S0', 'x')
@@ -75,21 +76,41 @@ def cost(indiv):
7576

7677
def show_best(index, generation, indiv, cost, block=True):
7778
x, y, y_with_noise, b = individual_data(indiv)
78-
cuadratic_error = np.sqrt((y_with_noise - b)**2 / (1 + np.absolute(x**2)))
79+
mean_squared_error = np.sqrt((y_with_noise - b)**2 / (1 + np.absolute(x**2)))
7980

80-
fig = plt.figure()
8181
# Put figure window on top of all other windows
82+
fig = plt.figure()
8283
fig.canvas.manager.window.setWindowModality(Qt.ApplicationModal)
84+
fig.canvas.manager.window.setWindowTitle("Best Individual")
85+
86+
formal = None
87+
if type(indiv.get_formal()) == list:
88+
formal = indiv.get_formal()[0]
89+
else:
90+
formal = indiv.get_formal()
8391

92+
plt.rc('font', family='serif')
8493
plt.suptitle("Generation N#{0} - Individual N#{1}\n"
8594
"Cost: {2}\n Formal: {3}".format(generation,
8695
index,
8796
cost,
88-
indiv.get_formal()))
97+
formal),
98+
fontsize=12)
99+
89100
plt.subplot(2, 1, 1)
90-
plt.plot(x, y, x, y_with_noise, '*', x, b)
101+
line1, = plt.plot(x, y, color='r', linewidth=4, label='Curve without noise')
102+
line2, = plt.plot(x, y_with_noise, 'g-.', linewidth=2, label='Curve with noise')
103+
line3, = plt.plot(x, b, color='k', linewidth=2, label='Control Law (Individual)')
104+
plt.ylabel('Functions', fontsize=12, fontweight='bold')
105+
plt.xlabel('Samples', fontsize=12, fontweight='bold')
106+
plt.legend(handles=[line1, line2, line3], loc=2)
107+
plt.grid(True)
91108

92109
plt.subplot(2, 1, 2)
93-
plt.plot(x, cuadratic_error, '*r')
110+
plt.plot(x, mean_squared_error, '*r')
111+
plt.ylabel('Mean Squared Error', fontsize=12, fontweight='bold')
112+
plt.xlabel('Samples', fontsize=12, fontweight='bold')
113+
plt.grid(True)
94114
plt.yscale('log')
115+
95116
plt.show(block=block)

0 commit comments

Comments
 (0)