23#include <spot/graph/graph.hh>
24#include <spot/misc/hash.hh>
25#include <spot/twa/acc.hh>
26#include <spot/twacube/cube.hh>
27#include <spot/twacube/fwd.hh>
57 public std::enable_shared_from_this<trans_index>
92 return !idx_ || idx_ > st_.succ_tail;
97 inline unsigned current(
unsigned seed = 0)
const
101 if (SPOT_UNLIKELY(!seed))
108 SPOT_ASSERT(primes[seed] > (st_.succ_tail-st_.succ+1));
109 unsigned long long c = (idx_-st_.succ) + 1;
110 unsigned long long p = primes[seed];
111 unsigned long long s = (st_.succ_tail-st_.succ+1);
112 return (
unsigned) (((c*p) % s)+st_.succ);
117 const graph_t::state_storage_t& st_;
121 class SPOT_API
twacube final:
public std::enable_shared_from_this<twacube>
135 std::vector<std::string>
ap()
const;
163 unsigned num_states()
const
165 return theg_.num_states();
168 unsigned num_edges()
const
170 return theg_.num_edges();
173 typedef digraph<cstate, transition> graph_t;
180 typedef graph_t::edge_storage_t edge_storage_t;
183 const graph_t::edge_storage_t&
185 unsigned seed = 0)
const
187 return theg_.edge_storage(ci->current(seed));
192 unsigned seed = 0)
const
194 return theg_.edge_data(ci->current(seed));
198 std::shared_ptr<trans_index> succ(
unsigned i)
const
200 return std::make_shared<trans_index>(i, theg_);
203 friend SPOT_API std::ostream& operator<<(std::ostream& os,
208 const std::vector<std::string> aps_;
213 inline twacube_ptr make_twacube(
const std::vector<std::string> aps)
215 return std::make_shared<twacube>(aps);
An acceptance condition.
Definition: acc.hh:61
Class for thread-safe states.
Definition: twacube.hh:33
state_storage_t & state_storage(state s)
return a reference to the storage of a state
Definition: graph.hh:711
Abstract class for states.
Definition: twa.hh:47
Class for iterators over transitions.
Definition: twacube.hh:58
bool done() const
Returns a boolean indicating wether all the transitions have been iterated.
Definition: twacube.hh:90
unsigned current(unsigned seed=0) const
Returns the current transition according to a specific seed. The seed is traditionally the thread ide...
Definition: twacube.hh:97
void reset()
Reset the iterator on the first element.
Definition: twacube.hh:77
void next()
Iterate over the next transition.
Definition: twacube.hh:83
Class for representing a transition.
Definition: twacube.hh:43
Class for representing a thread-safe twa.
Definition: twacube.hh:122
unsigned new_state()
This method creates a new state.
acc_cond & acc()
Returns the acceptance condition associated to the automaton.
std::vector< std::string > ap() const
Returns the names of the atomic properties.
void create_transition(unsigned src, const cube &cube, const acc_cond::mark_t &mark, unsigned dst)
create a transition between state src and state dst, using cube as the labelling cube and mark as the...
unsigned get_initial() const
Returns the id of the initial state in the automaton.
bool succ_contiguous() const
Check if all the successors of a state are located contiguously in memory. This is mandatory for swar...
const graph_t::edge_storage_t & trans_storage(std::shared_ptr< trans_index > ci, unsigned seed=0) const
Returns the storage associated to a transition.
Definition: twacube.hh:184
const cubeset & get_cubeset() const
Accessor the cube's manipulator.
const transition & trans_data(std::shared_ptr< trans_index > ci, unsigned seed=0) const
Returns the data associated to a transition.
Definition: twacube.hh:191
cstate * state_from_int(unsigned i)
Accessor for a state from its id.
const graph_t & get_graph()
Returns the underlying graph for this automaton.
Definition: twacube.hh:176
twacube(const std::vector< std::string > aps)
Build a new automaton from a list of atomic propositions.
void set_initial(unsigned init)
Updates the initial state to init.
Definition: automata.hh:26
unsigned * cube
A cube is only a set of bits in memory.
Definition: cube.hh:65
An acceptance mark.
Definition: acc.hh:84