Skip to content

Commit

Permalink
upated plot disc, resolved prior error for TP1 cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kylajones committed Dec 8, 2023
1 parent 67e491b commit 1ab8525
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
13 changes: 13 additions & 0 deletions linfa/plot_disc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# lf_model_plus_disc = np.loadtxt(path2)
# lf_model_plus_disc_plus_noise = np.loadtxt(path3)

<<<<<<< Updated upstream
# plt.hist(lf_model[:,0], label = 'LF')
# plt.hist(lf_model_plus_disc[:,0], label = 'LF + disc')
# plt.hist(lf_model_plus_disc_plus_noise[:,0], label = 'LF + disc + noise')
Expand Down Expand Up @@ -76,3 +77,15 @@ def plot_discrepancy(file_path,train_grid_in,train_grid_out,test_grid):
# Draw histograms of lf+discr
# Draw histograms of lf
# Draw histograms of lf+discr+noise
=======
plt.hist(lf_model, label = 'LF', alpha =0.5)
plt.hist(lf_model_plus_disc, label = 'LF + disc', alpha =0.5)
plt.hist(lf_model_plus_disc_plus_noise, label = 'LF + disc + noise', alpha = 0.5)
plt.xlabel('Coverage')
plt.ylabel('Frequency')
plt.legend()
plt.show()

# shape: number of no TP-pairs x Batch size (5000)
print(np.shape(lf_model))
>>>>>>> Stashed changes
13 changes: 5 additions & 8 deletions linfa/tests/test_discr_08_prior_TP1.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def run_test():
exp.surr_upd_it = 2000 # int: Number of iterations for the surrogate model update
exp.calibrate_interval = 1000 #:int: How often the surrogate model is updated

exp.annealing = False # TODO : turn this on eventually
exp.annealing = False
exp.budget = 216 # int: Total number of true model evaulations
exp.surr_folder = "./"
exp.use_new_surr = True
Expand All @@ -61,8 +61,8 @@ def run_test():
exp.transform = trsf

# Add temperatures and pressures for each evaluation
variable_inputs = [[350.0, 400.0, 450.0],
[1.0, 2.0, 3.0, 4.0, 5.0]]
variable_inputs = [[350.0],
[1.0]]

# Define model
langmuir_model = PhysChem(variable_inputs)
Expand Down Expand Up @@ -108,8 +108,7 @@ def log_density(calib_inputs, model, surrogate, transform):

# Initialize total number of variable inputs
total_var_inputs = len(model.var_in)

# HAD TO MOVE THIS UP BEFORE EVALUATE DISCREPANCY

# Evaluate model response - (num_var x num_batch)
modelOut = langmuir_model.solve_t(transform.forward(calib_inputs)).t()

Expand All @@ -131,8 +130,6 @@ def log_density(calib_inputs, model, surrogate, transform):
# Loop on the available observations
for loopA in range(num_obs):
l1 = -0.5 * np.prod(langmuir_model.data.shape) * np.log(2.0 * np.pi)

# TODO: generalize to multiple inputs
l2 = (-0.5 * langmuir_model.data.shape[1] * torch.log(torch.prod(stds))).item()
l3 = -0.5 * torch.sum(((modelOut + discrepancy.t() - Data[:,loopA].unsqueeze(0)) / stds.t())**2, dim = 1)

Expand Down Expand Up @@ -198,7 +195,7 @@ def generate_data(use_true_model=False,num_observations=50):

generate_data(use_true_model=True, num_observations=1)

#run_test()
run_test()



Expand Down
4 changes: 2 additions & 2 deletions linfa/tests/test_discr_17_prior_TP1_rep_meas.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def run_test():
exp.transform = trsf

# Add temperatures and pressures for each evaluation
variable_inputs = [[350.0, 400.0, 450.0],
[1.0, 2.0, 3.0, 4.0, 5.0]]
variable_inputs = [[350.0],
[1.0]]

# Define model
langmuir_model = PhysChem(variable_inputs)
Expand Down

0 comments on commit 1ab8525

Please sign in to comment.