From: <mma...@us...> - 2012-03-12 21:35:23
|
Revision: 9836 http://octave.svn.sourceforge.net/octave/?rev=9836&view=rev Author: mmarzolla Date: 2012-03-12 21:35:17 +0000 (Mon, 12 Mar 2012) Log Message: ----------- added new test cases Modified Paths: -------------- trunk/octave-forge/main/queueing/inst/ctmc_check_Q.m trunk/octave-forge/main/queueing/inst/dtmc_check_P.m Modified: trunk/octave-forge/main/queueing/inst/ctmc_check_Q.m =================================================================== --- trunk/octave-forge/main/queueing/inst/ctmc_check_Q.m 2012-03-12 19:37:46 UTC (rev 9835) +++ trunk/octave-forge/main/queueing/inst/ctmc_check_Q.m 2012-03-12 21:35:17 UTC (rev 9836) @@ -46,7 +46,8 @@ return; endif - if ( norm( sum(Q,2), "inf" ) > epsilon ) + if (any(Q(~logical(eye(size(Q))))<0) || \ # there is any negavite non-diagonal element + norm( sum(Q,2), "inf" ) > epsilon ) err = "Q is not an infinitesimal generator matrix"; return; endif @@ -54,3 +55,37 @@ result = rows(Q); err = ""; endfunction +%!test +%! Q = [0]; +%! [result err] = ctmc_check_Q(Q); +%! assert( result, 1 ); +%! assert( err, "" ); + +%!test +%! N = 10; +%! Q = ctmc_bd(rand(1,N-1),rand(1,N-1)); +%! [result err] = ctmc_check_Q(Q); +%! assert( result, N ); +%! assert( err, "" ); + +%!test +%! Q = [1 2 3; 4 5 6]; +%! [result err] = ctmc_check_Q(Q); +%! assert( result, 0 ); +%! assert( index(err, "square") > 0 ); + +%!test +%! N = 10; +%! Q = ctmc_bd(rand(1,N-1),rand(1,N-1)); +%! Q(2,1) = -1; +%! [result err] = ctmc_check_Q(Q); +%! assert( result, 0 ); +%! assert( index(err, "infinitesimal") > 0 ); + +%!test +%! N = 10; +%! Q = ctmc_bd(rand(1,N-1),rand(1,N-1)); +%! Q(1,1) += 7; +%! [result err] = ctmc_check_Q(Q); +%! assert( result, 0 ); +%! assert( index(err, "infinitesimal") > 0 ); Modified: trunk/octave-forge/main/queueing/inst/dtmc_check_P.m =================================================================== --- trunk/octave-forge/main/queueing/inst/dtmc_check_P.m 2012-03-12 19:37:46 UTC (rev 9835) +++ trunk/octave-forge/main/queueing/inst/dtmc_check_P.m 2012-03-12 21:35:17 UTC (rev 9836) @@ -66,4 +66,8 @@ %!test %! P = [0 1; 1 0]; -%! assert( dtmc_check_P(P), 2 ); \ No newline at end of file +%! assert( dtmc_check_P(P), 2 ); + +%!test +%! P = dtmc_bd( linspace(0.1,0.4,10), linspace(0.4,0.1,10) ); +%! assert( dtmc_check_P(P), rows(P) ); \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mma...@us...> - 2012-03-16 14:08:51
|
Revision: 9919 http://octave.svn.sourceforge.net/octave/?rev=9919&view=rev Author: mmarzolla Date: 2012-03-16 14:08:44 +0000 (Fri, 16 Mar 2012) Log Message: ----------- bug fixes Modified Paths: -------------- trunk/octave-forge/main/queueing/inst/dtmc.m trunk/octave-forge/main/queueing/inst/dtmc_check_P.m trunk/octave-forge/main/queueing/inst/dtmc_fpt.m trunk/octave-forge/main/queueing/inst/dtmc_is_irreducible.m trunk/octave-forge/main/queueing/inst/dtmc_mtta.m Modified: trunk/octave-forge/main/queueing/inst/dtmc.m =================================================================== --- trunk/octave-forge/main/queueing/inst/dtmc.m 2012-03-16 11:24:04 UTC (rev 9918) +++ trunk/octave-forge/main/queueing/inst/dtmc.m 2012-03-16 14:08:44 UTC (rev 9919) @@ -24,14 +24,16 @@ ## @cindex Discrete time Markov chain ## @cindex Markov chain, stationary probabilities ## @cindex Stationary probabilities +## @cindex Markov chain, transient probabilities +## @cindex Transient probabilities ## -## With a single argument, compute the steady-state probability vector -## @code{@var{p}(1), @dots{}, @var{p}(N)} for a -## Discrete-Time Markov Chain given the @math{N \times N} transition -## probability matrix @var{P}. With three arguments, compute the -## probability vector @code{@var{p}(1), @dots{}, @var{p}(N)} -## after @var{n} steps, given initial probability vector @var{p0} at -## time 0. +## Compute steady-state or transient state occupancy probabilities for a +## Discrete-Time Markov Chain. With a single argument, compute the +## steady-state occupancy probability vector @code{@var{p}(1), @dots{}, +## @var{p}(N)} given the @math{N \times N} transition probability matrix +## @var{P}. With three arguments, compute the state occupancy +## probabilities @code{@var{p}(1), @dots{}, @var{p}(N)} after @var{n} +## steps, given initial occupancy probability vector @var{p0}. ## ## @strong{INPUTS} ## @@ -145,6 +147,15 @@ %! p = dtmc(P, 100, [1 0]); %! assert( plim, p, 1e-5 ); +%!test +%! P = [0 1 0 0 0; \ +%! .25 0 .75 0 0; \ +%! 0 .5 0 .5 0; \ +%! 0 0 .75 0 .25; \ +%! 0 0 0 1 0 ]; +%! p = dtmc(P); +%! assert( p, [.0625 .25 .375 .25 .0625], 10*eps ); + %!demo %! a = 0.2; %! b = 0.15; Modified: trunk/octave-forge/main/queueing/inst/dtmc_check_P.m =================================================================== --- trunk/octave-forge/main/queueing/inst/dtmc_check_P.m 2012-03-16 11:24:04 UTC (rev 9918) +++ trunk/octave-forge/main/queueing/inst/dtmc_check_P.m 2012-03-16 14:08:44 UTC (rev 9919) @@ -17,14 +17,14 @@ ## -*- texinfo -*- ## -## @deftypefn {Function File} {[@var{result} @var{err}] =} dtmc_check_P (@var{P}) +## @deftypefn {Function File} {[@var{r} @var{err}] =} dtmc_check_P (@var{P}) ## ## @cindex Markov chain, discrete time ## -## If @var{P} is a valid transition probability matrix, return -## the size (number of rows or columns) of @var{P}. If @var{P} is not -## a transition probability matrix, set @var{result} to zero, and -## @var{err} to an appropriate error string. +## Check if @var{P} is a valid transition probability matrix. If @var{P} +## is valid, @var{r} is the size (number of rows or columns) of @var{P}. +## If @var{P} is not a transition probability matrix, @var{r} is set to +## zero, and @var{err} to an appropriate error string. ## ## @end deftypefn @@ -40,19 +40,19 @@ endif result = 0; + err = ""; if ( !issquare(P) ) err = "P is not a square matrix"; return; endif - if ( any(any(P <0)) || norm( sum(P,2) - 1, "inf" ) > epsilon ) + if ( any(any(P<-epsilon)) || norm( sum(P,2) - 1, "inf" ) > epsilon ) err = "P is not a stochastic matrix"; return; endif result = rows(P); - err = ""; endfunction %!test %! [r err] = dtmc_check_P( [1 1 1; 1 1 1] ); Modified: trunk/octave-forge/main/queueing/inst/dtmc_fpt.m =================================================================== --- trunk/octave-forge/main/queueing/inst/dtmc_fpt.m 2012-03-16 11:24:04 UTC (rev 9918) +++ trunk/octave-forge/main/queueing/inst/dtmc_fpt.m 2012-03-16 14:08:44 UTC (rev 9919) @@ -84,6 +84,10 @@ ( N>0 ) || \ error(err); + if ( any(diag(P) == 1) ) + error("Cannot compute first passage times for absorbing chains"); + endif + if ( nargin == 1 ) M = zeros(N,N); ## M(i,j) = 1 + sum_{k \neq j} P(i,k) M(k,j) @@ -119,7 +123,14 @@ %! 0.1 0.0 0.9; \ %! 0.9 0.1 0.0 ]; %! M = dtmc_fpt(P); +%! w = dtmc(P); +%! N = rows(P); +%! W = repmat(w,N,1); +%! Z = inv(eye(N)-P+W); +%! M1 = (repmat(diag(Z)',1,N) - Z) ./ repmat(w',1,N); +%! assert(M, M1); + %!shared P %! P = [ 0.0 0.9 0.1; \ %! 0.1 0.0 0.9; \ @@ -138,10 +149,9 @@ %!test %! m = dtmc_fpt(P, 1, [2 3]); -## FIXME: check this (matrix not ergodic???) -%!xtest +%!test %! P = dtmc_bd([1 1 1], [ 0 0 0] ); -%! dtmc_fpt(P); +%! fail( "dtmc_fpt(P)", "absorbing" ); ## Example on p. 461 of ## http://www.cs.virginia.edu/~gfx/Courses/2006/DataDriven/bib/texsyn/Chapter11.pdf Modified: trunk/octave-forge/main/queueing/inst/dtmc_is_irreducible.m =================================================================== --- trunk/octave-forge/main/queueing/inst/dtmc_is_irreducible.m 2012-03-16 11:24:04 UTC (rev 9918) +++ trunk/octave-forge/main/queueing/inst/dtmc_is_irreducible.m 2012-03-16 14:08:44 UTC (rev 9919) @@ -21,10 +21,11 @@ ## ## @cindex Markov chain, discrete time ## @cindex Discrete time Markov chain +## @cindex Irreducible Markov chain ## -## Check if @var{P} is irreducible, and identify strongly connected -## components in the transition graph of the discrete-time Markov chain -## with transition probability matrix @var{P}. +## Check if @var{P} is irreducible, and identify Strongly Connected +## Components (SCC) in the transition graph of the DTMC with transition +## probability matrix @var{P}. ## ## @strong{INPUTS} ## @@ -45,10 +46,10 @@ ## 1 if @var{P} irreducible, 0 otherwise. ## ## @item s -## @code{@var{s}(i)} is the strongly connected component that state @math{i} -## belongs to. Strongly connected components are numbered as 1, 2, -## @dots{}. If the graph is strongly connected, then there is a single -## SCC and the predicate @code{all(s == 1)} evaluates to true. +## @code{@var{s}(i)} is the SCC that state @math{i} belongs to. SCCs are +## numbered as 1, 2, @dots{}. If the graph is strongly connected, then +## there is a single SCC and the predicate @code{all(s == 1)} evaluates +## to true. ## ## @end table ## @@ -59,19 +60,23 @@ function [r s] = dtmc_is_irreducible( P ) - persistent epsilon = 10*eps; - if ( nargin != 1 ) print_usage(); endif - # dtmc_check_P(P); - + [N err] = dtmc_check_P(P); + if ( N == 0 ) + error(err); + endif s = __scc(P); r = (max(s) == 1); endfunction %!test +%! P = [0 .5 0; 0 0 0]; +%! fail( "dtmc_is_irresudible(P)" ); + +%!test %! P = [0 1 0; 0 .5 .5; 0 1 0]; %! [r s] = dtmc_is_irreducible(P); %! assert( r == 0 ); Modified: trunk/octave-forge/main/queueing/inst/dtmc_mtta.m =================================================================== --- trunk/octave-forge/main/queueing/inst/dtmc_mtta.m 2012-03-16 11:24:04 UTC (rev 9918) +++ trunk/octave-forge/main/queueing/inst/dtmc_mtta.m 2012-03-16 14:08:44 UTC (rev 9919) @@ -22,6 +22,7 @@ ## ## @cindex Markov chain, disctete time ## @cindex Mean time to absorption +## @cindex Absorption probabilities ## ## Compute the expected number of steps before absorption for the ## DTMC with @math{N \times N} transition probability matrix @var{P}. @@ -53,9 +54,10 @@ ## @item B ## When called with a single argument, @var{B} is a @math{N \times N} ## matrix where @code{@var{B}(i,j)} is the probability of being absorbed -## in state @math{j}, starting from state @math{i}; if @math{j} is not -## absorbing, @code{@var{B}(i,j) = 0}; if @math{i} is absorbing, then -## @code{@var{B}(i,i) = 1}. When called with two arguments, @var{B} is a +## in state @math{j}, starting from transient state @math{i}; if +## @math{j} is not absorbing, @code{@var{B}(i,j) = 0}; if @math{i} is +## absorbing, then @code{@var{B}(i,i) = 1}. +## When called with two arguments, @var{B} is a ## vector with @math{N} elements where @code{@var{B}(j)} is the ## probability of being absorbed in state @var{j}, given initial state ## occupancy probabilities @var{p0}. @@ -82,7 +84,7 @@ if ( nargin == 2 ) ( isvector(p0) && length(p0) == K && all(p0>=0) && abs(sum(p0)-1.0)<epsilon ) || \ - usage( "p0 must be a probability vector" ); + usage( "p0 must be a state occupancy probability vector" ); endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mma...@us...> - 2012-04-13 12:20:34
|
Revision: 10212 http://octave.svn.sourceforge.net/octave/?rev=10212&view=rev Author: mmarzolla Date: 2012-04-13 12:20:21 +0000 (Fri, 13 Apr 2012) Log Message: ----------- replaced usage() with error() Modified Paths: -------------- trunk/octave-forge/main/queueing/inst/ctmc.m trunk/octave-forge/main/queueing/inst/ctmc_bd.m trunk/octave-forge/main/queueing/inst/ctmc_exps.m trunk/octave-forge/main/queueing/inst/ctmc_fpt.m trunk/octave-forge/main/queueing/inst/ctmc_mtta.m trunk/octave-forge/main/queueing/inst/ctmc_taexps.m trunk/octave-forge/main/queueing/inst/dtmc.m trunk/octave-forge/main/queueing/inst/dtmc_bd.m trunk/octave-forge/main/queueing/inst/dtmc_exps.m trunk/octave-forge/main/queueing/inst/dtmc_mtta.m trunk/octave-forge/main/queueing/inst/population_mix.m trunk/octave-forge/main/queueing/inst/qnammm.m trunk/octave-forge/main/queueing/inst/qnclosedab.m trunk/octave-forge/main/queueing/inst/qnclosedbsb.m trunk/octave-forge/main/queueing/inst/qnclosedgb.m trunk/octave-forge/main/queueing/inst/qnclosedmultimva.m trunk/octave-forge/main/queueing/inst/qnclosedmultimvaapprox.m trunk/octave-forge/main/queueing/inst/qnclosedpb.m trunk/octave-forge/main/queueing/inst/qnclosedsinglemva.m trunk/octave-forge/main/queueing/inst/qnclosedsinglemvaapprox.m trunk/octave-forge/main/queueing/inst/qnclosedsinglemvald.m trunk/octave-forge/main/queueing/inst/qncmva.m trunk/octave-forge/main/queueing/inst/qnconvolution.m trunk/octave-forge/main/queueing/inst/qnconvolutionld.m trunk/octave-forge/main/queueing/inst/qnjackson.m trunk/octave-forge/main/queueing/inst/qnmarkov.m trunk/octave-forge/main/queueing/inst/qnmg1.m trunk/octave-forge/main/queueing/inst/qnmh1.m trunk/octave-forge/main/queueing/inst/qnmix.m trunk/octave-forge/main/queueing/inst/qnmknode.m trunk/octave-forge/main/queueing/inst/qnmm1.m trunk/octave-forge/main/queueing/inst/qnmm1k.m trunk/octave-forge/main/queueing/inst/qnmminf.m trunk/octave-forge/main/queueing/inst/qnmmm.m trunk/octave-forge/main/queueing/inst/qnmmmk.m trunk/octave-forge/main/queueing/inst/qnmvablo.m trunk/octave-forge/main/queueing/inst/qnopenab.m trunk/octave-forge/main/queueing/inst/qnopenbsb.m trunk/octave-forge/main/queueing/inst/qnopenmulti.m trunk/octave-forge/main/queueing/inst/qnopensingle.m trunk/octave-forge/main/queueing/inst/qnsolve.m trunk/octave-forge/main/queueing/inst/qnvisits.m Modified: trunk/octave-forge/main/queueing/inst/ctmc.m =================================================================== --- trunk/octave-forge/main/queueing/inst/ctmc.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/ctmc.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -86,7 +86,7 @@ [N err] = ctmc_check_Q(Q); ( N>0 ) || \ - usage(err); + error(err); if ( nargin == 1 ) # steady-state analysis @@ -112,10 +112,10 @@ else # transient analysis ( isscalar(t) && t>=0 ) || \ - usage("t must be a scalar >= 0"); + error("t must be a scalar >= 0"); ( isvector(p0) && length(p0) == N && all(p0>=0) && abs(sum(p0)-1.0)<N*eps ) || \ - usage( "p0 must be a probability vector" ); + error( "p0 must be a probability vector" ); p0 = p0(:)'; # make p0 a row vector Modified: trunk/octave-forge/main/queueing/inst/ctmc_bd.m =================================================================== --- trunk/octave-forge/main/queueing/inst/ctmc_bd.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/ctmc_bd.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -74,15 +74,15 @@ endif ( isvector( birth ) && isvector( death ) ) || \ - usage( "birth and death must be vectors" ); + error( "birth and death must be vectors" ); birth = birth(:); # make birth a column vector death = death(:); # make death a column vector size_equal( birth, death ) || \ - usage( "birth and death rates must have the same length" ); + error( "birth and death rates must have the same length" ); all( birth >= 0 ) || \ - usage( "birth rates must be >= 0" ); + error( "birth rates must be >= 0" ); all( death >= 0 ) || \ - usage( "death rates must be >= 0" ); + error( "death rates must be >= 0" ); ## builds the infinitesimal generator matrix Q = diag( birth, 1 ) + diag( death, -1 ); Modified: trunk/octave-forge/main/queueing/inst/ctmc_exps.m =================================================================== --- trunk/octave-forge/main/queueing/inst/ctmc_exps.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/ctmc_exps.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -79,7 +79,7 @@ [N err] = ctmc_check_Q(Q); (N>0) || \ - usage(err); + error(err); if ( nargin == 2 ) p = varargin{1}; @@ -89,14 +89,14 @@ endif ( isvector(p) && length(p) == size(Q,1) && all(p>=0) && abs(sum(p)-1.0)<epsilon ) || \ - usage( "p must be a probability vector" ); + error( "p must be a probability vector" ); p = p(:)'; # make p a row vector if ( nargin == 3 ) # non-absorbing case if ( isscalar(t) ) (t >= 0 ) || \ - usage( "t must be >= 0" ); + error( "t must be >= 0" ); ## F(x) are the transient state occupancy probabilities at time x ## F(x) = p*expm(Q*x) (see function ctmc()). F = @(x) (p*expm(Q*x)); @@ -104,7 +104,7 @@ else ## FIXME: deprecate this? ( isvector(t) && abs(t(1)) < epsilon ) || \ - usage( "t must be a vector, and t(1) must be 0.0" ); + error( "t must be a vector, and t(1) must be 0.0" ); t = t(:)'; # make tt a row vector ff = @(x,t) (x(:)'*Q+p); fj = @(x,t) (Q); Modified: trunk/octave-forge/main/queueing/inst/ctmc_fpt.m =================================================================== --- trunk/octave-forge/main/queueing/inst/ctmc_fpt.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/ctmc_fpt.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -89,8 +89,8 @@ endfor endfor else - (isscalar(i) && i>=1 && j<=N) || usage("i must be an integer in the range 1..%d", N); - (isvector(j) && all(j>=1) && all(j<=N)) || usage("j must be an integer or vector with elements in 1..%d", N); + (isscalar(i) && i>=1 && j<=N) || error("i must be an integer in the range 1..%d", N); + (isvector(j) && all(j>=1) && all(j<=N)) || error("j must be an integer or vector with elements in 1..%d", N); j = j(:)'; # make j a row vector Q(j,:) = 0; # make state(s) j absorbing p0 = zeros(1,N); p0(i) = 1; Modified: trunk/octave-forge/main/queueing/inst/ctmc_mtta.m =================================================================== --- trunk/octave-forge/main/queueing/inst/ctmc_mtta.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/ctmc_mtta.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -71,10 +71,10 @@ [N err] = ctmc_check_Q(Q); (N>0) || \ - usage(err); + error(err); ( isvector(p) && length(p) == N && all(p>=0) && abs(sum(p)-1.0)<epsilon ) || \ - usage( "p must be a probability vector" ); + error( "p must be a probability vector" ); L = ctmc_exps(Q,p); t = sum(L); Modified: trunk/octave-forge/main/queueing/inst/ctmc_taexps.m =================================================================== --- trunk/octave-forge/main/queueing/inst/ctmc_taexps.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/ctmc_taexps.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -52,12 +52,12 @@ ## @table @var ## ## @item M -## If this function is called with three parameters, @code{@var{M}(i)} -## is the expected fraction of the interval @math{[0,t]} spent in state -## @math{i} assuming that the state occupancy probability at time zero -## is @var{p}. If this function is called with two parameters, -## @code{@var{M}(i)} is the expected fraction of time until absorption -## spent in state @math{i}. +## When called with three arguments, @code{@var{M}(i)} is the expected +## fraction of the interval @math{[0,t]} spent in state @math{i} +## assuming that the state occupancy probability at time zero is +## @var{p}. When called with two arguments, @code{@var{M}(i)} is the +## expected fraction of time until absorption spent in state @math{i}; +## in this case the mean time to absorption is @code{sum(@var{M})}. ## ## @end table ## @@ -80,7 +80,7 @@ #{ if ( nargin == 3 ) (t >= 0) || \ - usage( "t must be >= 0" ); + error( "t must be >= 0" ); F = @(x) (p*expm(Q*x)); M = quadv(F,0,t) / t; else Modified: trunk/octave-forge/main/queueing/inst/dtmc.m =================================================================== --- trunk/octave-forge/main/queueing/inst/dtmc.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/dtmc.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -84,7 +84,7 @@ [N err] = dtmc_check_P(P); ( N>0 ) || \ - usage( err ); + error( err ); if ( nargin == 1 ) # steady-state analysis A = P-eye(N); @@ -96,10 +96,10 @@ p = b/A; else # transient analysis ( isscalar(n) && n>=0 ) || \ - usage( "n must be >=0" ); + error( "n must be >=0" ); ( isvector(p0) && length(p0) == N && all(p0>=0) && abs(sum(p0)-1.0)<N*eps ) || \ - usage( "p0 must be a probability vector" ); + error( "p0 must be a probability vector" ); p0 = p0(:)'; # make p0 a row vector Modified: trunk/octave-forge/main/queueing/inst/dtmc_bd.m =================================================================== --- trunk/octave-forge/main/queueing/inst/dtmc_bd.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/dtmc_bd.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -75,17 +75,17 @@ endif ( isvector( b ) && isvector( d ) ) || \ - usage( "birth and death must be vectors" ); + error( "birth and death must be vectors" ); b = b(:); # make b a column vector d = d(:); # make d a column vector size_equal( b, d ) || \ - usage( "birth and death vectors must have the same length" ); + error( "birth and death vectors must have the same length" ); all( b >= 0 ) || \ - usage( "birth probabilities must be >= 0" ); + error( "birth probabilities must be >= 0" ); all( d >= 0 ) || \ - usage( "death probabilities must be >= 0" ); + error( "death probabilities must be >= 0" ); all( ([b; 0] + [0; d]) <= 1 ) || \ - usage( "d(i)+b(i+1) must be <= 1"); + error( "d(i)+b(i+1) must be <= 1"); P = diag( b, 1 ) + diag( d, -1 ); P += diag( 1-sum(P,2) ); Modified: trunk/octave-forge/main/queueing/inst/dtmc_exps.m =================================================================== --- trunk/octave-forge/main/queueing/inst/dtmc_exps.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/dtmc_exps.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -74,7 +74,7 @@ [K err] = dtmc_check_P(P); (K>0) || \ - usage(err); + error(err); if ( nargin == 2 ) p0 = varargin{1}; @@ -84,7 +84,7 @@ endif ( isvector(p0) && length(p0) == K && all(p0>=0) && abs(sum(p0)-1.0)<epsilon ) || \ - usage( "p0 must be a state occupancy probability vector" ); + error( "p0 must be a state occupancy probability vector" ); p0 = p0(:)'; # make p0 a row vector Modified: trunk/octave-forge/main/queueing/inst/dtmc_mtta.m =================================================================== --- trunk/octave-forge/main/queueing/inst/dtmc_mtta.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/dtmc_mtta.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -91,11 +91,11 @@ [K err] = dtmc_check_P(P); (K>0) || \ - usage(err); + error(err); if ( nargin == 2 ) ( isvector(p0) && length(p0) == K && all(p0>=0) && abs(sum(p0)-1.0)<epsilon ) || \ - usage( "p0 must be a state occupancy probability vector" ); + error( "p0 must be a state occupancy probability vector" ); endif ## identify transient states Modified: trunk/octave-forge/main/queueing/inst/population_mix.m =================================================================== --- trunk/octave-forge/main/queueing/inst/population_mix.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/population_mix.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -84,10 +84,10 @@ endif isvector( population ) && all( population>=0 ) || \ - usage( "N must be an array >=0" ); + error( "N must be an array >=0" ); R = length(population); # number of classes ( isscalar(k) && k >= 0 && k <= sum(population) ) || \ - usage( "k must be a scalar <= %d", sum(population)); + error( "k must be a scalar <= %d", sum(population)); N = zeros(1, R); const = min(k, population); mp = 0; Modified: trunk/octave-forge/main/queueing/inst/qnammm.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnammm.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnammm.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -75,7 +75,7 @@ endif ( isscalar(lambda) && isvector(mu) ) || \ - usage( "the parameters must be vectors" ); + error( "the parameters must be vectors" ); m = length(mu); # number of servers Modified: trunk/octave-forge/main/queueing/inst/qnclosedab.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnclosedab.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnclosedab.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -69,14 +69,14 @@ print_usage(); endif ( isscalar(N) && N > 0 ) || \ - usage( "N must be a positive integer" ); + error( "N must be a positive integer" ); ( isvector(D) && length(D)>0 && all( D >= 0 ) ) || \ - usage( "D must be a vector of nonnegative floats" ); + error( "D must be a vector of nonnegative floats" ); if ( nargin < 3 ) Z = 0; else ( isscalar(Z) && Z >= 0 ) || \ - usage( "Z must be a nonnegative scalar" ); + error( "Z must be a nonnegative scalar" ); endif D_tot = sum(D); Modified: trunk/octave-forge/main/queueing/inst/qnclosedbsb.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnclosedbsb.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnclosedbsb.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -69,14 +69,14 @@ print_usage(); endif ( isscalar(N) && N>0 ) || \ - usage( "N must be a positive scalar" ); + error( "N must be a positive scalar" ); ( isvector(D) && length(D)>0 && all(D>=0) ) || \ - usage( "D must be a vector of nonnegative floats" ); + error( "D must be a vector of nonnegative floats" ); if ( nargin < 3 ) Z = 0; else ( isscalar(Z) && Z>=0 ) || \ - usage( "Z must be a nonnegative scalar" ); + error( "Z must be a nonnegative scalar" ); endif D_max = max(D); Modified: trunk/octave-forge/main/queueing/inst/qnclosedgb.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnclosedgb.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnclosedgb.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -79,15 +79,15 @@ print_usage(); endif ( isscalar(N) && N > 0 ) || \ - usage( "N must be >0" ); + error( "N must be >0" ); ( isvector(L) && length(L) > 0 && all( L >= 0 ) ) || \ - usage( "D must be a vector >=0" ); + error( "D must be a vector >=0" ); L = L(:)'; # make L a row vector if ( nargin < 3 ) Z = 0; else ( isscalar(Z) && (Z >= 0) ) || \ - usage( "Z must be >=0" ); + error( "Z must be >=0" ); endif L_tot = sum(L); L_max = max(L); @@ -122,9 +122,9 @@ ## network with N customers, service demands D and think time Z. This ## function uses Eq. (8) and (13) from the reference paper. function [ Q_lower Q_upper ] = __compute_Q( N, L, Z, X_plus, X_minus ) - isscalar(X_plus) || usage( "X_plus must be a scalar" ); - isscalar(X_minus) || usage( "X_minus must be a scalar" ); - ( isscalar(N) && (N>=0) ) || usage( "N is not valid" ); + isscalar(X_plus) || error( "X_plus must be a scalar" ); + isscalar(X_minus) || error( "X_minus must be a scalar" ); + ( isscalar(N) && (N>=0) ) || error( "N is not valid" ); L_tot = sum(L); L_max = max(L); M = length(L); Modified: trunk/octave-forge/main/queueing/inst/qnclosedmultimva.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnclosedmultimva.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnclosedmultimva.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -27,9 +27,8 @@ ## @cindex Mean Value Analysys (MVA) ## @cindex closed network, multiple classes ## -## Analyze closed, multiclass queueing networks with @math{K} service -## centers and @math{C} independent customer classes (chains) using the -## Mean Value Analysys (MVA) algorithm. +## Compute steady-state performance measures for closed, multiclass +## queueing networks using the Mean Value Analysys (MVA) algorithm. ## ## Queueing policies at service centers can be any of the following: ## @@ -63,9 +62,10 @@ ## ## If this function is called specifying the routing probability matrix ## @var{P}, then class switching @strong{is} allowed; however, in this -## case all nodes are restricted to be fixed rate service centers or -## delay centers: multiple-server and general load-dependent -## centers are not supported. @end quotation +## case all nodes are restricted to be fixed rate servers or delay +## centers: multiple-server and general load-dependent centers are not +## supported. +## @end quotation ## ## @strong{INPUTS} ## @@ -74,30 +74,31 @@ ## @item N ## @code{@var{N}(c)} is the number of class @math{c} requests in the ## system; @code{@var{N}(c) @geq{} 0}. If class @math{c} has -## no requests (@code{@var{N}(c) = 0}), then +## no requests (@code{@var{N}(c) == 0}), then for all @var{k}, ## @code{@var{U}(c,k) = @var{R}(c,k) = @var{Q}(c,k) = @var{X}(c,k) = 0} -## for all @var{k}. ## ## @item S ## @code{@var{S}(c,k)} is the mean service time for class @math{c} -## customers at center @math{k} (@code{@var{S}(c,k) @geq{} 0}). -## If service time at center @math{k} is class-dependent, -## then center #math{k} is assumed to be of type @math{-/G/1}--PS -## (Processor Sharing). +## customers at center @math{k} (@code{@var{S}(c,k) @geq{} 0}). If the +## service time at center @math{k} is class-dependent, i.e., different +## classes have different service times at center @math{k}, then center +## @math{k} is assumed to be of type @math{-/G/1}--PS (Processor +## Sharing). ## If center @math{k} is a FCFS node (@code{@var{m}(k)>1}), then the -## service times @strong{must} be class-independent. +## service times @strong{must} be class-independent, i.e., all classes +## @strong{must} have the same service time. ## ## @item V ## @code{@var{V}(c,k)} is the average number of visits of class @math{c} ## customers to service center @math{k}; @code{@var{V}(c,k) @geq{} 0}, ## default is 1. -## @strong{If you pass this parameter, class switching is not +## @strong{If you pass this argument, class switching is not ## allowed} ## ## @item P ## @code{@var{P}(r,i,s,j)} is the probability that a class @math{r} ## job completing service at center @math{i} is routed to center @math{j} -## as a class @math{s} job. @strong{If you pass this parameter, +## as a class @math{s} job. @strong{If you pass this argument, ## class switching is allowed}. ## ## @item m @@ -162,17 +163,17 @@ ## basic sanity checks isvector(N) && all( N>=0 ) || \ - usage( "N must be a vector >=0" ); + error( "N must be a vector >=0" ); C = length(N); ## Number of classes ( ndims(S) == 2 ) || \ - usage( "S must be a matrix" ); + error( "S must be a matrix" ); if ( nargin == 2 ) V = ones(size(S)); endif ( ismatrix(V) && (ndims(V) == 2 || ndims(V) == 4) ) || \ - usage("The third parametermust be a 2- or 4-dimensional matrix" ); + error("The third argument must be a 2- or 4-dimensional matrix" ); if ( ndims(V) == 2 ) [U R Q X] = __qnclosedmultimva_nocs( N, S, V, varargin{:} ); @@ -191,34 +192,34 @@ endif isvector(N) && all( N>=0 ) || \ - usage( "N must be >=0" ); + error( "N must be >=0" ); N = N(:)'; # make N a row vector C = length(N); ## Number of classes ( ndims(S) == 2 ) || \ - usage( "S must be a matrix" ); + error( "S must be a matrix" ); K = columns(S); ## Number of service centers size(S) == [C,K] || \ - usage( "S size mismatch (is %dx%d, should be %dx%d)", rows(S), columns(S), C, K ); + error( "S size mismatch (is %dx%d, should be %dx%d)", rows(S), columns(S), C, K ); ndims(P) == 4 && size(P) == [C,K,C,K] || \ - usage( "P size mismatch (should be %dx%dx%dx%d)",C,K,C,K ); + error( "P size mismatch (should be %dx%dx%dx%d)",C,K,C,K ); if ( nargin < 4 ) m = ones(1,K); else isvector(m) || \ - usage( "m must be a vector" ); + error( "m must be a vector" ); m = m(:)'; # make m a row vector length(m) == K || \ - usage( "m size mismatch (should be %d, is %d)", K, length(m) ); + error( "m size mismatch (should be %d, is %d)", K, length(m) ); endif ## Check consistency of parameters all( all( S >= 0 ) ) || \ - usage( "S must be >= 0" ); + error( "S must be >= 0" ); all( any(S>0,2) ) || \ - usage( "S must contain at least a value >0 for each row" ); + error( "S must contain at least a value >0 for each row" ); all( all( P >= 0 ) ) || \ - usage( "V must be >=0" ); + error( "V must be >=0" ); U = R = Q = X = zeros(C,K); @@ -288,42 +289,42 @@ endif isvector(N) && all( N>=0 ) || \ - usage( "N must be >=0" ); + error( "N must be >=0" ); N = N(:)'; # make N a row vector C = length(N); ## Number of classes K = columns(S); ## Number of service centers size(S) == [C,K] || \ - usage( "S size mismatch" ); + error( "S size mismatch" ); size(V) == [C,K] || \ - usage( "V size mismatch" ); + error( "V size mismatch" ); if ( nargin < 4 ) m = ones(1,K); else isvector(m) || \ - usage( "m must be a vector" ); + error( "m must be a vector" ); m = m(:)'; # make m a row vector length(m) == K || \ - usage( "m size mismatch (should be %d, is %d)", K, length(m) ); + error( "m size mismatch (should be %d, is %d)", K, length(m) ); endif if ( nargin < 5 ) Z = zeros(1,C); else isvector(Z) || \ - usage( "Z must be a vector" ); + error( "Z must be a vector" ); Z = Z(:)'; # make Z a row vector length(Z) == C || \ - usage( "Z size mismatch (should be %d, is %d)", C, length(Z) ); + error( "Z size mismatch (should be %d, is %d)", C, length(Z) ); endif ## Check consistency of parameters all( all( S >= 0 ) ) || \ - usage( "S must be >= 0" ); + error( "S must be >= 0" ); all( any(S>0,2) ) || \ - usage( "S must contain at least a value >0 for each row" ); + error( "S must contain at least a value >0 for each row" ); all( all( V >= 0 ) ) || \ - usage( "V must be >=0" ); + error( "V must be >=0" ); ## ensure that the service times for multiserver nodes ## are class-independent @@ -476,7 +477,7 @@ %! S = [1 2 3; 1 2 3]; %! N = [1 1]; %! V = zeros(3,2,3); -%! fail( "qnclosedmultimva(N,S,V)", "third parameter" ); +%! fail( "qnclosedmultimva(N,S,V)", "third argument" ); ## Check degenerate case (population is zero); LI servers %!test Modified: trunk/octave-forge/main/queueing/inst/qnclosedmultimvaapprox.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnclosedmultimvaapprox.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnclosedmultimvaapprox.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -139,33 +139,33 @@ endif isvector(N) && all( N>=0 ) || \ - usage( "N must be a vector of positive integers" ); + error( "N must be a vector of positive integers" ); N = N(:)'; # make N a row vector C = length(N); ## Number of classes K = columns(S); ## Number of service centers size(S) == [C,K] || \ - usage( "S size mismatch" ); + error( "S size mismatch" ); size(V) == [C,K] || \ - usage( "V size mismatch" ); + error( "V size mismatch" ); if ( nargin < 4 ) m = ones(1,K); else isvector(m) || \ - usage( "m must be a vector"); + error( "m must be a vector"); m = m(:)'; # make m a row vector ( length(m) == K && all( m <= 1 ) ) || \ - usage( "m must be <= 1 and have %d elements", K ); + error( "m must be <= 1 and have %d elements", K ); endif if ( nargin < 5 ) Z = zeros(1,C); else isvector(Z) || \ - usage( "Z must be a vector" ); + error( "Z must be a vector" ); Z = Z(:)'; # make Z a row vector ( length(Z) == C && all(Z >= 0 ) ) || \ - usage( "Z must be >= 0 and have %d elements", C ); + error( "Z must be >= 0 and have %d elements", C ); endif if ( nargin < 6 ) @@ -178,9 +178,9 @@ ## Check consistency of parameters all( all( S >= 0 ) ) || \ - usage( "S contains negative values" ); + error( "S contains negative values" ); all( all( V >= 0 ) ) || \ - usage( "V contains negative values" ); + error( "V contains negative values" ); ## Initialize results R = zeros( C, K ); Modified: trunk/octave-forge/main/queueing/inst/qnclosedpb.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnclosedpb.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnclosedpb.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -62,14 +62,14 @@ print_usage(); endif ( isscalar(N) && N > 0 ) || \ - usage( "N must be a positive integer" ); + error( "N must be a positive integer" ); ( isvector(D) && length(D)>0 && all( D >= 0 ) ) || \ - usage( "D must be a vector of nonnegative floats" ); + error( "D must be a vector of nonnegative floats" ); if ( nargin < 3 ) Z = 0; else ( isscalar(Z) && Z >= 0 ) || \ - usage( "Z must be a nonnegative scalar" ); + error( "Z must be a nonnegative scalar" ); endif D_tot = sum(D); X_max = 1/max(D); Modified: trunk/octave-forge/main/queueing/inst/qnclosedsinglemva.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnclosedsinglemva.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnclosedsinglemva.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -119,13 +119,13 @@ endif isscalar(N) && N >= 0 || \ - usage( "N must be >= 0" ); + error( "N must be >= 0" ); isvector(S) || \ - usage( "S must be a vector" ); + error( "S must be a vector" ); S = S(:)'; # make S a row vector isvector(V) || \ - usage( "V must be a vector" ); + error( "V must be a vector" ); V = V(:)'; # make V a row vector K = length(S); # Number of servers @@ -134,23 +134,23 @@ m = ones(1,K); else isvector(m) || \ - usage( "m must be a vector" ); + error( "m must be a vector" ); m = m(:)'; # make m a row vector endif [err S V m] = common_size(S, V, m); (err == 0) || \ - usage( "S, V and m are of incompatible size" ); + error( "S, V and m are of incompatible size" ); all(S>=0) || \ - usage( "S must be a vector >= 0" ); + error( "S must be a vector >= 0" ); all(V>=0) || \ - usage( "V must be a vector >= 0" ); + error( "V must be a vector >= 0" ); if ( nargin < 5 ) Z = 0; else (isscalar(Z) && Z >= 0) || \ - usage( "Z must be >= 0" ); + error( "Z must be >= 0" ); endif U = R = Q = X = zeros( 1, K ); Modified: trunk/octave-forge/main/queueing/inst/qnclosedsinglemvaapprox.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnclosedsinglemvaapprox.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnclosedsinglemvaapprox.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -117,11 +117,11 @@ endif isscalar(N) && N >= 0 || \ - usage( "N must be >= 0" ); + error( "N must be >= 0" ); isvector(S) || \ - usage( "S must be a vector" ); + error( "S must be a vector" ); isvector(V) || \ - usage( "V must be a vector" ); + error( "V must be a vector" ); S = S(:)'; # make S a row vector V = V(:)'; # make V a row vector @@ -131,39 +131,39 @@ m = ones(1,K); else isvector(m) || \ - usage( "m must be a vector" ); + error( "m must be a vector" ); m = m(:)'; # make m a row vector endif [err S V m] = common_size(S, V, m); (err == 0) || \ - usage( "S, V and m are of incompatible size" ); + error( "S, V and m are of incompatible size" ); all(S>=0) || \ - usage( "S must be a vector >= 0" ); + error( "S must be a vector >= 0" ); all(V>=0) || \ - usage( "V must be a vector >= 0" ); + error( "V must be a vector >= 0" ); all(m<=1) || \ - usage( "Vector m must be <= 1 (this function supports IS and single-server nodes only)" ); + error( "Vector m must be <= 1 (this function supports IS and single-server nodes only)" ); if ( nargin < 5 ) Z = 0; else (isscalar(Z) && Z >= 0) || \ - usage( "Z must be >= 0" ); + error( "Z must be >= 0" ); endif if ( nargin < 6 ) tol = 1e-5; else ( isscalar(tol) && tol>0 ) || \ - usage("tol must be a positive scalar"); + error("tol must be a positive scalar"); endif if ( nargin < 7 ) iter_max = 100; else ( isscalar(iter_max) && iter_max > 0 ) || \ - usage("iter_max must be a positive integer"); + error("iter_max must be a positive integer"); endif U = R = Q = X = zeros( 1, K ); Modified: trunk/octave-forge/main/queueing/inst/qnclosedsinglemvald.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnclosedsinglemvald.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnclosedsinglemvald.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -89,21 +89,21 @@ endif isvector(V) && all(V>=0) || \ - usage( "V must be a vector >= 0" ); + error( "V must be a vector >= 0" ); V = V(:)'; # make V a row vector K = length(V); # Number of servers isscalar(N) && N >= 0 || \ - usage( "N must be >= 0" ); + error( "N must be >= 0" ); ( ismatrix(S) && rows(S) == K && columns(S) >= N ) || \ - usage( "S size mismatch: is %dx%d, should be %dx%d", rows(S), columns(S), K, N ); + error( "S size mismatch: is %dx%d, should be %dx%d", rows(S), columns(S), K, N ); all(all(S>=0)) || \ - usage( "S must be >= 0" ); + error( "S must be >= 0" ); if ( nargin < 4 ) Z = 0; else isscalar(Z) && Z>=0 || \ - usage( "Z must be >= 0" ); + error( "Z must be >= 0" ); endif ## Initialize results Modified: trunk/octave-forge/main/queueing/inst/qncmva.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qncmva.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qncmva.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -91,24 +91,24 @@ endif isscalar(N) && N >= 0 || \ - usage("N must be a positive scalar"); + error("N must be a positive scalar"); isvector(S) || \ - usage("S must be a vector"); + error("S must be a vector"); S = S(:)'; # make S a row vector M = length(S)+1; # number of service centers (escluding the delay center) isvector(Sld) && length(Sld) == N && all(Sld>=0) || \ - usage("Sld must be a vector with %d elements >= 0", N); + error("Sld must be a vector with %d elements >= 0", N); Sld = Sld(:)'; # Make Sld a row vector isvector(V) && length(V) == M && all(V>=0) || \ - usage("V must be a vector with %d elements", M); + error("V must be a vector with %d elements", M); V = V(:)'; # Make V a row vector if ( nargin == 5 ) isscalar(Z) && Z>=0 || \ - usage("Z must be nonnegative"); + error("Z must be nonnegative"); else Z = 0; endif Modified: trunk/octave-forge/main/queueing/inst/qnconvolution.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnconvolution.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnconvolution.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -94,25 +94,25 @@ endif ( isscalar(N) && N>0 ) || \ - usage( "K must be a positive scalar" ); + error( "K must be a positive scalar" ); K = N; # To be compliant with the reference, we use K to denote the population size ( isvector(S) && all(S >= 0) ) || \ - usage( "S must be a vector of positive scalars" ); + error( "S must be a vector of positive scalars" ); S = S(:)'; # make S a row vector N = length(S); # Number of service centers ( isvector(V) && size_equal(V,S) ) || \ - usage( "V must be a vector of the same length as S" ); + error( "V must be a vector of the same length as S" ); V = V(:)'; if ( nargin < 4 ) m = ones(1,N); else isvector(m) || \ - usage( "m must be a vector" ); + error( "m must be a vector" ); m = m(:)'; [err m S] = common_size(m, S); (err == 0) || \ - usage( "m and S have incompatible size" ); + error( "m and S have incompatible size" ); endif ## First, we remember the indexes of IS nodes @@ -208,7 +208,7 @@ ## and accepts a vector as parameter j. function result = F(i,j,v,S,m) isscalar(i) || \ - usage( "i must be a scalar" ); + error( "i must be a scalar" ); k_i = j; if ( m(i) == 1 ) result = ( v(i)*S(i) ).^k_i; Modified: trunk/octave-forge/main/queueing/inst/qnconvolutionld.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnconvolutionld.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnconvolutionld.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -93,17 +93,17 @@ endif ( isscalar(N) && N>0 ) || \ - usage( "N must be a positive scalar" ); + error( "N must be a positive scalar" ); K = N; # To be compliant with the reference, we denote K as the population size ( isvector(V) ) || \ - usage( "V must be a vector" ); + error( "V must be a vector" ); V = V(:)'; # Make V a row vector N = length(V); # Number of service centers if ( isnumeric(S) ) ( rows(S) == N && columns(S) == K) || \ - usage( sprintf("S size mismatch: is %dx%d, should be %dx%d", rows(S), columns(S),K,N ) ); + error( sprintf("S size mismatch: is %dx%d, should be %dx%d", rows(S), columns(S),K,N ) ); all( all(S>=0) ) || \ - usage( "S must be >=0" ); + error( "S must be >=0" ); endif ## Initialization Modified: trunk/octave-forge/main/queueing/inst/qnjackson.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnjackson.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnjackson.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -24,9 +24,9 @@ ## @cindex open network, single class ## @cindex Jackson network ## -## With three or four input parameters, this function computes the -## steady-state occupancy probabilities for a Jackson network. With five -## input parameters, this function computes the steady-state probability +## With three or four arguments, this function computes the steady-state +## occupancy probabilities for a Jackson network. With five arguments, +## this function computes the steady-state probability ## @code{@var{pi}(j)} that there are @code{@var{k}(j)} requests at ## service center @math{j}. ## @@ -66,8 +66,8 @@ ## @code{@var{m}(i)} is the number of servers at service center ## @math{i}. If @code{@var{m}(i) < 1}, service center @math{i} is an ## infinite-server node. Otherwise, it is a regular FCFS queueing center with -## @code{@var{m}(i)} servers. If this parameter is omitted, default is -## @code{@var{m}(i) = 1} for all @math{i}. If this parameter is a scalar, +## @code{@var{m}(i)} servers. If this argument is omitted, default is +## @code{@var{m}(i) = 1} for all @math{i}. If this argument is a scalar, ## it will be promoted to a vector with the same size as @var{lambda}. ## Otherwise, @var{m} must be a vector of length @math{N}. ## @@ -116,18 +116,18 @@ print_usage(); endif ( isvector(lambda) && all(lambda>=0) ) || \ - usage( "lambda must be a vector >= 0" ); + error( "lambda must be a vector >= 0" ); lambda=lambda(:)'; # make lambda a row vector N = length(lambda); isvector(S) || \ - usage( "S must be a vector" ); + error( "S must be a vector" ); S = S(:)'; # make S a row vector size_equal(lambda,S) || \ - usage( "lambda and S must of be of the same length" ); + error( "lambda and S must of be of the same length" ); all(S>0) || \ - usage( "S must be >0" ); + error( "S must be >0" ); [N,N] == size(P) || \ - usage(" P must be a matrix of size length(lambda) x length(lambda)" ); + error(" P must be a matrix of size length(lambda) x length(lambda)" ); all(all(P>=0)) && all(sum(P,2)<=1) || \ error( "P is not a transition probability matrix" ); @@ -136,7 +136,7 @@ else [errorcode, lambda, m] = common_size(lambda, m); ( isvector(m) && (errorcode==0) ) || \ - usage("m and lambda must have the same length" ); + error("m and lambda must have the same length" ); endif ## Compute the arrival rates using the traffic equation: @@ -153,9 +153,9 @@ if ( nargin == 5 ) ( isvector(k) && size_equal(lambda,k) ) || \ - usage( "k must be a vector of the same size as lambda" ); + error( "k must be a vector of the same size as lambda" ); all(k>=0) || \ - usage( "k must be nonnegative" ); + error( "k must be nonnegative" ); ## compute occupancy probability rho = l .* S ./ m; Modified: trunk/octave-forge/main/queueing/inst/qnmarkov.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnmarkov.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnmarkov.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -144,17 +144,17 @@ print_usage(); endif - isvector(S) || usage( "S must be a vector" ); + isvector(S) || error( "S must be a vector" ); K = length(S); # number of service centers if ( nargin < 5 ) m = ones(1,K); else - size_equal(m,S) || usage( "m must have the same langth as S" ); + size_equal(m,S) || error( "m must have the same langth as S" ); endif ( [K,K] == size(P) && all( all(P>=0)) && all(sum(P,2) <= 1)) || \ - usage( "P must be SxS and nonnegative" ); + error( "P must be SxS and nonnegative" ); if ( isscalar(x) ) is_open = false; @@ -167,7 +167,7 @@ is_open = true; lambda = x; # open network size_equal(lambda, S ) || \ - usage( "lambda must have the same langth as S" ); + error( "lambda must have the same langth as S" ); endif ( all(m > 0) && all(m <= C) ) || \ Modified: trunk/octave-forge/main/queueing/inst/qnmg1.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnmg1.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnmg1.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -79,7 +79,7 @@ ## bring the parameters to a common size [ err lambda xavg x2nd ] = common_size( lambda, xavg, x2nd ); if ( err ) - usage( "parameters are of incompatible size" ); + error( "parameters are of incompatible size" ); endif mu = 1 ./ xavg; Modified: trunk/octave-forge/main/queueing/inst/qnmh1.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnmh1.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnmh1.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -95,12 +95,12 @@ print_usage(); endif if ( size(mu) != size(alpha) ) - usage( "parameters are of incompatible size" ); + error( "parameters are of incompatible size" ); endif [n c] = size(mu); if (!is_scalar(lambda) && (n != length(lambda)) ) - usage( "parameters are of incompatible size" ); + error( "parameters are of incompatible size" ); endif for i=1:n avg = sum( alpha(i,:) .* (1 ./ mu(i,:)) ); Modified: trunk/octave-forge/main/queueing/inst/qnmix.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnmix.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnmix.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -121,34 +121,34 @@ print_usage(); endif isvector(lambda) || \ - usage( "lambda must be a vector" ); + error( "lambda must be a vector" ); lambda = lambda(:)'; isvector(N) || \ - usage( "N must be a vector" ); + error( "N must be a vector" ); N = N(:)'; size_equal(lambda,N) || \ - usage( "lambda and N must be of equal length" ); + error( "lambda and N must be of equal length" ); ( !any( lambda>0 & N>0 ) ) || \ - usage("A class cannot be open and closed at the same time. Check lambda and N" ); + error("A class cannot be open and closed at the same time. Check lambda and N" ); ( all( lambda>0 | N>0 ) ) || \ - usage( "A class cannot be neither open nor closed. Check lambda and N" ); + error( "A class cannot be neither open nor closed. Check lambda and N" ); size_equal(S,V) || \ - usage( "S and V must have the same size" ); + error( "S and V must have the same size" ); C = length(lambda); # number of classes K = columns(S); # number of service centers rows(S) == C || \ - usage( "S must have %d rows", C ); + error( "S must have %d rows", C ); if ( nargin < 5 ) m = ones(1,K); else isvector( m ) || \ - usage( "m must be a vector" ); + error( "m must be a vector" ); m = m(:)'; size_equal(lambda,m) || \ - usage( "lambda and m must be of equal length" ); + error( "lambda and m must be of equal length" ); endif all( m<=1 ) || \ - usage( "This function supports single-server and delay centers only. Check m" ); + error( "This function supports single-server and delay centers only. Check m" ); if ( !any(lambda>0) ) warning( "qnmix(): There are no open classes. Using qnclosedmultimva()" ); [U R Q X] = qnclosedmultimva( N, S, V, m ); Modified: trunk/octave-forge/main/queueing/inst/qnmknode.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnmknode.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnmknode.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -99,12 +99,12 @@ function Q = qnmknode( node, S, varargin ) ischar(node) || \ - usage( "Parameter \"node\" must be a string" ); + error( "Parameter \"node\" must be a string" ); node = tolower(node); isvector(S) || ismatrix(S) || \ - usage( "Parameter \"S\" must be a vector" ); + error( "Parameter \"S\" must be a vector" ); m = 1; s2 = ones( size(S) ); if ( strcmp(node, "m/m/m-fcfs") ) @@ -115,7 +115,7 @@ if ( 3 == nargin ) m = varargin{1}; m>=1 || \ - usage( "m must be >=1" ); + error( "m must be >=1" ); endif elseif ( strcmp(node, "m/m/1/k-fcfs") ) ## M/M/1/k finite capacity node @@ -125,7 +125,7 @@ if ( 3 == nargin ) k = varargin{1}; k>=1 || \ - usage( "k must be >=1" ); + error( "k must be >=1" ); endif elseif ( strcmp(node, "-/g/1-lcfs-pr") ) ## -/G/1-LCFS-PR node @@ -149,7 +149,7 @@ s2 = varargin{1}; endif else - usage( "Unknown node type \"%s\". node type must be one of \"m/m/m-fcfs\", \"-/g/1-lcfs-pr\", \"-/g/1-ps\" and \"-/g/inf\"", node ); + error( "Unknown node type \"%s\". node type must be one of \"m/m/m-fcfs\", \"-/g/1-lcfs-pr\", \"-/g/1-ps\" and \"-/g/inf\"", node ); endif Q = struct( "node", node, "m", m, "S", S, "s2", s2, "c", rows(S), "comment", "" ); endfunction Modified: trunk/octave-forge/main/queueing/inst/qnmm1.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnmm1.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnmm1.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -89,14 +89,14 @@ ## bring the parameters to a common size [ err lambda mu ] = common_size( lambda, mu ); if ( err ) - usage( "parameters are of incompatible size" ); + error( "parameters are of incompatible size" ); endif ( isvector(lambda) && isvector(mu) ) || \ - usage( "lambda and mu must be vectors" ); + error( "lambda and mu must be vectors" ); all( lambda > 0 ) || \ - usage( "lambda must be >0" ); + error( "lambda must be >0" ); all( mu > lambda ) || \ - usage( "The system is not ergodic" ); + error( "The system is not ergodic" ); U = rho = lambda ./ mu; # utilization p0 = 1-rho; Q = rho ./ (1-rho); Modified: trunk/octave-forge/main/queueing/inst/qnmm1k.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnmm1k.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnmm1k.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -95,17 +95,17 @@ endif ( isvector(lambda) && isvector(mu) && isvector(K) ) || \ - usage( "lambda, mu, K must be vectors of the same size" ); + error( "lambda, mu, K must be vectors of the same size" ); [err lambda mu K] = common_size( lambda, mu, K ); if ( err ) - usage( "Parameters are not of common size" ); + error( "Parameters are not of common size" ); endif all( K>0 ) || \ - usage( "K must be >0" ); + error( "K must be >0" ); ( all( lambda>0 ) && all( mu>0 ) ) || \ - usage( "lambda and mu must be >0" ); + error( "lambda and mu must be >0" ); U = R = Q = X = p0 = pK = 0*lambda; a = lambda./mu; Modified: trunk/octave-forge/main/queueing/inst/qnmminf.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnmminf.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnmminf.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -93,13 +93,13 @@ [ err lambda mu ] = common_size( lambda, mu ); if ( err ) - usage( "Parameters are of incompatible size" ); + error( "Parameters are of incompatible size" ); endif ( isvector(lambda) && isvector(mu) ) || \ - usage( "lambda and mu must be vectors" ); + error( "lambda and mu must be vectors" ); ( all( lambda>0 ) && all( mu>0 ) ) || \ - usage( "lambda and mu must be >0" ); + error( "lambda and mu must be >0" ); U = Q = lambda ./ mu; # Traffic intensity. p0 = exp(-lambda./mu); # probability that there are 0 requests in the system R = 1 ./ mu; Modified: trunk/octave-forge/main/queueing/inst/qnmmm.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnmmm.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnmmm.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -111,14 +111,14 @@ endif [err lambda mu m] = common_size( lambda, mu, m ); if ( err ) - usage( "parameters are not of common size" ); + error( "parameters are not of common size" ); endif ( isvector(lambda) && isvector(mu) && isvector(m) ) || \ - usage( "the parameters must be vectors" ); + error( "the parameters must be vectors" ); all( m>0 ) || \ - usage( "m must be >0" ); + error( "m must be >0" ); all( lambda < m .* mu ) || \ error( "Processing capacity exceeded" ); Modified: trunk/octave-forge/main/queueing/inst/qnmmmk.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnmmmk.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnmmmk.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -115,7 +115,7 @@ endif ( isvector(lambda) && isvector(mu) && isvector(m) && isvector(K) ) || ... - usage( "lambda, mu, m, K must be vectors of the same size" ); + error( "lambda, mu, m, K must be vectors of the same size" ); lambda = lambda(:)'; # make lambda a row vector mu = mu(:)'; # make mu a row vector m = m(:)'; # make m a row vector @@ -123,15 +123,15 @@ [err lambda mu m K] = common_size( lambda, mu, m, K ); if ( err ) - usage( "Parameters are not of common size" ); + error( "Parameters are not of common size" ); endif all( K>0 ) || \ - usage( "k must be strictly positive" ); + error( "k must be strictly positive" ); all( m>0 ) && all( m <= K ) || \ - usage( "m must be in the range 1:k" ); + error( "m must be in the range 1:k" ); all( lambda>0 ) && all( mu>0 ) || \ - usage( "lambda and mu must be >0" ); + error( "lambda and mu must be >0" ); U = R = Q = X = p0 = pK = 0*lambda; for i=1:length(lambda) ## Build and solve the birth-death process describing the M/M/m/k system Modified: trunk/octave-forge/main/queueing/inst/qnmvablo.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnmvablo.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnmvablo.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -91,15 +91,15 @@ print_usage(); endif ( isscalar(K) && K > 0 ) || \ - usage( "K must be a positive integer" ); + error( "K must be a positive integer" ); isvector(S) && all(S>0) || \ error ("S must be a vector > 0"); S = S(:)'; # make S a row vector N = length(S); ( isvector(M) && length(M) == N ) || \ - usage( "M must be a vector with %d elements", N ); + error( "M must be a vector with %d elements", N ); all( M >= 1) || \ - usage( "M must be >= 1"); + error( "M must be >= 1"); M = M(:)'; # make M a row vector (K < sum(M)) || \ Modified: trunk/octave-forge/main/queueing/inst/qnopenab.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnopenab.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnopenab.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -64,9 +64,9 @@ print_usage(); endif ( isscalar(lambda) && lambda > 0 ) || \ - usage( "lambda must be a positive scalar" ); + error( "lambda must be a positive scalar" ); ( isvector(D) && length(D)>0 && all( D>=0 ) ) || \ - usage( "D must be a vector of nonnegative scalars" ); + error( "D must be a vector of nonnegative scalars" ); X_upper = 1/max(D); R_lower = sum(D); Modified: trunk/octave-forge/main/queueing/inst/qnopenbsb.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnopenbsb.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnopenbsb.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -65,9 +65,9 @@ print_usage(); endif ( isscalar(lambda) && lambda>0 ) || \ - usage( "lambda must be a positive scalar" ); + error( "lambda must be a positive scalar" ); ( isvector(D) && length(D)>0 && all(D>=0) ) || \ - usage( "D must be a vector of nonnegative floats" ); + error( "D must be a vector of nonnegative floats" ); D_max = max(D); D_tot = sum(D); Modified: trunk/octave-forge/main/queueing/inst/qnopenmulti.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnopenmulti.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnopenmulti.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -92,24 +92,24 @@ print_usage(); endif isvector(lambda) && all(lambda > 0) || \ - usage( "lambda must be a vector of positive floats" ); + error( "lambda must be a vector of positive floats" ); lambda = lambda(:)'; # make lambda a row vector C = length(lambda); K = columns(S); [C,K] == size(S) || \ - usage( "rows(S) must be equal to length(lambda)" ); + error( "rows(S) must be equal to length(lambda)" ); all(all( S > 0 )) || \ - usage( "S(c,k) must be > 0" ); + error( "S(c,k) must be > 0" ); [C,K] == size(V) || \ - usage( "V must be a matrix of the same size as S" ); + error( "V must be a matrix of the same size as S" ); all( all(V>= 0) ) || \ - usage( "V must be >= 0 " ); + error( "V must be >= 0 " ); if ( nargin < 4 ) m = ones(1,K); else ( isvector( m ) && length(m) == K && all( m <= 1 ) ) || \ - usage( "m must be less than or equal to ones(1,K)" ); + error( "m must be less than or equal to ones(1,K)" ); m = m(:)'; # make m a row vector endif Modified: trunk/octave-forge/main/queueing/inst/qnopensingle.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnopensingle.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnopensingle.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -101,25 +101,25 @@ print_usage(); endif ( isscalar(lambda) && lambda>0 ) || \ - usage( "lambda must be a positive number" ); + error( "lambda must be a positive number" ); lambda = lambda(:)'; ( isvector( S ) && all(S>0) ) || \ - usage( "S must be a vector >0" ); + error( "S must be a vector >0" ); S = S(:)'; K = length(S); ( isvector( V ) && length(V)==K && all(V>=0) ) || \ - usage( "V must be a vector >=0 and of the same length as S" ); + error( "V must be a vector >=0 and of the same length as S" ); V = V(:)'; if ( nargin < 4 ) m = ones(1,K); else (isvector(m) && (length(m) == K)) || \ - usage( "m must be a vector of %d elements", K); + error( "m must be a vector of %d elements", K); m = m(:)'; [err m] = common_size(m,S); ( err == 0 ) || \ - usage( "m and S are not of common size" ); + error( "m and S are not of common size" ); endif ## Compute maximum processing capacity Modified: trunk/octave-forge/main/queueing/inst/qnsolve.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnsolve.m 2012-04-13 12:11:56 UTC (rev 10211) +++ trunk/octave-forge/main/queueing/inst/qnsolve.m 2012-04-13 12:20:21 UTC (rev 10212) @@ -106,7 +106,7 @@ endif ischar(network_type) || \ - usage("First parameter must be a string"); + error("First parameter must be a string"); network_type = tolower(network_type); @@ -117,7 +117,7 @@ elseif (strcmp(network_type, "mixed" ) ) [U R Q X] = __qnsolve_mixed( varargin{:} ); else - usage( "Invalid network type %s: must be one of \"open\", \"closed\" or \"mixed\"", network_type ); + error( "Invalid network type %s: must be one of \"open\", \"closed\" or \"mixed\"", network_type ); endif endfunction @@ -140,26 +140,26 @@ endif ( isscalar(lambda) && (lambda>0) ) || \ - usage( "lambda must be a scalar > 0" ); + error( "lambda must be a scalar > 0" ); iscell(QQ) || \ - usage( "QQ must be a cell array" ); + error( "QQ must be a cell array" ); N = length(QQ); ( isvector(V) && length(V) == N ) || \ - usage( "V must be a vector of length %d", N ); + error( "V must be a vector of length %d", N ); V = V(:); # make V a row vector all(V>=0) || \ - usage( "V must be >= 0" ); + error( "V must be >= 0" ); ## Initialize vectors S = zeros(size(V)); m = ones(size(V)); for i=1:N QQ{i}.c == 1 || \ - usage( "Multiclass networks are not supported by this function" ); + error( "Multiclass networks are not supported by this function" ); S(i) = QQ{i}.S; if __is_li(QQ{i}) ; # nothing to do @@ -168,7 +168,7 @@ elseif __is_is(QQ{i}) m(i) = -1; else - usage( "Unsupported type \"%s\" for node %d", QQ{i}.node, i ); + error( "Unsupported type \"%s\" for node %d", QQ{i}.node, i ); endif endfor @@ -184,29 +184,29 @@ print_usage(); endif isvector(lambda) && all(lambda > 0) || \ - usage( "lambda must be a vector >0" ); + error( "lambda must be a vector >0" ); lambda = lambda(:)'; # make lambda a row vector iscell(QQ) || \ - usage( "QQ must be a cell array" ); + error( "QQ must be a cell array" ); C = length(lambda); K = length(QQ); [C,K] == size(V) || \ - usage( "V size mismatch" ); + error( "V size mismatch" ); all( all( V>= 0 ) ) || \ - usage( "V must be >= 0 " ); + error( "V must be >= 0 " ); S = zeros(C,K); m = ones(1,K); for i=1:K QQ{i}.c == C || \ - usage( "Wrong number of classes for center %d (is %d, should be %d)", i, QQ{i}.c, C ); + error( "Wrong number of classes for center %d (is %d, should be %d)", i, QQ{i}.c, C ); S(:,i) = QQ{i}.S(:); if __is_li(QQ{i}) ; # nothing to do elseif __is_is(QQ{i}) m(i) = -1; else - usage( "Unsupported type \"%s\" for node %d", QQ{i}.node, i ); + error( "Unsupported type \"%s\" for node %d", QQ{i}.node, i ); endif endfor @@ -231,32 +231,32 @@ function [U R Q X] = __qnsolve_closed_single( N, QQ, V, Z ) if ( nargin < 3 || nargin > 4 ) - usage(); + error(); endif isscalar(N) || \ - usage( "Multiclass networks are not supported by this function" ); + error( "Multiclass networks are not supported by this function" ); iscell(QQ) || \ - usage( "QQ must be a cell array" ); + error( "QQ must be a cell array" ); if ( nargin < 4 ) Z = 0; else isscalar(Z) && Z >= 0 || \ - usage( "Z must be >= 0" ); + error( "Z must be >= 0" ); endif K = length(QQ); ( isvector(V) && length(V) == K ) || \ - usage( "V must be a vector of length %d", K ); + error( "V must be a vector of length %d", K ); ## Initialize vectors i_single = i_multi = i_delay = i_ld = []; for i=1:K ( QQ{i}.c == 1 ) || \ - usage( "Multiclass networks are not supported by this function" ); + error( "Multiclass networks are not supported by this function" ); if __is_li(QQ{i}) i_single = [i_single i]; elseif __is_multi(QQ{i}) @@ -266,7 +266,7 @@ elseif __is_ld(QQ{i}) i_ld = [i_ld i]; else - usage( "Unsupported type \"%s\" for node %d", QQ{i}.node, i ); + error( "Unsupported type \"%s\" for node %d", QQ{i}.node, i ); endif endfor p = cell( 1, K ); @@ -365,48 +365,48 @@ endif isvector(N) && all( N>0 ) || \ - usage( "N must be >0" ); + error( "N must be >0" ); iscell(QQ) || \ - usage( "QQ must be a cell array" ); + error( "QQ must be a cell array" ); C = length(N); ## Number of classes K = length(QQ); ## Number of service centers size(V) == [C,K] || \ - usage( "V size mismatch" ); + error( "V size mismatch" ); if ( nargin < 4 ) Z = zeros(1,C); else isvector(Z) && length(Z) == C || \ - usage( "Z size mismatch" ); + error( "Z size mismatch" ); endif ## Check consistence of parameters all( all( V >= 0 ) ) || \ - usage( "V must be >=0" ); + error( "V must be >=0" ); ## Initialize vectors i_single = i_multi = i_delay = i_ld = [... [truncated message content] |
From: <mma...@us...> - 2012-09-08 16:50:16
|
Revision: 10983 http://octave.svn.sourceforge.net/octave/?rev=10983&view=rev Author: mmarzolla Date: 2012-09-08 16:50:10 +0000 (Sat, 08 Sep 2012) Log Message: ----------- Increased tolerance in tests Modified Paths: -------------- trunk/octave-forge/main/queueing/inst/dtmc_fpt.m trunk/octave-forge/main/queueing/inst/dtmc_mtta.m trunk/octave-forge/main/queueing/inst/qnvisits.m Modified: trunk/octave-forge/main/queueing/inst/dtmc_fpt.m =================================================================== --- trunk/octave-forge/main/queueing/inst/dtmc_fpt.m 2012-09-07 20:54:56 UTC (rev 10982) +++ trunk/octave-forge/main/queueing/inst/dtmc_fpt.m 2012-09-08 16:50:10 UTC (rev 10983) @@ -138,5 +138,5 @@ %! P(8,[7 5 9]) = 1/3; %! P(9,[6 8]) = .5; %! M = dtmc_fpt(P); -%! assert( M(1:9 != 5,5)', [6 5 6 5 5 6 5 6], 10*eps ); +%! assert( M(1:9 != 5,5)', [6 5 6 5 5 6 5 6], 100*eps ); Modified: trunk/octave-forge/main/queueing/inst/dtmc_mtta.m =================================================================== --- trunk/octave-forge/main/queueing/inst/dtmc_mtta.m 2012-09-07 20:54:56 UTC (rev 10982) +++ trunk/octave-forge/main/queueing/inst/dtmc_mtta.m 2012-09-08 16:50:10 UTC (rev 10983) @@ -158,9 +158,9 @@ %!test %! P = dtmc_bd([0 .5 .5 .5 .5], [.5 .5 .5 .5 0]); %! [t N B] = dtmc_mtta(P); -%! assert( t(2:5), [4 6 6 4], 10*eps ); -%! assert( B(2:5,1), [.8 .6 .4 .2]', 10*eps ); -%! assert( B(2:5,6), [.2 .4 .6 .8]', 10*eps ); +%! assert( t(2:5), [4 6 6 4], 100*eps ); +%! assert( B(2:5,1), [.8 .6 .4 .2]', 100*eps ); +%! assert( B(2:5,6), [.2 .4 .6 .8]', 100*eps ); ## Compute the probability of completing the "snakes and ladders" ## game in n steps, for various values of n. Also, computes the expected Modified: trunk/octave-forge/main/queueing/inst/qnvisits.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnvisits.m 2012-09-07 20:54:56 UTC (rev 10982) +++ trunk/octave-forge/main/queueing/inst/qnvisits.m 2012-09-08 16:50:10 UTC (rev 10983) @@ -189,7 +189,7 @@ %! P(2,3,2,1) = 0.2; %! P(2,4,2,1) = 0.16; %! lambda = [0.1 0 0 0.1 ; 0 0 0.2 0.1]; -%! lambda_sum = sum(sum(lambda)); +%! lambda_sum = sum(lambda(:)); %! V = qnvisits(P, lambda); %! assert( all( all(V>=0) ) ); %! for i=1:K @@ -413,7 +413,7 @@ ## solve the traffic equation A = eye(K*C) - reshape(P,[K*C K*C]); - b = reshape(lambda / sum(sum(lambda)), [1,K*C]); + b = reshape(lambda / sum(lambda(:)), [1,K*C]); V = reshape(b/A, [C, K]); endif ## Make sure that no negative values appear (sometimes, numerical This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mma...@us...> - 2012-04-05 14:32:52
|
Revision: 10146 http://octave.svn.sourceforge.net/octave/?rev=10146&view=rev Author: mmarzolla Date: 2012-04-05 14:32:41 +0000 (Thu, 05 Apr 2012) Log Message: ----------- Bug fixes Modified Paths: -------------- trunk/octave-forge/main/queueing/inst/ctmc.m trunk/octave-forge/main/queueing/inst/ctmc_taexps.m trunk/octave-forge/main/queueing/inst/dtmc.m trunk/octave-forge/main/queueing/inst/dtmc_fpt.m trunk/octave-forge/main/queueing/inst/qnmmm.m Modified: trunk/octave-forge/main/queueing/inst/ctmc.m =================================================================== --- trunk/octave-forge/main/queueing/inst/ctmc.m 2012-04-04 12:47:24 UTC (rev 10145) +++ trunk/octave-forge/main/queueing/inst/ctmc.m 2012-04-05 14:32:41 UTC (rev 10146) @@ -25,11 +25,14 @@ ## @cindex Markov chain, state occupancy probabilities ## @cindex Stationary probabilities ## +## Compute stationary or transient state occupancy probabilities +## for a continuous-time Markov chain. +## ## With a single argument, compute the stationary state occupancy ## probability vector @var{p}(1), @dots{}, @var{p}(N) for a -## Continuous-Time Markov Chain with infinitesimal generator matrix -## @var{Q} of size @math{N \times N}. With three arguments, compute the -## state occupancy probabilities @var{p}(1), @dots{}, @var{p}(N) at time +## continuous-time Markov chain with @math{N \times N} infinitesimal +## generator matrix @var{Q}. With three arguments, compute the state +## occupancy probabilities @var{p}(1), @dots{}, @var{p}(N) at time ## @var{t}, given initial state occupancy probabilities @var{p0} at time ## 0. ## @@ -74,6 +77,8 @@ function q = ctmc( Q, t, p0 ) + persistent epsilon = 10*eps; + if ( nargin != 1 && nargin != 3 ) print_usage(); endif @@ -83,52 +88,43 @@ ( N>0 ) || \ usage(err); - if ( nargin == 1 ) - q = __ctmc_steady_state( Q ); - else + if ( nargin == 1 ) # steady-state analysis + + ## non zero columns + nonzero=find( any(abs(Q)>epsilon,1 ) ); + if ( length(nonzero) == 0 ) + error( "Q is the zero matrix" ); + endif + + normcol = nonzero(1); # normalization condition column + + ## force probability of unvisited states to zero + for i=find( all(abs(Q)<epsilon,1) ) + Q(i,i) = 1; + endfor + + ## assert( rank(Q) == N-1 ); + + Q(:,normcol) = 1; # add normalization condition + b = zeros(1,N); b(normcol)=1; + q = b/Q; # qQ = b; + + else # transient analysis + ( isscalar(t) && t>=0 ) || \ - usage("t must be nonnegative"); + usage("t must be a scalar >= 0"); ( isvector(p0) && length(p0) == N && all(p0>=0) && abs(sum(p0)-1.0)<N*eps ) || \ usage( "p0 must be a probability vector" ); p0 = p0(:)'; # make p0 a row vector - q = __ctmc_transient(Q, t, p0 ); - endif + q = p0*expm(Q*t); -endfunction - -## Helper function, compute steady state probability -function q = __ctmc_steady_state( Q ) - persistent epsilon = 10*eps; - N = rows(Q); - - ## non zero columns - nonzero=find( any(abs(Q)>epsilon,1 ) ); - if ( length(nonzero) == 0 ) - error( "Q is the zero matrix" ); endif - normcol = nonzero(1); # normalization condition column - - ## force probability of unvisited states to zero - for i=find( all(abs(Q)<epsilon,1) ) - Q(i,i) = 1; - endfor - - ## assert( rank(Q) == N-1 ); - - Q(:,normcol) = 1; # add normalization condition - b = zeros(1,N); b(normcol)=1; - q = b/Q; # qQ = b; endfunction -## Helper function, compute transient probability -function q = __ctmc_transient( Q, t, p0 ) - q = p0*expm(Q*t); -endfunction - %!test %! Q = [-1 1 0 0; 2 -3 1 0; 0 2 -3 1; 0 0 2 -2]; %! q = ctmc(Q); Modified: trunk/octave-forge/main/queueing/inst/ctmc_taexps.m =================================================================== --- trunk/octave-forge/main/queueing/inst/ctmc_taexps.m 2012-04-04 12:47:24 UTC (rev 10145) +++ trunk/octave-forge/main/queueing/inst/ctmc_taexps.m 2012-04-05 14:32:41 UTC (rev 10146) @@ -75,7 +75,7 @@ endif L = ctmc_exps(Q,varargin{:}); - M = L ./ sum(L); + M = L ./ repmat(sum(L,2),1,columns(L)); #{ if ( nargin == 3 ) @@ -111,6 +111,7 @@ %! for i=1:length(t) %! M(i,:) = ctmc_taexps(Q,t(i),p); %! endfor +%! clf; %! plot(t, M(:,1), ";State 1;", "linewidth", 2, \ %! t, M(:,2), ";State 2;", "linewidth", 2, \ %! t, M(:,3), ";State 3;", "linewidth", 2, \ @@ -141,7 +142,7 @@ %! 0 0 0 d -d]; %! p = ctmc(Q); %! printf("System availability: %f\n",p(1)+p(4)); -%! TT = linspace(1e-5,1*day,101); +%! TT = linspace(0,1*day,101); %! PP = ctmc_taexps(Q,TT,[1 0 0 0 0]); %! A = At = Abart = zeros(size(TT)); %! A(:) = p(1) + p(4); # steady-state availability @@ -151,6 +152,7 @@ %! At(n) = p(1) + p(4); # instantaneous availability %! Abart(n) = PP(n,1) + PP(n,4); # interval base availability %! endfor +%! clf; %! semilogy(TT,A,";Steady-state;", \ %! TT,At,";Instantaneous;", \ %! TT,Abart,";Interval base;"); Modified: trunk/octave-forge/main/queueing/inst/dtmc.m =================================================================== --- trunk/octave-forge/main/queueing/inst/dtmc.m 2012-04-04 12:47:24 UTC (rev 10145) +++ trunk/octave-forge/main/queueing/inst/dtmc.m 2012-04-05 14:32:41 UTC (rev 10146) @@ -86,9 +86,15 @@ ( N>0 ) || \ usage( err ); - if ( nargin == 1 ) - p = __dtmc_steady_state( P ); - else + if ( nargin == 1 ) # steady-state analysis + A = P-eye(N); + A(:,N) = 1; # add normalization condition + rank( A ) == N || \ + warning( "dtmc(): P is reducible" ); + + b = [ zeros(1,N-1) 1 ]; + p = b/A; + else # transient analysis ( isscalar(n) && n>=0 ) || \ usage( "n must be >=0" ); @@ -97,27 +103,10 @@ p0 = p0(:)'; # make p0 a row vector - p = __dtmc_transient(P, n, p0); + p = p0*P^n; endif endfunction -## Helper function, compute steady-state probability -function p = __dtmc_steady_state( P ) - N = rows(P); - A = P-eye(N); - A(:,N) = 1; # add normalization condition - rank( A ) == N || \ - warning( "dtmc(): P is reducible" ); - - b = [ zeros(1,N-1) 1 ]; - p = b/A; -endfunction - -## Helper function, compute transient probability -function p = __dtmc_transient( P, n, p0 ) - p = p0*P^n; -endfunction - %!test %! P = [0.75 0.25; 0.5 0.5]; %! p = dtmc(P); Modified: trunk/octave-forge/main/queueing/inst/dtmc_fpt.m =================================================================== --- trunk/octave-forge/main/queueing/inst/dtmc_fpt.m 2012-04-04 12:47:24 UTC (rev 10145) +++ trunk/octave-forge/main/queueing/inst/dtmc_fpt.m 2012-04-05 14:32:41 UTC (rev 10146) @@ -140,15 +140,3 @@ %! M = dtmc_fpt(P); %! assert( M(1:9 != 5,5)', [6 5 6 5 5 6 5 6], 10*eps ); -%!demo -%! P = [ 0.0 0.9 0.1; \ -%! 0.1 0.0 0.9; \ -%! 0.9 0.1 0.0 ]; -%! M = dtmc_fpt(P); -%! w = dtmc(P); -%! N = rows(P); -%! W = repmat(w,N,1); -%! Z = inv(eye(N)-P+W); -%! M1 = (repmat(diag(Z),1,N) - Z) ./ repmat(w',1,N); -%! assert(M, M1); - Modified: trunk/octave-forge/main/queueing/inst/qnmmm.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnmmm.m 2012-04-04 12:47:24 UTC (rev 10145) +++ trunk/octave-forge/main/queueing/inst/qnmmm.m 2012-04-05 14:32:41 UTC (rev 10146) @@ -141,7 +141,7 @@ R = Q ./ X; endfunction %!demo -%! disp("This is figure 6.4 on p. 220 Bolch et al."); +%! # This is figure 6.4 on p. 220 Bolch et al. %! rho = 0.9; %! ntics = 21; %! lambda = 0.9; @@ -153,6 +153,6 @@ %! axis([0,ntics,0,25]); %! legend("Jobs in the system","Queue Length","location","northwest"); %! xlabel("Number of servers (m)"); -%! title("\lambda = 0.9, \mu = 0.9"); +%! title("\\lambda = 0.9, \\mu = 0.9"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mma...@us...> - 2012-06-16 15:40:40
|
Revision: 10633 http://octave.svn.sourceforge.net/octave/?rev=10633&view=rev Author: mmarzolla Date: 2012-06-16 15:40:34 +0000 (Sat, 16 Jun 2012) Log Message: ----------- Small fixed to the docstrings Modified Paths: -------------- trunk/octave-forge/main/queueing/inst/ctmc.m trunk/octave-forge/main/queueing/inst/dtmc.m trunk/octave-forge/main/queueing/inst/qnsolve.m Modified: trunk/octave-forge/main/queueing/inst/ctmc.m =================================================================== --- trunk/octave-forge/main/queueing/inst/ctmc.m 2012-06-16 09:34:54 UTC (rev 10632) +++ trunk/octave-forge/main/queueing/inst/ctmc.m 2012-06-16 15:40:34 UTC (rev 10633) @@ -28,13 +28,12 @@ ## Compute stationary or transient state occupancy probabilities ## for a continuous-time Markov chain. ## -## With a single argument, compute the stationary state occupancy -## probability vector @var{p}(1), @dots{}, @var{p}(N) for a -## continuous-time Markov chain with @math{N \times N} infinitesimal -## generator matrix @var{Q}. With three arguments, compute the state -## occupancy probabilities @var{p}(1), @dots{}, @var{p}(N) at time -## @var{t}, given initial state occupancy probabilities @var{p0} at time -## 0. +## With a single argument, compute the stationary probability vector +## @var{p}(1), @dots{}, @var{p}(N) for a continuous-time Markov chain +## with @math{N \times N} infinitesimal generator matrix @var{Q}. With +## three arguments, compute the state occupancy probabilities +## @var{p}(1), @dots{}, @var{p}(N) at time @var{t}, given initial state +## occupancy probabilities @var{p0}(1), @dots{}, @var{p0}(N) at time 0. ## ## @strong{INPUTS} ## @@ -44,10 +43,12 @@ ## Infinitesimal generator matrix. @var{Q} is a @math{N \times N} square ## matrix where @code{@var{Q}(i,j)} is the transition rate from state ## @math{i} to state @math{j}, for @math{1 @leq{} i \neq j @leq{} N}. -## Transition rates must be nonnegative, and @math{\sum_{j=1}^N Q_{i, j} = 0} +## #var{Q} must satisfy the property that @math{\sum_{j=1}^N Q_{i, j} = +## 0} ## ## @item t -## Time at which to compute the transient probability +## Time at which to compute the transient probability. If omitted, +## compute the steady state occupancy probability. ## ## @item p0 ## @code{@var{p0}(i)} is the probability that the system @@ -66,7 +67,7 @@ ## satisfies the equation @math{p{\bf Q} = 0} and @math{\sum_{i=1}^N p_i = 1}. ## If this function is invoked with three arguments, @code{@var{p}(i)} ## is the probability that the system is in state @math{i} at time @var{t}, -## given the initial occupancy probabilities @var{p0}. +## given the initial occupancy probabilities @var{p0}(1), @dots{}, @var{p0}(N). ## ## @end table ## Modified: trunk/octave-forge/main/queueing/inst/dtmc.m =================================================================== --- trunk/octave-forge/main/queueing/inst/dtmc.m 2012-06-16 09:34:54 UTC (rev 10632) +++ trunk/octave-forge/main/queueing/inst/dtmc.m 2012-06-16 15:40:34 UTC (rev 10633) @@ -27,13 +27,14 @@ ## @cindex Markov chain, transient probabilities ## @cindex Transient probabilities ## -## Compute steady-state or transient state occupancy probabilities for a -## Discrete-Time Markov Chain. With a single argument, compute the -## steady-state occupancy probability vector @code{@var{p}(1), @dots{}, -## @var{p}(N)} given the @math{N \times N} transition probability matrix -## @var{P}. With three arguments, compute the state occupancy -## probabilities @code{@var{p}(1), @dots{}, @var{p}(N)} after @var{n} -## steps, given initial occupancy probability vector @var{p0}. +## With a single argument, compute the steady-state occupancy +## probability vector @code{@var{p}(1), @dots{}, @var{p}(N)} for a +## discrete-time Markov chain described by the @math{N \times N} +## transition probability matrix @var{P}. With three arguments, compute +## the state occupancy probabilities @code{@var{p}(1), @dots{}, +## @var{p}(N)} that the system is in state @math{i} after @var{n} steps, +## given initial occupancy probability vector @var{p0}(1), @dots{}, +## @var{p0}(N). ## ## @strong{INPUTS} ## @@ -42,8 +43,9 @@ ## @item P ## @code{@var{P}(i,j)} is the transition probability from state @math{i} ## to state @math{j}. @var{P} must be an irreducible stochastic matrix, -## which means that the sum of each row must be 1 (@math{\sum_{j=1}^N P_{i, j} = 1}), and the rank of -## @var{P} must be equal to its dimension. +## which means that the sum of each row must be 1 (@math{\sum_{j=1}^N +## P_{i, j} = 1}), and the rank of @var{P} must be equal to its +## dimension. ## ## @item n ## Number of transitions after which compute the state occupancy probabilities Modified: trunk/octave-forge/main/queueing/inst/qnsolve.m =================================================================== --- trunk/octave-forge/main/queueing/inst/qnsolve.m 2012-06-16 09:34:54 UTC (rev 10632) +++ trunk/octave-forge/main/queueing/inst/qnsolve.m 2012-06-16 15:40:34 UTC (rev 10633) @@ -22,8 +22,7 @@ ## @deftypefnx {Function File} {[@var{U}, @var{R}, @var{Q}, @var{X}] =} qnsolve (@var{"open"}, @var{lambda}, @var{QQ}, @var{V}) ## @deftypefnx {Function File} {[@var{U}, @var{R}, @var{Q}, @var{X}] =} qnsolve (@var{"mixed"}, @var{lambda}, @var{N}, @var{QQ}, @var{V}) ## -## General evaluator of QN models. Networks can be open, -## closed or mixed; single as well as multiclass networks are supported. +## High-level function for analyzing QN models. ## ## @itemize ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |