randaut: add option --acc-type=random

Fixes #71.

* src/bin/randaut.cc: Implement option --acc-type.
* src/tgbaalgos/randomgraph.cc,
src/tgbaalgos/randomgraph.hh (random_acceptance): New function.
* src/tgbatest/randaut.test, wrap/python/tests/randaut.ipynb: Test it.
This commit is contained in:
Alexandre Duret-Lutz 2015-03-31 13:46:25 +02:00
parent d3ee61979c
commit 2f42c1c9bf
5 changed files with 2017 additions and 1830 deletions

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2008, 2009, 2010, 2012, 2013, 2014 Laboratoire de
// Copyright (C) 2008, 2009, 2010, 2012, 2013, 2014, 2015 Laboratoire de
// Recherche et Développement de l'Epita (LRDE).
// Copyright (C) 2004, 2005, 2007 Laboratoire d'Informatique de
// Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
@ -241,4 +241,41 @@ namespace spot
return res;
}
acc_cond::acc_code random_acceptance(unsigned n_accs)
{
// With 0 acceptance sets, we always generate the true acceptance.
// (Working with false is somehow pointless, and the formulas we
// generate for n_accs>0 are always satisfiable, so it makes sense
// that it should be satisfiable for n_accs=0 as well.)
if (n_accs == 0)
return {};
acc_cond acc(n_accs);
std::vector<acc_cond::acc_code> codes;
codes.reserve(n_accs);
for (unsigned i = 0; i < n_accs; ++i)
if (drand() < 0.5)
codes.push_back(acc.inf(acc.mark(i)));
else
codes.push_back(acc.fin(acc.mark(i)));
int s = codes.size();
while (s > 1)
{
// Pick a random code and put it at the end
int p1 = mrand(s--);
std::swap(codes[p1], codes[s]);
// and another one
int p2 = mrand(s);
if (drand() < 0.5)
codes[p2].append_or(std::move(codes.back()));
else
codes[p2].append_and(std::move(codes.back()));
codes.pop_back();
}
return codes[0];
}
}