Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
552 changes: 290 additions & 262 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Binary file added __pycache__/plots_RTO.cpython-37.pyc
Binary file not shown.
155 changes: 154 additions & 1 deletion plots_RTO.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,4 +725,157 @@ def plot_obj_noise(obj):
plt.tight_layout()
plt.savefig('figs_noise_WO/noexplore_prior.png', dpi=400)
plt.close()
return print(1)
return print(1)


#
#
# X_opt_mc, y_opt_mc, TR_l_mc, xnew_mc, backtrack_1_mc = pickle.load(
# open('prior_with_exploration_ei_no_red_constraint_violation.p', 'rb'))
# plant = Bio_system(nk=6)
# cons_system = [] # l.WO_obj_ca
# for k in range(plant.nk):
# cons_system.append(functools.partial(plant.bio_con1_ca, k + 1))
# cons_system.append(functools.partial(plant.bio_con2_ca, k + 1))
#
# obj_system = plant.bio_obj_ca
# cons_h = np.zeros([8, 63, 12])
# obj = np.zeros([8, 63])
# for i in range(8):
# max_obj = 0.
#
# for j in range(63):
# for ik in range(12):
# cons_h[i, j, ik] = cons_system[ik](np.array(X_opt_mc)[i, j])
# if j >= 13:
# # for k in range(100):
# p = 0.
# if (cons_h[i, j,:] > 1e-7).all(): # not(np.array(backtrack_1_mc)[i,j-13]):#cons_system[ik](np.array(X_opt_mc)[i,j-k])>0:
# # p+=1
# print(cons_h[i, j, :] > 1e-7)
# if -obj_system(np.array(X_opt_mc)[i, j]) > max_obj:
# max_obj = -obj_system(np.array(X_opt_mc)[i, j])
# obj[i, j] = max_obj
# else:
# obj[i, j] = max_obj
# else:
# obj[i, j] = max_obj
#
# # if p==1 or j== 13:
# # obj[i,j] = obj_system(np.array(X_opt_mc)[i,j-k])
# # break
#
# else:
# obj[i, j] = -obj_system(np.array(X_opt_mc)[i, j])

# csfont = {'fontname': 'Times New Roman'}
#
# # plt.rcParams['font.sans-serif'] = "Arial"
# plt.rcParams['font.family'] = "Times New Roman"
# ni = 50
# ft = int(20)
# font = {'size': ft}
# plt.rc('font', **font)
# plt.rc('text', usetex=True)
# params = {'legend.fontsize': 15,
# 'legend.handlelength': 2}
# plt.rcParams.update(params)
# plt.plot(np.linspace(1, 50, 50),obj[0,13:].T,color='#AA3939', label='Proposed')
# plt.plot(np.linspace(1, 50, 50),obj[[0,1,2,3,4,5,7],13:].T,color='#AA3939')
#
# plt.plot(np.linspace(1, 50, 50), [0.171] * ni, 'k--', label='Real Optimum')
#
# plt.xlabel('RTO-iter')
# plt.ylabel('Objective')
# plt.xlim(1, 50)
# plt.legend()
# plt.tick_params(right=True, top=True, left=True, bottom=True)
# plt.tick_params(axis="y", direction="in")
# plt.tick_params(axis="x", direction="in")
# plt.tight_layout()
# plt.savefig('figs_WO/EI_bio.png', dpi=400)
# plt.close()
X_opt_mc, y_opt_mc, TR_l_mc, xnew_mc, backtrack_1_mc = pickle.load(open('no_prior_with_exploration_ei_no_red_constraint_violation_GP.p', 'rb'))
X_opt_mc_model, y_opt_mc, TR_l_mc, xnew_mc, backtrack_1_mc = pickle.load(open('prior_with_exploration_ei_no_red_constraint_violation.p', 'rb'))
csfont = {'fontname': 'Times New Roman'}

# plt.rcParams['font.sans-serif'] = "Arial"
plt.rcParams['font.family'] = "Times New Roman"
ni = 50
ft = int(20)
font = {'size': ft}
plt.rc('font', **font)
plt.rc('text', usetex=True)
params = {'legend.fontsize': 15,
'legend.handlelength': 2}
plt.rcParams.update(params)
u1_opt = np.array([282.21090606, 282.21090606, 281.84839532, 280.74131362, 120.00896333, 120.01589492,
222.34601803])
# plt.step(np.linspace(0,6,7),(40-0)*np.array([np.array(X_opt_mc)[3,-1,1].T,*np.array(X_opt_mc)[3,-1,1::2].T])+0, where='pre',
# color='#AA3939', label='Proposed')
plt.step(np.linspace(0,6,7),u1_opt, where='pre',
color='#AA3939', label='Optimal')
u1 = np.array(X_opt_mc)[:,:,::2]

plt.fill_between(np.linspace(0,6,7),
np.quantile((400-120)*np.array([np.array(u1)[:,-1,1].T,
*np.array(u1)[:,-1].T])+120,0.05,axis=1),
np.quantile((400-120)*np.array([np.array(u1)[:,-1,1].T,
*np.array(u1)[:,-1].T])+120,0.95,axis=1),'-',step='pre'
,color='#226666',alpha=0.2)
plt.step(np.linspace(0,6,7),((400-120)*np.array([np.array(u1)[:,-1,1].T,*np.array(u1)[:,-1].T])).mean(1)+120,'--',where='pre'
,color='#226666', label='Proposed')

plt.ylabel('$I [\mu$mol m$^{-2}$s$^{-1}]$ ')
plt.xlabel('Normalized time [-]')
plt.xlim(0, 6)
plt.legend()
plt.tick_params(right=True, top=True, left=True, bottom=True)
plt.tick_params(axis="y", direction="in")
plt.tick_params(axis="x", direction="in")
plt.tight_layout()
plt.savefig('figs_WO/I2.png', dpi=400)
plt.close()

#
#X_opt_mc, y_opt_mc, TR_l_mc, xnew_mc, backtrack_1_mc = pickle.load(open('no_prior_with_exploration_ei_no_red_constraint_violation_GP.p', 'rb'))
X_opt_mc_model, y_opt_mc, TR_l_mc, xnew_mc, backtrack_1_mc = pickle.load(open('prior_with_exploration_ei_no_red_constraint_violation.p', 'rb'))
csfont = {'fontname': 'Times New Roman'}

# plt.rcParams['font.sans-serif'] = "Arial"
plt.rcParams['font.family'] = "Times New Roman"
ni = 50
ft = int(20)
font = {'size': ft}
plt.rc('font', **font)
plt.rc('text', usetex=True)
params = {'legend.fontsize': 15,
'legend.handlelength': 2}
plt.rcParams.update(params)

# plt.step(np.linspace(0,6,7),(40-0)*np.array([np.array(X_opt_mc)[3,-1,1].T,*np.array(X_opt_mc)[3,-1,1::2].T])+0, where='pre',
# color='#AA3939', label='Proposed')
u2_opt = np.array([25.06421834, 25.06421834, 16.03066446, 37.62476903, 39.99997563, 39.9999762, 39.99997472])
plt.step(np.linspace(0,6,7),u2_opt, where='pre',
color='#AA3939', label='Optimal')
u2 = np.array(X_opt_mc)[:,:,1::2]
plt.fill_between(np.linspace(0,6,7),
np.quantile((40)*np.array([np.array(u2)[:,-1,1].T,
*np.array(u2)[:,-1].T]),0.05,axis=1),
np.quantile((40)*np.array([np.array(u2)[:,-1,1].T,
*np.array(u2)[:,-1].T]),0.95,axis=1),'-',step='pre'
,color='#226666',alpha=0.2)
plt.step(np.linspace(0,6,7),((40)*np.array([np.array(u2)[:,-1,1].T,*np.array(u2)[:,-1].T])).mean(1),'--',where='pre'
,color='#226666', label='Proposed')

plt.ylabel('$F_{\sf N} [$mg L$^{-1}$h$^{-1}]$ ')
plt.xlabel('Normalized time [-]')
plt.xlim(0, 6)
plt.legend()
plt.tick_params(right=True, top=True, left=True, bottom=True)
plt.tick_params(axis="y", direction="in")
plt.tick_params(axis="x", direction="in")
plt.tight_layout()
plt.savefig('figs_WO/f_N2.png', dpi=400)
plt.close()

Empty file added run_Bio/__init__.py
Empty file.
Binary file added run_Bio/figs_WO/EI_bio_GP.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 run_Bio/figs_WO/I.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 run_Bio/figs_WO/I2.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 run_Bio/figs_WO/f_N.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 run_Bio/figs_WO/f_N2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading