Skip to content

Commit

Permalink
Prepare for estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
JBjoernskov committed Jan 11, 2024
1 parent 815d858 commit 1c3411d
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions twin4build/estimator/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,6 @@ def run_emcee_estimation(self,
result["chain.jumps_proposed"].append(chain.jumps_proposed.copy())
result["chain.swaps_accepted"].append(chain.swaps_accepted.copy())
result["chain.swaps_proposed"].append(chain.swaps_proposed.copy())

print("---")
print("logl", chain.logl[i])
print("logP", chain.logP[i])

if i % n_save_checkpoint == 0:
result["chain.logl"] = chain.logl[:i]
Expand Down Expand Up @@ -314,10 +310,10 @@ def _loglike_wrapper(self, theta):
except FMICallException as inst:
return -1e+10

if self.use_simulated_annealing:
# Python returns a complex number for (-x)**y where x and y is positive. Python returns the real numbered root for -(x)**y where x and y is positive.
# Therefore abs is used to convert the negative loglike and then the sign is added after taking the power.
loglike = loglike*self.beta
# if self.use_simulated_annealing:
# # Python returns a complex number for (-x)**y where x and y is positive. Python returns the real numbered root for -(x)**y where x and y is positive.
# # Therefore abs is used to convert the negative loglike and then the sign is added after taking the power.
# loglike = loglike*self.beta
return loglike

def _loglike(self, theta):
Expand All @@ -336,17 +332,14 @@ def _loglike(self, theta):
targetMeasuringDevices=self.targetMeasuringDevices,
show_progress_bar=False)

print("----")
res = np.zeros((self.actual_readings.iloc[:,0].size, len(self.targetMeasuringDevices)))
for j, (y_scale, measuring_device) in enumerate(zip(self.y_scale, self.targetMeasuringDevices)):
simulation_readings = np.array(next(iter(measuring_device.savedInput.values())))[self.n_initialization_steps:]
actual_readings = self.actual_readings[measuring_device.id].to_numpy()
res[:,j] = (simulation_readings-actual_readings)/y_scale
print(measuring_device.id)
self.n_obj_eval+=1
ss = np.sum(res**2, axis=0)
loglike = -0.5*np.sum(ss/(self.standardDeviation**2))
print(self.standardDeviation)
if self.verbose:
print("=================")
with np.printoptions(precision=3, suppress=True):
Expand All @@ -369,10 +362,10 @@ def _loglike_gaussian_process_wrapper(self, theta):
except FMICallException as inst:
return -1e+10

if self.use_simulated_annealing:
# Python returns a complex number for (-x)**y where x and y is positive. Python returns the real numbered root for -(x)**y where x and y is positive.
# Therefore abs is used to convert the negative loglike and then the sign is added after taking the power.
loglike = loglike*self.beta
# if self.use_simulated_annealing:
# # Python returns a complex number for (-x)**y where x and y is positive. Python returns the real numbered root for -(x)**y where x and y is positive.
# # Therefore abs is used to convert the negative loglike and then the sign is added after taking the power.
# loglike = loglike*self.beta

return loglike

Expand Down

0 comments on commit 1c3411d

Please sign in to comment.