Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion PRINS/run_PRINS.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@
m_sys, _, _, _ = instance.run(mint_timeout=args.timeout,
ignore_values=args.ignore_values,
save_pdf=args.save_pdf,
det = args.det != 'none',
num_workers=args.num_workers,
use_pickle=args.use_pickle)
if args.det != 'none':
PRINS.postprocess(m_sys, determinize_technique=args.det)
PRINS.postprocess(m_sys, determinize_technique=args.det, save_pdf=args.save_pdf, output_dir = os.path.join(args.output_dir, args.system))
logger.info('run_PRINS ends without error(s).')
15 changes: 11 additions & 4 deletions PRINS/src/main/PRINS.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(self, system: str, logs, output_dir: str):
self.l_vectors = convert_df_into_l_vectors(self.logs_df, include_component=True)
self.components = natsorted(self.logs_df.component.unique())

def run(self, mint_timeout=3600, mint_param=2, ignore_values=False, save_pdf=True, num_workers=4, use_pickle=False):
def run(self, mint_timeout=3600, mint_param=2, ignore_values=False, save_pdf=True, det = False, num_workers=4, use_pickle=False):
"""Run PRINS (main algorithm).

:param mint_timeout: mint timeout (sec) (default=3600)
Expand Down Expand Up @@ -169,8 +169,8 @@ def run(self, mint_timeout=3600, mint_param=2, ignore_values=False, save_pdf=Tru
lc_div_score = len(set(all_components)) / len(all_components)
print(f'lcDivScore: {lc_div_score:.3f}')

# (optional) Saving the Results as a pdf file
if save_pdf:
# (optional) Saving the Results as a pdf file if deterministic technique is not asked
if save_pdf and not det:
if len(m_sys.states) < 1000:
m_sys.save_pdf(output_dir=self.output_dir)
else:
Expand Down Expand Up @@ -253,7 +253,7 @@ def partition_log_by_component(l_vector: list) -> list:
return partitioned_log

@staticmethod
def postprocess(m_sys: 'NFA', determinize_technique: str = 'hybrid-1'):
def postprocess(m_sys: 'NFA', determinize_technique: str = 'hybrid-1', save_pdf=True, output_dir = "/."):
"""
Postprocessing function.
Currently, we only convert NFA to DFA.
Expand All @@ -279,4 +279,11 @@ def postprocess(m_sys: 'NFA', determinize_technique: str = 'hybrid-1'):
print(f'Post-processed model (m_sys): states={len(dfa_sys.states)}, transitions={len(dfa_sys.transitions)}')
logger.info(f'Post-processed model (m_sys): states={len(dfa_sys.states)}, transitions={len(dfa_sys.transitions)}')

# (optional) Saving the Results as a pdf file
if save_pdf:
if len(dfa_sys.states) < 1000:
dfa_sys.save_pdf(output_dir)
else:
print(f'Do not save model.pdf because of too many states: {len(m_sys.states)}')

return dfa_sys, time.time() - start_time