butools.queues.FluidQueue¶
-
butools.queues.
FluidQueue
()¶ Matlab: Ret = FluidQueue(Q, Rin, Rout, ...)
Mathematica: Ret = FluidQueue[Q, Rin, Rout, ...]
Python/Numpy: Ret = FluidQueue(Q, Rin, Rout, ...)
Returns various performane measures of a fluid queue.
In a fluid queue there is a background continuous time Markov chain (given by generator Q), and diagonal matrix Rin (Rout) whose ith entry provides the fluid rate at which fluid enters the queue (can be served) while the background process is in state i.
Parameters: Q : matrix, shape (N,N)
The generator of the background Markov chain
Rin : matrix, shape (N,N)
Diagonal matrix containing the fluid input rates associated to the states of the background process
Rout : matrix, shape (N,N)
Diagonal matrix containing the fluid output rates associated to the states of the background process
further parameters :
The rest of the function parameters specify the options and the performance measures to be computed.
The supported performance measures and options in this function are:
Parameter name Input parameters Output “flMoms” Number of moments The moments of the fluid level “flDistr” A vector of points The fluid level distribution at the requested points (cdf) “flDistrME” None The vector-matrix parameters of the matrix-exponentially distributed fluid level distribution “flDistrPH” None The vector-matrix parameters of the matrix-exponentially distributed fluid level distribution, converted to a PH representation “stMoms” Number of moments The sojourn time moments of fluid drops “stDistr” A vector of points The sojourn time distribution at the requested points (cummulative, cdf) “stDistrME” None The vector-matrix parameters of the matrix-exponentially distributed sojourn time distribution “stDistrPH” None The vector-matrix parameters of the matrix-exponentially distributed sojourn time distribution, converted to a PH representation “prec” The precision Numerical precision to check if the input is valid and it is also used as a stopping condition when solving the Riccati equation “Q0” Matrix, shape(N,N) The generator of the background Markov chain when the fluid level is zero. If not given, Q0=Q is assumed Returns: Ret : list of the performance measures
Each entry of the list corresponds to a performance measure requested. If there is just a single item, then it is not put into a list.
Notes
“flDistrME” and “stDistrME” behave much better numerically than “flDistrPH” and “stDistrPH”.
Examples
For Matlab:
>>> Q = [-9., 2., 4., 0., 1., 2.; 6., -25., 5., 3., 7., 4.; 1., 3., -4., 0., 0., 0.; 0., 0., 0., -8., 3., 5.; 7., 3., 0., 2., -13., 1.; 7., 8., 0., 3., 8., -26.]; >>> vRin = [4.,2.,1.,0.,0.,3.]; >>> vRout = [6.,2.,0.,0.,3.,2.]; >>> Rin = diag(vRin); >>> Rout = diag(vRout); >>> [fld, flm] = FluidQueue(Q, Rin, Rout, 'flDistr', (0.:0.1:1.), 'flMoms', 5); Final Residual Error for Psi: 5.3291e-15 >>> disp(fld); Columns 1 through 8 0.23662 0.39265 0.49537 0.57807 0.6469 0.70447 0.75265 0.79297 Columns 9 through 11 0.82672 0.85497 0.87861 >>> disp(flm); 0.40636 0.4546 0.76609 1.722 4.8384 >>> [alphap, Ap] = FluidQueue(Q, Rin, Rout, 'flDistrPH'); Final Residual Error for Psi: 5.3291e-15 >>> disp(alphap); 0.63124 0.13213 >>> disp(Ap); -2.0387 0.41483 12.1 -21.143 >>> [alpha, A] = FluidQueue(Q, Rin, Rout, 'flDistrME'); Final Residual Error for Psi: 5.3291e-15 >>> disp(alpha); 0.099033 0.66434 >>> disp(A); -3.8739 2.2653 16.206 -19.308 >>> fldFromPH = CdfFromPH(alphap, Ap, (0.:0.1:1.)); >>> disp(fldFromPH); Columns 1 through 8 0.23662 0.39265 0.49537 0.57807 0.6469 0.70447 0.75265 0.79297 Columns 9 through 11 0.82672 0.85497 0.87861 >>> flmFromME = MomentsFromME(alpha, A, 5); >>> disp(flmFromME); 0.40636 0.4546 0.76609 1.722 4.8384 >>> [std, stm] = FluidQueue(Q, Rin, Rout, 'stDistr', (0.:0.1:1.), 'stMoms', 5); Final Residual Error for Psi: 5.3291e-15 >>> disp(std); Columns 1 through 8 0.31678 0.57513 0.67546 0.74313 0.7949 0.83595 0.8688 0.89511 Columns 9 through 11 0.91618 0.93304 0.94652 >>> disp(stm); 0.23252 0.20069 0.26684 0.47402 1.0523 >>> [betap, Bp] = FluidQueue(Q, Rin, Rout, 'stDistrPH'); Final Residual Error for Psi: 5.3291e-15 >>> disp(betap); Columns 1 through 8 0.24893 0.030403 0.068594 0.023408 0.21436 0 0 0 Columns 9 through 12 0 0 0 0.097532 >>> disp(Bp); Columns 1 through 8 -21.232 2.489 2 0 4 0 0 0 72.6 -135.86 0 2 0 4 0 0 6 0 -29.077 0.82967 5 0 3 0 0 6 24.2 -67.286 0 5 0 3 1 0 3 0 -4 0 0 0 0 1 0 3 0 -4 0 0 0 0 0 0 0 0 -8 0 0 0 0 0 0 0 0 -8 7 0 3 0 0 0 2 0 0 7 0 3 0 0 0 2 7 0 8 0 0 0 3 0 0 7 0 8 0 0 0 3 Columns 9 through 12 1 0 2 0 0 1 0 2 7 0 4 0 0 7 0 4 0 0 0 0 0 0 0 0 3 0 5 0 0 3 0 5 -19.116 1.2445 1 0 36.3 -76.429 0 1 8 0 -30.077 0.82967 0 8 24.2 -68.286 >>> [beta, B] = FluidQueue(Q, Rin, Rout, 'stDistrME'); Final Residual Error for Psi: 5.3291e-15 >>> disp(beta); Columns 1 through 8 6.1487e-17 0 0.078831 -0.087519 0.095339 1.1102e-16 0 -0.10977 Columns 9 through 12 0.10977 -0.10977 0.10977 0.59657 >>> disp(B); Columns 1 through 8 -22.232 -9.0243 12.676 -16.419 -10.249 30.265 0 0 -7.8856 -14 12.876 -9.097 -5.6783 16.769 0 0 -7.2098 15.443 -18.077 -16.653 4.8244 14.325 -4.9559 5.1109 -6.4942 13.91 45.225 -88.757 8.1259 15.247 -9.3289 9.6206 -5.1787 9.9439 41.788 -50.497 -22.618 13.996 -8.5637 3.0746 1.1565 9.2439 33.466 -40.969 105.27 -123.85 -13.15 9.2801 1.1143 8.9065 32.244 -39.473 97.844 -111.62 -21.67 14.098 1.0805 5.2804 29.45 -31.898 93.14 -109.17 47.142 -53.616 1.0805 3.4399 31.604 -34.29 95.746 -109.17 47.142 -45.616 1.0805 3.4399 29.45 -31.898 95.746 -109.17 44.233 -42.616 1.4204 -0.85454 34.477 -38.276 102.69 -109.17 44.233 -45.616 1.4204 -0.85454 28.732 -31.898 101.83 -108.24 37.445 -38.616 Columns 9 through 12 0 -20.594 20.594 0 0 -11.41 11.41 0 0 -13.925 13.925 0 -6.2713 -6.2713 11.288 1.2543 0 -6.9083 11.514 1.1514 0 -6.422 3.211 8.5627 0 -6.1876 3.0938 8.2501 0 -6 0 11 -8 -8 2 11 0 -16 0 13 3 3.1162 -24.622 18.505 0 -2.0893 60.013 -57.924 >>> stdFromPH = CdfFromPH(betap, Bp, (0.:0.1:1.)); >>> disp(stdFromPH); Columns 1 through 8 0.31678 0.57513 0.67546 0.74313 0.7949 0.83595 0.8688 0.89511 Columns 9 through 11 0.91618 0.93304 0.94652 >>> stmFromME = MomentsFromME(beta, B, 5); >>> disp(stmFromME); 0.23252 0.20069 0.26684 0.47402 1.0523
For Mathematica:
>>> Q = {{-9., 2., 4., 0., 1., 2.},{6., -25., 5., 3., 7., 4.},{1., 3., -4., 0., 0., 0.},{0., 0., 0., -8., 3., 5.},{7., 3., 0., 2., -13., 1.},{7., 8., 0., 3., 8., -26.}}; >>> vRin = {4.,2.,1.,0.,0.,3.}; >>> vRout = {6.,2.,0.,0.,3.,2.}; >>> Rin = DiagonalMatrix[vRin]; >>> Rout = DiagonalMatrix[vRout]; >>> {fld, flm} = FluidQueue[Q, Rin, Rout, "flDistr", Range[0.,1.,0.1], "flMoms", 5]; "Final Residual Error for Psi: "3.552713678800501*^-15 >>> Print[fld]; {0.23662288834725298, 0.39264885436465424, 0.4953720074760106, 0.5780715681563571, 0.6469041669036231, 0.7044705767536769, 0.7526473904478992, 0.7929699724085515, 0.8267192438851823, 0.8549668265296148, 0.8786095927626414} >>> Print[flm]; {0.40636152724912705, 0.45459875335830063, 0.7660938906391563, 1.7219814531396151, 4.8383553122056435} >>> {alphap, Ap} = FluidQueue[Q, Rin, Rout, "flDistrPH"]; "Final Residual Error for Psi: "3.552713678800501*^-15 >>> Print[alphap]; {0.6312437949552183, 0.1321333166975293} >>> Print[Ap]; {{-2.038729227705291, 0.41483299932786355}, {12.100016650885564, -21.143102743484828}} >>> {alpha, A} = FluidQueue[Q, Rin, Rout, "flDistrME"]; "Final Residual Error for Psi: "3.552713678800501*^-15 >>> Print[alpha]; {0.09903292185295065, 0.6643441897997966} >>> Print[A]; {{-3.873888074242129, 2.265266300893395}, {16.206146825973583, -19.30794389694799}} >>> fldFromPH = CdfFromPH[alphap, Ap, Range[0.,1.,0.1]]; >>> Print[fldFromPH]; {0.2366228883472523, 0.3926488543646537, 0.49537200747600996, 0.5780715681563567, 0.6469041669036226, 0.7044705767536761, 0.752647390447899, 0.7929699724085515, 0.826719243885182, 0.8549668265296144, 0.8786095927626408} >>> flmFromME = MomentsFromME[alpha, A, 5]; >>> Print[flmFromME]; {0.406361527249127, 0.4545987533583005, 0.766093890639156, 1.7219814531396143, 4.838355312205641} >>> {std, stm} = FluidQueue[Q, Rin, Rout, "stDistr", Range[0.,1.,0.1], "stMoms", 5]; "Final Residual Error for Psi: "3.552713678800501*^-15 >>> Print[std]; {0.31678183878167165, 0.5751281366978114, 0.6754587240241274, 0.7431259359792002, 0.7948956352818286, 0.8359503921804168, 0.8687966127678342, 0.895110856527426, 0.9161817691938701, 0.9330411640536861, 0.9465218585049266} >>> Print[stm]; {0.2325226067816825, 0.20068950224745224, 0.26683979953080217, 0.47402477308795066, 1.052265707013926} >>> {betap, Bp} = FluidQueue[Q, Rin, Rout, "stDistrPH"]; "Final Residual Error for Psi: "3.552713678800501*^-15 >>> Print[betap]; {0.2489256585531655, 0.030403121047365863, 0.06859400291252453, 0.02340757153618713, 0.21435625910163925, 0., 0., 0., 0., 0., 0., 0.0975315480674464} >>> Print[Bp]; {{-21.23237536623175, 2.4889979959671824, 2., 0., 4., 0., 0., 0., 1., 0., 2., 0.}, {72.60009990531339, -135.85861646090896, 0., 2., 0., 4., 0., 0., 0., 1., 0., 2.}, {6., 0., -29.077458455410582, 0.8296659986557274, 5., 0., 3., 0., 7., 0., 4., 0.}, {0., 6., 24.20003330177113, -67.28620548696966, 0., 5., 0., 3., 0., 7., 0., 4.}, {1., 0., 3., 0., -4., 0., 0., 0., 0., 0., 0., 0.}, {0., 1., 0., 3., 0., -4., 0., 0., 0., 0., 0., 0.}, {0., 0., 0., 0., 0., 0., -8., 0., 3., 0., 5., 0.}, {0., 0., 0., 0., 0., 0., 0., -8., 0., 3., 0., 5.}, {7., 0., 3., 0., 0., 0., 2., 0., -19.116187683115875, 1.2444989979835912, 1., 0.}, {0., 7., 0., 3., 0., 0., 0., 2., 36.30004995265669, -76.42930823045448, 0., 1.}, {7., 0., 8., 0., 0., 0., 3., 0., 8., 0., -30.077458455410582, 0.8296659986557274}, {0., 7., 0., 8., 0., 0., 0., 3., 0., 8., 24.20003330177113, -68.28620548696966}} >>> {beta, B} = FluidQueue[Q, Rin, Rout, "stDistrME"]; "Final Residual Error for Psi: "3.552713678800501*^-15 >>> Print[beta]; {3.264004570026444*^-17, 0., 0.078831427608686, -0.08751888856574991, 0.09533889262153328, -1.1102230246251565*^-16, 0., -0.10977187523000154, 0.10977187523000154, -0.10977187523000154, 0.10977187523000154, 0.5965667295538591} >>> Print[B]; {{-22.232375366231746, -9.024334461376778, 12.676341281041134, -16.41886435303353, -10.248515585018609, 30.264973851239237, 0., 0., 0., -20.593606234218658, 20.593606234218658, 0.}, {-7.885554013509164, -14., 12.876273100640667, -9.096994589077221, -5.678266707024877, 16.76853510958077, 0., 0., 0., -11.410041550630227, 11.410041550630227, 0.}, {-7.209828938108562, 15.44329181707263, -18.07745845541058, -16.653045216976402, 4.824361648380197, 14.325098944679178, -4.955917721818842, 5.110876056418869, 0., -13.924887390711975, 13.924887390711975, 0.}, {-6.494153631516062, 13.910331368099698, 45.22483399646519, -88.75656159121243, 8.12591699549531, 15.246825395741896, -9.328920246280369, 9.620610711320927, -6.271324797933972, -6.27132479793397, 11.288384636281148, 1.2542649595867943}, {-5.17874381712221, 9.94388397950392, 41.78794639107936, -50.49678710251786, -22.61805543038884, 13.996231507413134, -8.56373206173128, 3.0745666597174584, 0., -6.90831656703395, 11.513860945056583, 1.1513860945056584}, {1.156466847093981, 9.243874525368991, 33.46570969180691, -40.968532043409766, 105.26888080212088, -123.84766338168792, -13.15028655062144, 9.280128382401386, 0., -6.42199885465433, 3.210999427327165, 8.562665139539106}, {1.1142572671540418, 8.906484775101795, 32.24425353676651, -39.473232344457195, 97.84400096052254, -111.61936991988053, -21.670317693073674, 14.097752082035752, 0., -6.187604003897572, 3.093802001948786, 8.250138671863432}, {1.0804737340516644, 5.280411661151828, 29.449994310245835, -31.898192751799968, 93.14039968197055, -109.16943402785212, 47.141886678532906, -53.61588779389599, 0., -6., 0., 11.}, {1.0804737340516646, 3.4399275659085404, 31.604410296403845, -34.29003187404438, 95.74595485960887, -109.16943402785212, 47.141886678532906, -45.61588779389599, -8., -8.000000000000002, 2.0000000000000018, 11.}, {1.080473734051665, 3.4399275659085404, 29.449994310245838, -31.898192751799975, 95.74595485960887, -109.16943402785212, 44.23284466668765, -42.61588779389599, 0., -16., 0., 13.000000000000002}, {1.4203850599450722, -0.854535322992466, 34.47696494461453, -38.276430411118405, 102.69410199997778, -109.16943402785212, 44.23284466668765, -45.61588779389599, 3., 3.116187683115877, -24.621664222726388, 18.505476539610513}, {1.4203850599450727, -0.854535322992466, 28.731855648193164, -31.89819275179997, 101.82558360743165, -108.23514547754328, 37.44507997238203, -38.61588779389599, 0., -2.089346473248271, 60.01317816409224, -57.92383169084397}} >>> stdFromPH = CdfFromPH[betap, Bp, Range[0.,1.,0.1]]; >>> Print[stdFromPH]; {0.31678183878167143, 0.5751281366978112, 0.6754587240241272, 0.7431259359792002, 0.7948956352818284, 0.8359503921804168, 0.8687966127678343, 0.8951108565274261, 0.9161817691938701, 0.9330411640536861, 0.9465218585049268} >>> stmFromME = MomentsFromME[beta, B, 5]; >>> Print[stmFromME]; {0.23252260678168227, 0.2006895022474516, 0.26683979953080084, 0.47402477308794727, 1.0522657070139159}
For Python/Numpy:
>>> Q = ml.matrix([[-9., 2., 4., 0., 1., 2.],[6., -25., 5., 3., 7., 4.],[1., 3., -4., 0., 0., 0.],[0., 0., 0., -8., 3., 5.],[7., 3., 0., 2., -13., 1.],[7., 8., 0., 3., 8., -26.]]) >>> vRin = ml.matrix([[4.,2.,1.,0.,0.,3.]]) >>> vRout = ml.matrix([[6.,2.,0.,0.,3.,2.]]) >>> Rin = Diag(vRin) >>> Rout = Diag(vRout) >>> fld, flm = FluidQueue(Q, Rin, Rout, "flDistr", np.arange(0.,1.1,0.1), "flMoms", 5) Final Residual Error for G: 6.661338147750939e-15 >>> print(fld) [ 0.23662 0.39265 0.49537 0.57807 0.6469 0.70447 0.75265 0.79297 0.82672 0.85497 0.87861] >>> print(flm) [0.406361527249128, 0.45459875335830258, 0.76609389063916067, 1.7219814531396287, 4.8383553122056897] >>> alphap, Ap = FluidQueue(Q, Rin, Rout, "flDistrPH") Final Residual Error for G: 6.661338147750939e-15 >>> print(alphap) [[ 0.63124 0.13213]] >>> print(Ap) [[ -2.03873 0.41483] [ 12.10002 -21.1431 ]] >>> alpha, A = FluidQueue(Q, Rin, Rout, "flDistrME") Final Residual Error for G: 6.661338147750939e-15 >>> print(alpha) [[ 0.09903 0.66434]] >>> print(A) [[ -3.87389 2.26527] [ 16.20615 -19.30794]] >>> fldFromPH = CdfFromPH(alphap, Ap, np.arange(0.,1.1,0.1)) >>> print(fldFromPH) [ 0.23662 0.39265 0.49537 0.57807 0.6469 0.70447 0.75265 0.79297 0.82672 0.85497 0.87861] >>> flmFromME = MomentsFromME(alpha, A, 5) >>> print(flmFromME) [0.40636152724912805, 0.45459875335830258, 0.76609389063916078, 1.7219814531396285, 4.8383553122056906] >>> std, stm = FluidQueue(Q, Rin, Rout, "stDistr", np.arange(0.,1.1,0.1), "stMoms", 5) Final Residual Error for G: 6.661338147750939e-15 >>> print(std) [ 0.31678 0.57513 0.67546 0.74313 0.7949 0.83595 0.8688 0.89511 0.91618 0.93304 0.94652] >>> print(stm) [0.23252260678168307, 0.20068950224745297, 0.26683979953080317, 0.47402477308795288, 1.0522657070139314] >>> betap, Bp = FluidQueue(Q, Rin, Rout, "stDistrPH") Final Residual Error for G: 6.661338147750939e-15 >>> print(betap) [[ 0.24893 0.0304 0.06859 0.02341 0.21436 0. 0. 0. 0. 0. 0. 0.09753]] >>> print(Bp) [[ -21.23238 2.489 2. 0. 4. 0. 0. 0. 1. 0. 2. 0. ] [ 72.6001 -135.85862 0. 2. 0. 4. 0. 0. 0. 1. 0. 2. ] [ 6. 0. -29.07746 0.82967 5. 0. 3. 0. 7. 0. 4. 0. ] [ 0. 6. 24.20003 -67.28621 0. 5. 0. 3. 0. 7. 0. 4. ] [ 1. 0. 3. 0. -4. 0. 0. 0. 0. 0. 0. 0. ] [ 0. 1. 0. 3. 0. -4. 0. 0. 0. 0. 0. 0. ] [ 0. 0. 0. 0. 0. 0. -8. 0. 3. 0. 5. 0. ] [ 0. 0. 0. 0. 0. 0. 0. -8. 0. 3. 0. 5. ] [ 7. 0. 3. 0. 0. 0. 2. 0. -19.11619 1.2445 1. 0. ] [ 0. 7. 0. 3. 0. 0. 0. 2. 36.30005 -76.42931 0. 1. ] [ 7. 0. 8. 0. 0. 0. 3. 0. 8. 0. -30.07746 0.82967] [ 0. 7. 0. 8. 0. 0. 0. 3. 0. 8. 24.20003 -68.28621]] >>> beta, B = FluidQueue(Q, Rin, Rout, "stDistrME") Final Residual Error for G: 6.661338147750939e-15 >>> print(beta) [[ 0. 0. 0.07883 -0.08752 0.09534 0. 0. -0.10977 0.10977 -0.10977 0.10977 0.59657]] >>> print(B) [[ -22.23238 -9.02433 12.67634 -16.41886 -10.24852 30.26497 0. 0. 0. -20.59361 20.59361 0. ] [ -7.88555 -14. 12.87627 -9.09699 -5.67827 16.76854 0. 0. 0. -11.41004 11.41004 0. ] [ -7.20983 15.44329 -18.07746 -16.65305 4.82436 14.3251 -4.95592 5.11088 0. -13.92489 13.92489 0. ] [ -6.49415 13.91033 45.22483 -88.75656 8.12592 15.24683 -9.32892 9.62061 -6.27132 -6.27132 11.28838 1.25426] [ -5.17874 9.94388 41.78795 -50.49679 -22.61806 13.99623 -8.56373 3.07457 0. -6.90832 11.51386 1.15139] [ 1.15647 9.24387 33.46571 -40.96853 105.26888 -123.84766 -13.15029 9.28013 0. -6.422 3.211 8.56267] [ 1.11426 8.90648 32.24425 -39.47323 97.844 -111.61937 -21.67032 14.09775 0. -6.1876 3.0938 8.25014] [ 1.08047 5.28041 29.44999 -31.89819 93.1404 -109.16943 47.14189 -53.61589 0. -6. 0. 11. ] [ 1.08047 3.43993 31.60441 -34.29003 95.74595 -109.16943 47.14189 -45.61589 -8. -8. 2. 11. ] [ 1.08047 3.43993 29.44999 -31.89819 95.74595 -109.16943 44.23284 -42.61589 0. -16. 0. 13. ] [ 1.42039 -0.85454 34.47696 -38.27643 102.6941 -109.16943 44.23284 -45.61589 3. 3.11619 -24.62166 18.50548] [ 1.42039 -0.85454 28.73186 -31.89819 101.82558 -108.23515 37.44508 -38.61589 0. -2.08935 60.01318 -57.92383]] >>> stdFromPH = CdfFromPH(betap, Bp, np.arange(0.,1.1,0.1)) >>> print(stdFromPH) [ 0.31678 0.57513 0.67546 0.74313 0.7949 0.83595 0.8688 0.89511 0.91618 0.93304 0.94652] >>> stmFromME = MomentsFromME(beta, B, 5) >>> print(stmFromME) [0.23252260678168368, 0.20068950224745336, 0.2668397995308035, 0.47402477308795293, 1.0522657070139294]