Skip to content

Commit f0daa88

Browse files
committed
added comments in the code
1 parent 42e5950 commit f0daa88

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

GLIS_BO_analysis.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
from scipy.interpolate import interp1d
1515
if __name__ == '__main__':
1616

17-
algo = 'GLIS'
18-
#algo = 'BO'
19-
20-
machine = 'PI' # PC or PI
17+
algo = 'GLIS' # GLIS or BO
18+
machine = 'PC' # PC or PI
2119
eps_calc = 1.0
2220
iter_max_plot = 500
2321

@@ -124,26 +122,26 @@ def xref_fun_def(t):
124122

125123
# In[Iteration plot]
126124

127-
Y = results['J_sample']
125+
J = results['J_sample']
128126
Ts_MPC = simout['Ts_MPC']
129127

130-
Y_best_curr = np.zeros(np.shape(Y))
131-
Y_best_val = Y[0]
128+
J_best_curr = np.zeros(np.shape(J))
129+
J_best_val = J[0]
132130
iter_best_val = 0
133131

134132
fig, axes = plt.subplots(1, 1, figsize=(6, 4))
135133
axes = [axes]
136-
for i in range(len(Y_best_curr)):
137-
if Y[i] < Y_best_val:
138-
Y_best_val = Y[i]
134+
for i in range(len(J_best_curr)):
135+
if J[i] < J_best_val:
136+
J_best_val = J[i]
139137
iter_best_val = i
140-
Y_best_curr[i] = Y_best_val
138+
J_best_curr[i] = J_best_val
141139

142-
N = len(Y)
140+
N = len(J)
143141
iter = np.arange(1, N + 1, dtype=np.int)
144-
axes[0].plot(iter, Y, 'k*', label='Current test point')
142+
axes[0].plot(iter, J, 'k*', label='Current test point')
145143
# axes[0].plot(iter, Y_best_curr, 'r', label='Current best point')
146-
axes[0].plot(iter, Y_best_val * np.ones(Y.shape), '-', label='Overall best point', color='red')
144+
axes[0].plot(iter, J_best_val * np.ones(J.shape), '-', label='Overall best point', color='red')
147145
axes[0].set_xlabel("Iteration index n (-)")
148146
axes[0].set_ylabel(r"Performance cost $\tilde {J}^{\mathrm{cl}}$")
149147

GLIS_BO_main.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
if __name__ == '__main__':
1717

18-
np.random.seed(2)
18+
np.random.seed(0)
1919
# initial random points
2020

2121
# optimization parameters
@@ -26,9 +26,8 @@
2626
eps = 0.0 # Minimum allows distance between the las two observations
2727
eps_calc = 1.0
2828

29-
# method = 'BO'
30-
method = "GLIS"
31-
machine = 'PI' # PC or PI
29+
method = "GLIS" # GLIS or BO
30+
machine = 'PC' # PC or PI
3231

3332

3433
dict_x0 = {

0 commit comments

Comments
 (0)