1
0
Fork 0
Old engine for Continuous Time Bayesian Networks. Superseded by reCTBN. 🐍 https://github.com/madlabunimib/PyCTBN
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
PyCTBN/main_package/classes/cache.py

24 lines
695 B

4 years ago
import typing
import set_of_cims as sofc
class Cache:
def __init__(self):
self.list_of_sets_of_indxs = []
self.actual_cache = []
def find(self, parents_comb: typing.Set):
try:
result = self.actual_cache[self.list_of_sets_of_indxs.index(parents_comb)]
print("CACHE HIT!!!!")
return result
except ValueError:
return None
def put(self, parents_comb: typing.Set, socim: sofc.SetOfCims):
self.list_of_sets_of_indxs.append(parents_comb)
self.actual_cache.append(socim)
def clear(self):
del self.list_of_sets_of_indxs[:]
del self.actual_cache[:]