LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
dtmc_isfeasible.m
1%{ @file dtmc_isfeasible.m
2 % @brief Checks feasibility of a stochastic matrix
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Checks feasibility of a stochastic matrix
9 %
10 % @details
11 % Verifies if row sums are close to 1 and elements are non-negative.
12 %
13 % @par Syntax:
14 % @code
15 % res = dtmc_isfeasible(P)
16 % @endcode
17 %
18 % @par Parameters:
19 % <table>
20 % <tr><th>Name<th>Description
21 % <tr><td>P<td>Matrix to check
22 % </table>
23 %
24 % @par Returns:
25 % <table>
26 % <tr><th>Name<th>Description
27 % <tr><td>res<td>Precision level (1-15) if feasible, or 0 if not feasible
28 % </table>
29%}
30function res=dtmc_isfeasible(P)
31sP = sum(P,2);
32res = 0;
33for tol=1:15
34 if min(sP) > 1-10^-tol && max(sP) < 1+10^-tol && min(P(:)) > -10^-tol
35 res = tol;
36 end
37end
38
39end