sat_minimize: improve logs and document Python bindings
* spot/priv/satcommon.cc, spot/priv/satcommon.hh: Make it possible to set the log file without setting the environment variable. Adjust print_log to take the input state and print it as a new column. * spot/twaalgos/dtbasat.cc, spot/twaalgos/dtwasat.cc: Adjust all calls to print_log. Fix log output for incremental approaches. Prefer purge_unreachable_states() over stats_reachable(). Do not call scc_filter() on colored automata. * spot/twaalgos/dtwasat.hh: Document the new "log" option. * NEWS: Mention the changes. * tests/python/satmin.ipynb: New file. * tests/Makefile.am: Add it. * doc/org/satmin.org, doc/org/tut.org: Link to it. * doc/org/satmin.org, bin/man/spot-x.x: Adjust description of CSV files. * bench/dtgbasat/gen.py, bench/dtgbasat/tabl.pl, bench/dtgbasat/tabl1.pl, bench/dtgbasat/tabl2.pl, bench/dtgbasat/tabl3.pl, bench/dtgbasat/tabl4.pl: Adjust for the new column. * spot/misc/satsolver.cc, spot/misc/satsolver.hh (stats): Make it const. * python/spot/__init__.py (sat_minimize): Add display_log and return_log options. * tests/python/ipnbdoctest.py: Adjust to not compare SAT-minimization logs as they contain timings.
This commit is contained in:
parent
5266010889
commit
c766f58d5d
21 changed files with 5076 additions and 177 deletions
|
|
@ -33,7 +33,7 @@ from spot.aux import \
|
|||
import subprocess
|
||||
import os
|
||||
import signal
|
||||
|
||||
import tempfile
|
||||
|
||||
# The parrameters used by default when show() is called on an automaton.
|
||||
_show_default = None
|
||||
|
|
@ -927,7 +927,8 @@ for fun in ['remove_x', 'relabel', 'relabel_bse',
|
|||
def sat_minimize(aut, acc=None, colored=False,
|
||||
state_based=False, states=0,
|
||||
max_states=0, sat_naive=False, sat_langmap=False,
|
||||
sat_incr=0, sat_incr_steps=0):
|
||||
sat_incr=0, sat_incr_steps=0,
|
||||
display_log=False, return_log=False):
|
||||
args=''
|
||||
if acc is not None:
|
||||
if type(acc) is not str:
|
||||
|
|
@ -950,9 +951,25 @@ def sat_minimize(aut, acc=None, colored=False,
|
|||
if sat_incr:
|
||||
args += ',sat-incr=' + str(sat_incr)
|
||||
args += ',sat-incr-steps=' + str(sat_incr_steps)
|
||||
|
||||
from spot.impl import sat_minimize as sm
|
||||
return sm(aut, args, state_based)
|
||||
|
||||
if display_log or return_log:
|
||||
import pandas as pd
|
||||
with tempfile.NamedTemporaryFile(dir='.', suffix='.satlog') as t:
|
||||
args += ',log="{}"'.format(t.name)
|
||||
aut = sm(aut, args, state_based)
|
||||
dfrm = pd.read_csv(t.name, dtype=object)
|
||||
if display_log:
|
||||
# old versions of ipython do not import display by default
|
||||
from IPython.display import display
|
||||
del dfrm['automaton']
|
||||
display(dfrm)
|
||||
if return_log:
|
||||
return aut, dfrm
|
||||
else:
|
||||
return aut
|
||||
else:
|
||||
return sm(aut, args, state_based)
|
||||
|
||||
|
||||
def parse_word(word, dic=_bdd_dict):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue