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>
70 public std::enable_shared_from_this<trans_index>
81 st_(g.state_storage(
state))
109 return !idx_ || idx_ > st_.succ_tail;
114 inline unsigned current(
unsigned seed = 0)
const
118 if (SPOT_UNLIKELY(!seed))
125 SPOT_ASSERT(primes[seed] > (st_.succ_tail-st_.succ+1));
126 unsigned long long c = (idx_-st_.succ) + 1;
127 unsigned long long p = primes[seed];
128 unsigned long long s = (st_.succ_tail-st_.succ+1);
129 return (
unsigned) (((c*p) % s)+st_.succ);
134 const graph_t::state_storage_t& st_;
139 class SPOT_API
twacube final:
public std::enable_shared_from_this<twacube>
155 std::vector<std::string>
ap()
const;
186 return theg_.num_states();
192 return theg_.num_edges();
209 unsigned seed = 0)
const
211 return theg_.edge_storage(ci->current(seed));
216 unsigned seed = 0)
const
218 return theg_.edge_data(ci->current(seed));
222 std::shared_ptr<trans_index>
succ(
unsigned i)
const
224 return std::make_shared<trans_index>(i, theg_);
233 const std::vector<std::string> aps_;
242 return std::make_shared<twacube>(aps);
An acceptance condition.
Definition acc.hh:54
Class for thread-safe states.
Definition twacube.hh:41
cstate(cstate &&s) noexcept
Move a state.
Manager for allocating and manipulating cubes (bit-encoded partial assignments over APs).
Definition cube.hh:72
A directed graph.
Definition graph.hh:605
internal::edge_storage< state, state, edge, internal::boxed_label< transition > > edge_storage_t
Edge storage type.
Definition graph.hh:632
Abstract class for states.
Definition twa.hh:49
Class for iterators over transitions.
Definition twacube.hh:71
graph_t::edge_storage_t edge_storage_t
Edge storage type.
Definition twacube.hh:76
bool done() const
Returns a boolean indicating whether all the transitions have been iterated.
Definition twacube.hh:107
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:114
trans_index(trans_index &&ci)
Move an iterator.
Definition twacube.hh:87
void reset()
Reset the iterator on the first element.
Definition twacube.hh:94
void next()
Iterate over the next transition.
Definition twacube.hh:100
trans_index(unsigned state, const graph_t &g)
Build an iterator for state state.
Definition twacube.hh:80
digraph< cstate, transition > graph_t
Underlying graph type.
Definition twacube.hh:74
Class for representing a transition.
Definition twacube.hh:53
acc_cond::mark_t acc_
Acceptance mark.
Definition twacube.hh:64
cube cube_
Transition cube.
Definition twacube.hh:63
transition(const cube &cube, acc_cond::mark_t acc)
Build a transition from a cube and an acceptance mark.
transition(transition &&t) noexcept
Move a transition.
A Transition-based ω-Automaton.
Definition twa.hh:648
Class for representing a thread-safe twa.
Definition twacube.hh:140
unsigned num_edges() const
Return the number of edges.
Definition twacube.hh:190
graph_t::edge_storage_t edge_storage_t
Edge storage type.
Definition twacube.hh:204
unsigned new_state()
This method creates a new state.
std::shared_ptr< trans_index > succ(unsigned i) const
Returns the successor of state i.
Definition twacube.hh:222
acc_cond & acc()
Returns the acceptance condition associated to the automaton.
std::vector< std::string > ap() const
Returns the names of the atomic propositions.
~twacube()
Destroy the automaton.
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:208
const cubeset & get_cubeset() const
Accessor for the cube's manipulator.
friend std::ostream & operator<<(std::ostream &os, const twacube &twa)
Stream a twacube.
const transition & trans_data(std::shared_ptr< trans_index > ci, unsigned seed=0) const
Returns the data associated to a transition.
Definition twacube.hh:215
cstate * state_from_int(unsigned i)
Accessor for a state from its id.
digraph< cstate, transition > graph_t
Underlying graph type.
Definition twacube.hh:196
unsigned num_states() const
Return the number of states.
Definition twacube.hh:184
const graph_t & get_graph()
Returns the underlying graph for this automaton.
Definition twacube.hh:199
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.
std::shared_ptr< twacube > twacube_ptr
Definition fwd.hh:28
unsigned * cube
A cube is only a set of bits in memory.
Definition cube.hh:66
twacube_ptr make_twacube(const std::vector< std::string > aps)
Build a shared twacube automaton.
Definition twacube.hh:240
Definition automata.hh:26
An acceptance mark.
Definition acc.hh:76