I have $n$ numbers and ordered sets $s_i$ of some of these numbers, I need to calculate the number of all the possible permutations of the $n$ numbers respecting the orders in the sets $s_i$. I found a way to calculate the number of possible permutations when the sets $s_i$ are disjoint, but not when they are not disjoint. We suppose that the orders of the sets $s_i$ are compatible.
For example: $n=5$
$s_1 = (1, 2, 3)$
$s_2 = (5, 2)$
In this example, what is the total number of the possible permutations of the numbers from 1 to 5 respecting the orders in $s_1$ and $s_2$.
I would appreciate any suggestions for the general case.
Note that we can assume the sets $\{S_j\}_j$ exhaust $[n]$; if not, we just add the remaining numbers in as singletons. This gives a partial order $P$ on $[n]$; $x\leq_P y$ iff $(\exists j)(x\text{ appears before }y\text{ in }S_j)$. Conversely, any partial order can be given in your form; take $\{S_{x,y}\}_{x,y\in[n]}$ where $S_{x,y}=\begin{cases} (x,y) & x\leq_P y \\ x & \text{otherwise} \end{cases}$.
A permutation preserving the $\{S_j\}_j$ is a linear extension of $P$; as Wiki points out, counting linear extensions is
#P-complete, and so intractable to compute in general. OTOH, Wiki says it can be approximated quite well via a randomized algorithm, citing Bubley & Dyer, "Faster random generation of linear extensions" (Discrete Mathematics 201: 1999).