randltl: gracefully handle the absence of unary or binary operators.

* src/ltlvisit/randomltl.cc: Fix generation of formulas when unary or
binary operators are missing.
* src/ltlvisit/apcollect.cc, src/ltlvisit/apcollect.hh
(destroy_atomic_prop_set): New function.
* src/bin/randltl.cc: Use it, and also honnor --boolean-priorities
when generating SEREs.
* src/ltltest/rand.test: New file.
* src/ltltest/Makefile.am: Add it.
This commit is contained in:
Alexandre Duret-Lutz 2014-02-05 18:10:48 +01:00
parent 4911e7dc1f
commit 50bdc24514
6 changed files with 154 additions and 20 deletions

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2012 Laboratoire de Recherche et Développement
// Copyright (C) 2012, 2014 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
@ -53,6 +53,14 @@ namespace spot
};
}
void destroy_atomic_prop_set(atomic_prop_set& aprops)
{
atomic_prop_set::const_iterator i = aprops.begin();
while (i != aprops.end())
(*(i++))->destroy();
}
atomic_prop_set*
atomic_prop_collect(const formula* f, atomic_prop_set* s)
{

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2012, 2013, 2014 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
@ -40,6 +40,11 @@ namespace spot
typedef std::set<const atomic_prop*,
formula_ptr_less_than> atomic_prop_set;
/// \brief Destroy all the atomic propositions in an
/// atomic_prop_set.
SPOT_API void
destroy_atomic_prop_set(atomic_prop_set& as);
/// \brief Return the set of atomic propositions occurring in a formula.
///
/// \param f the formula to inspect

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2008, 2009, 2010, 2011, 2012 Laboratoire de Recherche
// et Développement de l'Epita (LRDE).
// Copyright (C) 2008, 2009, 2010, 2011, 2012, 2014 Laboratoire de
// Recherche et Développement de l'Epita (LRDE).
// Copyright (C) 2005 Laboratoire d'Informatique de Paris 6
// (LIP6), département Systèmes Répartis Coopératifs (SRC), Université
// Pierre et Marie Curie.
@ -191,9 +191,7 @@ namespace spot
else
assert(!"unexpected max_n");
}
assert(total_1_ != 0.0);
assert(total_2_ != 0.0);
assert(total_2_and_more_ != 0.0);
assert(total_2_and_more_ >= total_2_);
}
const formula*
@ -204,6 +202,30 @@ namespace spot
double r = drand();
op_proba* p;
// Approximate impossible cases.
if (n == 1 && total_1_ == 0.0)
{
if (total_2_ != 0.0)
n = 2;
else
n = 3;
}
else if (n == 2 && total_2_ == 0.0)
{
if (total_1_ != 0.0)
n = 1;
else
n = 3;
}
else if (n > 2 && total_2_and_more_ == 0.0)
{
if (total_1_ != 0.0)
n = 1;
else
assert(total_2_ == 0.0);
}
if (n == 1)
{
r *= total_1_;