|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
import os |
|
|
|
|
import time as tm |
|
|
|
|
from line_profiler import LineProfiler |
|
|
|
|
import numpy as np |
|
|
|
|
|
|
|
|
|
import network_graph as ng |
|
|
|
|
import sample_path as sp |
|
|
|
@ -30,12 +31,18 @@ class ParametersEstimator: |
|
|
|
|
#print("Elapsed Time ", t1) |
|
|
|
|
|
|
|
|
|
def parameters_estimation_single_trajectory(self, trajectory): |
|
|
|
|
tr_len = trajectory.shape[0] |
|
|
|
|
row_length = trajectory.shape[1] |
|
|
|
|
print(tr_len) |
|
|
|
|
print(row_length) |
|
|
|
|
t0 = tm.time() |
|
|
|
|
for indx, row in enumerate(trajectory): |
|
|
|
|
if trajectory[indx][1] == -1: |
|
|
|
|
""" #if int(trajectory[indx][1]) == -1: |
|
|
|
|
#break |
|
|
|
|
if indx == tr_len - 2: |
|
|
|
|
break |
|
|
|
|
if trajectory[indx + 1][1] != -1: |
|
|
|
|
transition = self.find_transition(trajectory[indx], trajectory[indx + 1]) |
|
|
|
|
transition = self.find_transition(trajectory[indx], trajectory[indx + 1], row_length) |
|
|
|
|
which_node = transition[0] |
|
|
|
|
# print(which_node) |
|
|
|
|
which_matrix = self.which_matrix_to_update(row, transition[0]) |
|
|
|
@ -43,7 +50,9 @@ class ParametersEstimator: |
|
|
|
|
self.amalgamated_cims_struct.update_state_transition_for_matrix(which_node, which_matrix, which_element) |
|
|
|
|
|
|
|
|
|
#changed_node = which_node |
|
|
|
|
time = self.compute_time_delta(trajectory[indx], trajectory[indx + 1]) |
|
|
|
|
if int(trajectory[indx][0]) == 0: |
|
|
|
|
time = trajectory[indx + 1][0] |
|
|
|
|
#time = self.compute_time_delta(trajectory[indx], trajectory[indx + 1]) |
|
|
|
|
which_element = transition[1][0] |
|
|
|
|
self.amalgamated_cims_struct.update_state_residence_time_for_matrix(which_node, which_matrix, which_element, |
|
|
|
|
time) |
|
|
|
@ -53,20 +62,19 @@ class ParametersEstimator: |
|
|
|
|
# print(node) |
|
|
|
|
which_node = node_indx |
|
|
|
|
which_matrix = self.which_matrix_to_update(row, node_indx) |
|
|
|
|
which_element = row[node_indx + 1] |
|
|
|
|
which_element = int(row[node_indx + 1]) |
|
|
|
|
# print("State res time element " + str(which_element) + node) |
|
|
|
|
# print("State res time matrix indx" + str(which_matrix)) |
|
|
|
|
self.amalgamated_cims_struct.update_state_residence_time_for_matrix(which_node, which_matrix, |
|
|
|
|
which_element, time) |
|
|
|
|
t1 = tm.time() - t0 |
|
|
|
|
print("Elapsed Time ", t1) |
|
|
|
|
print("Elapsed Time ", t1)""" |
|
|
|
|
|
|
|
|
|
def find_transition(self, current_row, next_row): |
|
|
|
|
for indx in range(1, len(current_row)): |
|
|
|
|
def find_transition(self, current_row, next_row, row_length): |
|
|
|
|
for indx in range(1, row_length): |
|
|
|
|
if current_row[indx] != next_row[indx]: |
|
|
|
|
return [indx - 1, (current_row[indx], next_row[indx])] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def compute_time_delta(self, current_row, next_row): |
|
|
|
|
return next_row[0] - current_row[0] |
|
|
|
|
|
|
|
|
@ -97,7 +105,7 @@ print(pe.amalgamated_cims_struct.get_set_of_cims(2).get_cims_number()) |
|
|
|
|
#pe.parameters_estimation_single_trajectory(pe.sample_path.trajectories[0].get_trajectory()) |
|
|
|
|
lp = LineProfiler() |
|
|
|
|
lp_wrapper = lp(pe.parameters_estimation_single_trajectory) |
|
|
|
|
lp_wrapper(pe.sample_path.trajectories[0].get_trajectory()) |
|
|
|
|
lp_wrapper(pe.sample_path.trajectories.get_trajectory()) |
|
|
|
|
lp.print_stats() |
|
|
|
|
#pe.parameters_estimation() |
|
|
|
|
"""for matrix in pe.amalgamated_cims_struct.get_set_of_cims(1).actual_cims: |
|
|
|
|