Merge branch 'master' into next

Conflicts:
	src/ltlvisit/simplify.cc
	src/tgbatest/Makefile.am
This commit is contained in:
Alexandre Duret-Lutz 2014-05-15 14:30:49 +02:00
commit 53de8fc3a4
24 changed files with 333 additions and 223 deletions

View file

@ -25,6 +25,7 @@
#include "ltlast/constant.hh"
#include <deque>
#include <vector>
#include <algorithm>
#include "tgbaalgos/scc.hh"
#include "tgba/bddprint.hh"
@ -174,7 +175,7 @@ namespace spot
public:
unsigned
next_level(bdd all, int slevel, bdd acc)
next_level(bdd all, int slevel, bdd acc, bool skip_levels)
{
bdd temp = acc;
if (all != found_)
@ -200,7 +201,11 @@ namespace spot
acc = temp;
unsigned next = slevel;
while (next < order_.size() && bdd_implies(order_[next], acc))
++next;
{
++next;
if (!skip_levels)
break;
}
return next;
}
@ -223,16 +228,18 @@ namespace spot
{
bdd all_;
std::map<int, acc_order> orders_;
bool skip_levels_;
public:
scc_orders(bdd all): all_(all)
scc_orders(bdd all, bool skip_levels):
all_(all), skip_levels_(skip_levels)
{
}
unsigned
next_level(int scc, int slevel, bdd acc)
{
return orders_[scc].next_level(all_, slevel, acc);
return orders_[scc].next_level(all_, slevel, acc, skip_levels_);
}
void
@ -247,7 +254,7 @@ namespace spot
sba*
degeneralize(const tgba* a, bool use_z_lvl, bool use_cust_acc_orders,
bool use_lvl_cache)
int use_lvl_cache, bool skip_levels)
{
bool use_scc = use_lvl_cache || use_cust_acc_orders || use_z_lvl;
@ -290,7 +297,7 @@ namespace spot
}
// Initialize scc_orders
scc_orders orders(a->all_acceptance_conditions());
scc_orders orders(a->all_acceptance_conditions(), skip_levels);
// Make sure we always use the same pointer for identical states
// from the input automaton.
@ -312,7 +319,7 @@ namespace spot
tr_cache_t tr_cache;
// State level cache
typedef std::map<const state*, int> lvl_cache_t;
typedef std::map<const state*, unsigned> lvl_cache_t;
lvl_cache_t lvl_cache;
// Compute SCCs in order to use any optimization.
@ -342,7 +349,11 @@ namespace spot
s.second = orders.next_level(m.initial(), s.second, acc);
else
while (s.second < order.size() && bdd_implies(order[s.second], acc))
++s.second;
{
++s.second;
if (!skip_levels)
break;
}
}
#ifdef DEGEN_DEBUG
@ -479,7 +490,8 @@ namespace spot
// }
if (is_scc_acc)
{
// If lvl_cache is used and switching SCCs, use level from cache
// If lvl_cache is used and switching SCCs, use level
// from cache
if (use_lvl_cache && s_scc != scc
&& lvl_cache.find(d.first) != lvl_cache.end())
{
@ -520,10 +532,17 @@ namespace spot
// Consider both the current acceptance
// sets, and the acceptance sets common to
// the outgoing transitions of the
// destination state.
while (next < order.size()
&& bdd_implies(order[next], acc))
++next;
// destination state. But don't do
// that if the state is accepting and we
// are not skipping levels.
if (skip_levels || !is_acc)
while (next < order.size()
&& bdd_implies(order[next], acc))
{
++next;
if (!skip_levels)
break;
}
d.second = next;
}
}
@ -547,8 +566,23 @@ namespace spot
ds2num[d] = dest;
todo.push_back(d);
// Insert new state to cache
if (use_lvl_cache && lvl_cache.find(d.first) == lvl_cache.end())
lvl_cache[d.first] = d.second;
if (use_lvl_cache)
{
std::pair<lvl_cache_t::iterator, bool> res =
lvl_cache.insert(lvl_cache_t::value_type(d.first,
d.second));
if (!res.second)
{
if (use_lvl_cache == 3)
res.first->second =
std::max(res.first->second, d.second);
else if (use_lvl_cache == 2)
res.first->second =
std::min(res.first->second, d.second);
}
}
}
state_explicit_number::transition*& t =

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement
// Copyright (C) 2012, 2013, 2014 Laboratoire de Recherche et Développement
// de l'Epita.
//
// This file is part of Spot, a model checking library.
@ -44,7 +44,9 @@ namespace spot
/// default because our benchmarks show that it usually does more
/// harm than good). If \a use_lvl_cache is set, everytime an SCC
/// is entered on a state that as already been associated to some
/// level elsewhere, reuse that level).
/// level elsewhere, reuse that level (set it to 2 to keep the
/// smallest number, 3 to keep the largest level, and 1 to keep the
/// first level found).
///
/// Any of these three options will cause the SCCs of the automaton
/// \a a to be computed prior to its actual degeneralization.
@ -53,7 +55,8 @@ namespace spot
SPOT_API sba*
degeneralize(const tgba* a, bool use_z_lvl = true,
bool use_cust_acc_orders = false,
bool use_lvl_cache = true);
int use_lvl_cache = 1,
bool skip_levels = true);
}

View file

@ -913,11 +913,12 @@ namespace spot
}
if (dest->kind() != formula::Constant)
// If the destination is not 0 or [*0], it means it
// can have successors. Fusion the tail and append
// anything to concatenate.
if (dest->kind() != formula::Constant
|| dest == ltl::constant::true_instance())
{
// If the destination is not a constant, it
// means it can have successors. Fusion the
// tail and append anything to concatenate.
const formula* dest2 =
multop::instance(multop::Fusion, dest, tail->clone());
if (to_concat_)

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).
//
// This file is part of Spot, a model checking library.
//
@ -39,15 +39,16 @@ namespace spot
postprocessor::postprocessor(const option_map* opt)
: type_(TGBA), pref_(Small), level_(High),
degen_reset_(true), degen_order_(false), degen_cache_(true),
simul_(-1), scc_filter_(-1), ba_simul_(-1), tba_determinisation_(false),
sat_minimize_(0), sat_acc_(0), sat_states_(0), state_based_(false),
wdba_minimize_(true)
degen_lskip_(true), simul_(-1), scc_filter_(-1), ba_simul_(-1),
tba_determinisation_(false), sat_minimize_(0), sat_acc_(0),
sat_states_(0), state_based_(false), wdba_minimize_(true)
{
if (opt)
{
degen_order_ = opt->get("degen-order", 0);
degen_reset_ = opt->get("degen-reset", 1);
degen_cache_ = opt->get("degen-lcache", 1);
degen_lskip_ = opt->get("degen-lskip", 1);
simul_ = opt->get("simul", -1);
simul_limit_ = opt->get("simul-limit", -1);
scc_filter_ = opt->get("scc-filter", -1);
@ -116,7 +117,8 @@ namespace spot
const tgba* d = degeneralize(a,
degen_reset_,
degen_order_,
degen_cache_);
degen_cache_,
degen_lskip_);
delete a;
if (ba_simul_ <= 0)
return d;

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).
//
// This file is part of Spot, a model checking library.
//
@ -110,7 +110,8 @@ namespace spot
// Fine-tuning options fetched from the option_map.
bool degen_reset_;
bool degen_order_;
bool degen_cache_;
int degen_cache_;
bool degen_lskip_;
int simul_;
int simul_limit_;
int scc_filter_;