mymap = vplot.get_vmap(2) extent = [ grids['states'][1][0], grids['states'][1][-1], grids['states'][0][0], grids['states'][0][-1] ] fig, axs = plt.subplots(1, figsize=(6, 5)) X_value = vibly.project_Q2S(data["Q_value"], grids, proj_opt=np.max) # lvls = [0., 0.15] print(X_value.max()) pc1 = vplot.value_function(axs, X_value, grids, XV=XV, cont_lvls=None, mymap=mymap, mynorm=mynorm) # fig.colorbar(pc1, ax=axs, orientation='horizontal', extend='both') fig.colorbar(pc1, ax=axs, orientation='horizontal', extend='max', ticks=[0., 1, 2.]) # * Reward function # pc0 = vplot.reward_function(axs, RX_value, grids, XV=XV, # mymap="PRGn", mynorm=mynorm) #, # viability_threshold=0) # fig.colorbar(pc0, ax=axs)
ymin=v_min, ymax=v_max, where=~XV_slice, facecolor='red', alpha=0.2) axs[0].add_collection(collection) axs[0].grid(True) # * plot value functions lvls = [-100., -75., -50., -25., alpha, 1.] for pdx, idx in enumerate(these_values): data = data_list[idx] X_value = vibly.project_Q2S(data["Q_value"], grids, proj_opt=np.max) pc3 = vplot.value_function(axs[pdx + 1], X_value, grids, XV=XV, mymap=mymap, mynorm=mynorm) for idx in range(num_plots - 1): plt.setp(axs[idx].get_xticklabels(), visible=False) fig.colorbar(pc1, ax=axs, orientation='horizontal', extend='both', spacing='proportional', ticks=lvls) # plt.savefig("Test up to 1e9"+'.pdf', format='pdf') plt.show() plt.close()
# viability_threshold = X_value[XV].min() # mynorm = colors.CenteredNorm() # mymap = plt.get_cmap('bwr_r') # shrunk_cmap = vplot.shiftedColorMap(mymap, start=0.2, midpoint=0.5, stop=0.8, name='shrunk') extent = [ grids['states'][1][0], grids['states'][1][-1], grids['states'][0][0], grids['states'][0][-1] ] fig, axs = plt.subplots(2, 1) # * Reward function RX_value = vibly.project_Q2S(R_value, grids, proj_opt=np.mean) pc0 = vplot.reward_function(axs[0], RX_value, grids, XV=XV, mymap="PRGn") fig.colorbar(pc0, ax=axs[0]) # * Value Function pc1 = vplot.value_function(axs[1], X_value, grids, XV=XV, mymap=mymap) fig.colorbar(pc1, ax=axs[1]) plt.savefig(savename + str(failure_penalty) + '.pdf', format='pdf') print("******************") print("******************") # plt.imshow(np.transpose(S_M), origin='lower') # visualize the S-safety measure # plt.show() # plt.imshow(Q_V) # visualize the viable set # plt.show()
plt.savefig('negproxy_R.pdf', format='pdf') plt.close() # * plot value functions # lvls = [-0.2, -0.1, -0.001, 0., 0.001, 0.1, 0.2, 1.] # lvls = [-100., -200., -50., -10., 0., 0.5, 1., 1.5, 2., 2.5, 3. ].sort() # lvls = [-100., -200., -50., 0., 1., 2., 3.].sort() # lvls=10 for pdx, data in enumerate(data_list): # data = data_list[ndx] fig, ax = plt.subplots(figsize=(colwide, 3 / 6 * colwide), constrained_layout=True) X_value = vibly.project_Q2S(data["Q_value"], grids, proj_opt=np.max) pc1 = vplot.value_function( ax, X_value, grids, XV=XV, # cont_lvls=lvls, mymap=mymap, mynorm=mynorm) print("max viable: ", X_value[XV].max()) print("min viable: ", X_value[XV].min()) print("max unviable: ", X_value[~XV].max()) print("min unviable: ", X_value[~XV].min()) print("-----") fig.colorbar(pc1, ax=ax, orientation='horizontal', extend='both', spacing='proportional', shrink=0.8) # fig.colorbar(pc1, ax=ax, orientation='horizontal', extend='min',