@@ -61,11 +61,14 @@ def observer_unconstrained(query_points):
6161def create_bo_model (data ):
6262 gpr = build_gpr (data , search_space )
6363 return GaussianProcessRegression (gpr )
64+
6465# set the random seed
66+ rand_seed = 42
67+ np .random .seed (rand_seed )
6568
6669search_space = Box ([1.0 ], [2.0 ])
6770num_init_points = 4
68- num_steps = 6
71+ num_steps = 4
6972init_data_cons = observer_constrained (search_space .sample (num_init_points ))
7073init_query_points = init_data_cons [OBJECTIVE ].query_points
7174init_data_uncons = observer_unconstrained (init_query_points )
@@ -82,6 +85,26 @@ def create_bo_model(data):
8285final_string = "Final\n n = " + str (num_init_points + num_steps )
8386ax [1 ,0 ].set_ylabel (final_string ,fontsize = 'x-large' ,rotation = 0 ,labelpad = 25 )
8487
88+ # annotate f'(x) in math script on ax[0,0], bottom right corner
89+ ax [0 ,0 ].annotate (r"$f'(x)$" , xy = (0.1 , 0.85 ), xycoords = 'axes fraction' , ha = 'center' , va = 'center' ,fontsize = 'xx-large' )
90+ ax [1 ,0 ].annotate (r"$f'(x)$" , xy = (0.1 , 0.85 ), xycoords = 'axes fraction' , ha = 'center' , va = 'center' ,fontsize = 'xx-large' )
91+
92+ # annotate f(x) in math script on ax[1,0], bottom left
93+ ax [0 ,1 ].annotate (r"$f(x)$" , xy = (0.1 , 0.2 ), xycoords = 'axes fraction' , ha = 'center' , va = 'center' ,fontsize = 'xx-large' )
94+ ax [1 ,1 ].annotate (r"$f(x)$" , xy = (0.1 , 0.2 ), xycoords = 'axes fraction' , ha = 'center' , va = 'center' ,fontsize = 'xx-large' )
95+
96+
97+ # annotate c(x) at (0.8, 0.5) in figure coordinates (not axis)
98+ #ax[0,1].annotate(r"$c(x)$", xy=(0.8, -0.1), xycoords='axes fraction', ha='center', va='center',fontsize='xx-large')
99+
100+ # get rid of xticks on ax[0,0] and ax[0,1]
101+ ax [0 ,0 ].set_xticks ([])
102+ ax [0 ,1 ].set_xticks ([])
103+
104+ # set xlabel for ax[1,0] and ax[1,1] as "x" in math script
105+ ax [1 ,0 ].set_xlabel (r"$x$" ,fontsize = 'xx-large' )
106+ ax [1 ,1 ].set_xlabel (r"$x$" ,fontsize = 'xx-large' )
107+
85108# for both the unconstrained plots, plot the true objective function
86109x = np .linspace (1 , 2 , 500 ).reshape (- 1 ,1 )
87110y = Sim_unconstrained .objective (tf .convert_to_tensor (x ))
@@ -116,9 +139,10 @@ def create_bo_model(data):
116139#cbar = plt.colorbar(ax[0,1].collections[0], ax=ax[0,1],cmap='RdBu')
117140cbar = fig .colorbar (mesh ,location = 'bottom' )
118141cbar .set_ticks ([0 ,0.5 , 1 ])
119- cbar .set_ticklabels (["Certainly\n Infeasible" ,"Inferred\n Threshold\n Value" , "Certainly\n Feasible" ])
142+ cbar .set_ticklabels (["Certainly\n Infeasible" ,"Inferred\n Threshold of $c(x)$" , "Certainly\n Feasible" ])
143+
144+ ax [0 ,0 ].legend (loc = 'lower right' ,fontsize = 'large' )
120145
121- ax [0 ,0 ].legend ()
122146
123147#plt.show()
124148
0 commit comments