randaut: add a --colored option

Fixes #83.

* src/bin/randaut.cc: Add option.
* src/twaalgos/randomgraph.cc, src/twaalgos/randomgraph.hh: Honor it.
* src/tests/randaut.test: Add tests.
* doc/org/randaut.org: Document it.
This commit is contained in:
Alexandre Duret-Lutz 2015-06-01 21:56:39 +02:00
parent 97665a584e
commit 715805fad3
5 changed files with 148 additions and 33 deletions

View file

@ -152,7 +152,7 @@ $txt
* Acceptance condition
The generation of the acceptance sets abn is controlled with the following three parameters:
The generation of the acceptance sets abn is controlled with the following four parameters:
- =-A ACCEPTANCE= (or =--acceptance=ACCEPTANCE=) controls both the acceptance condition,
and the number of associated acceptance sets. The =ACCEPTANCE= argument is documented
@ -191,12 +191,17 @@ randaut --help | sed -n '/^ \(ACCEPTANCE\|RANGE\)/,/^$/p'
- =-a= (or =--acc-probability=) controls the probability that any
transition belong to a given acceptance set.
- =-S= (or =--state-acc=) requests that the automaton use state-based
acceptance. In this case, =-a= is the probability that a /state/
belong to the acceptance set. (Because Spot only deals with
transition-based acceptance internally, this options force all
transitions leaving a state to belong to the same acceptance sets.
But if the output format allows state-acceptance, it will be used.)
- =-S= (or =--state-based-acceptance=) requests that the automaton
use state-based acceptance. In this case, =-a= is the probability
that a /state/ belong to the acceptance set. (Because Spot only
deals with transition-based acceptance internally, this options
force all transitions leaving a state to belong to the same
acceptance sets. But if the output format allows state-based
acceptance, it will be used.)
- =--colored= requests that each transition (of state if combined with =-S=)
in the generated automaton should belong to exactly one set (in that
case =-a= is ignored, and =-A= must be used to specify an acceptance
condition with at least one set).
In addition, =-B= (or =--ba=) is a shorthand for =-A1 -S=,
ans =-s= (or =--spin=) implies =-B=.
@ -268,14 +273,14 @@ $txt
#+NAME: randaut5b
#+BEGIN_SRC sh :results verbatim :exports code
randaut -Q6 -d0.4 --state-acc -a.2 -A 'Streett 1..3' 2 --dot=.a
randaut -Q6 -d0.4 -S -a.2 -A 'Streett 1..3' 2 --dot=.a
#+END_SRC
#+RESULTS: randaut5b
#+begin_example
digraph G {
rankdir=LR
label=<(Fin(<font color="#5DA5DA">⓿</font>) | Inf(<font color="#F17CB0">❶</font>)) &amp; (Fin(<font color="#FAA43A">❷</font>) | Inf(<font color="#B276B2">❸</font>))>
label=<(Fin(<font color="#5DA5DA">⓿</font>) | Inf(<font color="#F17CB0">❶</font>)) &amp; (Fin(<font color="#FAA43A">❷</font>) | Inf(<font color="#B276B2">❸</font>))>
labelloc="t"
node [shape="circle"]
fontname="Lato"
@ -290,21 +295,20 @@ digraph G {
0 -> 3 [label=<!p0 &amp; !p1>]
1 [label=<1>]
1 -> 5 [label=<!p0 &amp; p1>]
2 [label=<2<br/><font color="#5DA5DA">⓿</font><font color="#FAA43A">❷</font>>]
2 -> 0 [label=<!p0 &amp; p1>]
2 -> 4 [label=<!p0 &amp; !p1>]
2 [label=<2<br/><font color="#5DA5DA">⓿</font><font color="#FAA43A">❷</font>>]
2 -> 1 [label=<!p0 &amp; p1>]
2 -> 2 [label=<!p0 &amp; !p1>]
2 -> 4 [label=<p0 &amp; p1>]
3 [label=<3>]
3 -> 1 [label=<!p0 &amp; !p1>]
3 -> 2 [label=<p0 &amp; !p1>]
3 -> 5 [label=<!p0 &amp; !p1>]
3 -> 4 [label=<p0 &amp; !p1>]
4 [label=<4<br/><font color="#B276B2">❸</font>>]
4 -> 2 [label=<p0 &amp; !p1>]
4 -> 5 [label=<!p0 &amp; !p1>]
4 -> 3 [label=<!p0 &amp; p1>]
5 [label=<5<br/><font color="#F17CB0">❶</font>>]
5 -> 3 [label=<!p0 &amp; p1>]
3 -> 2 [label=<!p0 &amp; !p1>]
3 -> 3 [label=<!p0 &amp; p1>]
4 [label=<4>]
4 -> 0 [label=<!p0 &amp; !p1>]
4 -> 5 [label=<!p0 &amp; p1>]
5 [label=<5<br/><font color="#F17CB0">❶</font><font color="#FAA43A">❷</font>>]
5 -> 1 [label=<p0 &amp; p1>]
5 -> 2 [label=<!p0 &amp; !p1>]
5 -> 3 [label=<p0 &amp; p1>]
}
#+end_example
@ -314,6 +318,73 @@ $txt
#+RESULTS:
[[file:randaut5b.png]]
For generating random parity automata you should use the option
=--colored= to make sure each transition (or state in the following
example) belong to exactly one acceptance set. Note that you can
specify a precise parity acceptance such as =parity min even 3=, or
give =randaut= some freedom, as in this example.
#+NAME: randaut5c
#+BEGIN_SRC sh :results verbatim :exports code
randaut -Q10 -S --colored -A 'parity rand rand 3..4' 2 --dot=.a
#+END_SRC
#+RESULTS: randaut5c
#+begin_example
digraph G {
rankdir=LR
label=<Inf(<font color="#5DA5DA">⓿</font>) | (Fin(<font color="#F17CB0">❶</font>) &amp; (Inf(<font color="#FAA43A">❷</font>) | Fin(<font color="#B276B2">❸</font>)))>
labelloc="t"
node [shape="circle"]
fontname="Lato"
node [fontname="Lato"]
edge [fontname="Lato"]
node[style=filled, fillcolor="#ffffa0"] edge[arrowhead=vee, arrowsize=.7]
I [label="", style=invis, width=0]
I -> 0
0 [label=<0<br/><font color="#F17CB0">❶</font>>]
0 -> 2 [label=<!p0 &amp; !p1>]
0 -> 8 [label=<!p0 &amp; !p1>]
0 -> 0 [label=<p0 &amp; !p1>]
0 -> 6 [label=<!p0 &amp; p1>]
1 [label=<1<br/><font color="#B276B2">❸</font>>]
1 -> 5 [label=<!p0 &amp; !p1>]
1 -> 9 [label=<!p0 &amp; p1>]
2 [label=<2<br/><font color="#FAA43A">❷</font>>]
2 -> 4 [label=<p0 &amp; p1>]
2 -> 5 [label=<!p0 &amp; !p1>]
3 [label=<3<br/><font color="#5DA5DA">⓿</font>>]
3 -> 6 [label=<p0 &amp; !p1>]
3 -> 1 [label=<!p0 &amp; p1>]
4 [label=<4<br/><font color="#5DA5DA">⓿</font>>]
4 -> 6 [label=<!p0 &amp; !p1>]
4 -> 1 [label=<p0 &amp; p1>]
5 [label=<5<br/><font color="#5DA5DA">⓿</font>>]
5 -> 0 [label=<!p0 &amp; !p1>]
5 -> 8 [label=<p0 &amp; !p1>]
5 -> 7 [label=<!p0 &amp; !p1>]
6 [label=<6<br/><font color="#5DA5DA">⓿</font>>]
6 -> 2 [label=<!p0 &amp; !p1>]
6 -> 3 [label=<!p0 &amp; !p1>]
7 [label=<7<br/><font color="#FAA43A">❷</font>>]
7 -> 3 [label=<!p0 &amp; p1>]
7 -> 1 [label=<!p0 &amp; p1>]
8 [label=<8<br/><font color="#5DA5DA">⓿</font>>]
8 -> 3 [label=<!p0 &amp; p1>]
8 -> 4 [label=<p0 &amp; !p1>]
8 -> 2 [label=<p0 &amp; !p1>]
8 -> 0 [label=<!p0 &amp; p1>]
9 [label=<9<br/><font color="#F17CB0">❶</font>>]
9 -> 0 [label=<p0 &amp; p1>]
9 -> 6 [label=<p0 &amp; !p1>]
}
#+end_example
#+BEGIN_SRC dot :file randaut5c.png :cmdline -Tpng :var txt=randaut5c :exports results
$txt
#+END_SRC
#+RESULTS:
[[file:randaut5c.png]]
* Determinism