The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Math::Telephony::ErlangC - Erlang C calculations in Perl

VERSION

Please check version directly inside the module:

 perl -MMath::Telephony::ErlangC \
   -le 'print $Math::Telephony::ErlangC::VERSION'

SYNOPSIS

  use Math::Telephony::ErlangC;

  # Evaluate probability that a service request will have to wait
  $wprob = wait_probability($traffic, $servers);

  # Probability that the wait time will be less than a fixed maximum
  # $mst is the mean service time
  $mwprob = maxtime_probability($traffic, $servers, $mst, $maxtime);

  # Average time waiting in queue
  # $mst is the mean service time
  $awtime = average_wait_time($traffic, $servers, $mst);

DESCRIPTION

This module contains various functions to deal with Erlang C calculations.

The Erlang C model allows dimensioning the number of servers in a M/M/S/inf/inf model (Kendall notation):

  • The input process is Markovian (Poisson in this case)

  • The serving process is Markovian (ditto)

  • There are S servers

  • The wait line is infinite (pure wait, no loss, no renounce)

  • The input population is infinite

CONCEPTS

Some concepts are common to the the following functions:

  • traffic is the offered traffic expressed in Erlang. When an input parameter, this value must be defined and greater or equal to 0. As per definition, this value is given by the product of the service request arrival and the average service time (see below for this).

  • servers is the number of servers in the queue. When an input parameter, this must be a defined value, greater or equal to 0.

  • wait probability is the probability that a given service request will be put inside the wait queue, which happens when all servers are busy.

  • (average) service time is the (average) time that each server needs to complete a service request; it's referred to as $mst most of the time below.

INTERFACE

EXPORT

None by default. Following functions can be imported at once via the ":all" keyword.

FUNCTIONS FOR WAIT PROBABILITY

$wprob = wait_probability($traffic, $servers);

Evaluate the probability that a call will have to wait in the queue because all servers are busy.

$servers = servers_waitprob($traffic, $wait_probability)

Evaluate the needed number of servers to handle $traffic Erlangs with a wait probability not greater than $wait_probability.

$traffic = traffic_waitprob($servers, $wait_probability, $prec);

Evaluate the maximum traffic that can be handled with $servers without having a wait probability for any request that is beyond the given value. The calculation is performed until the iteration process shows variations below $prec, which is optional and defaults to $Math::Telephony::ErlangB::default_precision.

FUNCTIONS FOR MAXIMUM WAIT TIME PROBABILITY

$mwprob = maxtime_probability($traffic, $servers, $mst, $maxtime);

Evaluate the probability that any given service request will be handled within the given maximum time.

$servers = servers_maxtime($traffic, $maxtime_probability, $mst, $maxtime);

Evaluate the needed number of servers given the $traffic in erlang, $maxtime_probability, i.e. the probability that any given request will be served in no more than $maxtime seconds, and $mst, which represents the mean service time for any given request.

$traffic = traffic_maxtime($servers, $maxtime_probability, $mst, $maxtime, $prec);

Evaluate the maximum traffic that can be handled with $servers, with $maxtime_probability that the any given request will be handled within $maxtime. Parameter $mst represents the average time needed to serve a request.

You can optionally specify a $prec precision for calculations, otherwise the precision will default to $Math::Telephony::ErlangB::precision.

$mst = service_time_maxtime($traffic, $servers, $maxt_prob, $maxtime);

Evaluate the mean service time required when other parameters are fixed.

$mst = service_time2_maxtime($frequency, $servers, $maxt_prob, $maxtime);

Evaluate the mean service time required when other parameters are fixed.

my $maxtime = max_time_maxtime($traffic, $servers, $maxt_prob, $mst);

Evaluate the maximum time required to process a request with a probability of $maxt_prob.

FUNCTIONS FOR AVERAGE WAIT TIME

$awtime = average_wait_time($traffic, $servers, $mst);

Evaluate the average waiting time, i.e. average time spent inside the queue by the generic request.

$servers = servers_waittime($traffic, $average_wait_time, $mst);

Evaluate the needed number of servers to serve the given $traffic with an average wait time in queue not exceeding $average_wait_time for each request. $mst is the mean service time.

$traffic = traffic_waittime($servers, $average_wait_time, $mst, $prec);

Evaluate the maximum traffic that can be handled with $servers, where the average wait time does not exceed $average_wait_time. $mst is the mean service time.

You can optionally specify a $prec precision for calculations, otherwise the precision will default to $Math::Telephony::ErlangB::precision.

$mst = service_time_waittime($traffic, $servers, $awt);

Evaluate the mean service time for $servers being offered $traffic, assuming that the average wait time in queue is $awt.

$mst = service_time2_waittime($frequency, $servers, $awt);

Evaluate the mean service time for $servers loaded with requests wich occur with $frequency, assuming that the average wait time in queue is $awt.

DIAGNOSTICS

At the moment, the various functions return undef when invoked with invalid parameters. In the future there could be a switch to a more exception-oriented interface.

CONFIGURATION AND ENVIRONMENT

Math::Telephony::ErlangC requires no configuration files or environment variables.

DEPENDENCIES

This module depends on the following non-standard modules:

-

version

-

Math::Telephony::ErlangB

INCOMPATIBILITIES

None reported.

BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests through http://rt.cpan.org/

The servers() aggregated function isn't implemented yet.

AUTHOR

Flavio Poletti <flavio [at] polettix [dot] it>

LICENCE AND COPYRIGHT

Copyright (c) 2007, Flavio Poletti <flavio [at] polettix [dot] it>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic and perlgpl.

Questo modulo è software libero: potete ridistribuirlo e/o modificarlo negli stessi termini di Perl stesso. Vedete anche perlartistic e perlgpl.

DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

NEGAZIONE DELLA GARANZIA

Poiché questo software viene dato con una licenza gratuita, non c'è alcuna garanzia associata ad esso, ai fini e per quanto permesso dalle leggi applicabili. A meno di quanto possa essere specificato altrove, il proprietario e detentore del copyright fornisce questo software "così com'è" senza garanzia di alcun tipo, sia essa espressa o implicita, includendo fra l'altro (senza però limitarsi a questo) eventuali garanzie implicite di commerciabilità e adeguatezza per uno scopo particolare. L'intero rischio riguardo alla qualità ed alle prestazioni di questo software rimane a voi. Se il software dovesse dimostrarsi difettoso, vi assumete tutte le responsabilità ed i costi per tutti i necessari servizi, riparazioni o correzioni.

In nessun caso, a meno che ciò non sia richiesto dalle leggi vigenti o sia regolato da un accordo scritto, alcuno dei detentori del diritto di copyright, o qualunque altra parte che possa modificare, o redistribuire questo software così come consentito dalla licenza di cui sopra, potrà essere considerato responsabile nei vostri confronti per danni, ivi inclusi danni generali, speciali, incidentali o conseguenziali, derivanti dall'utilizzo o dall'incapacità di utilizzo di questo software. Ciò include, a puro titolo di esempio e senza limitarsi ad essi, la perdita di dati, l'alterazione involontaria o indesiderata di dati, le perdite sostenute da voi o da terze parti o un fallimento del software ad operare con un qualsivoglia altro software. Tale negazione di garanzia rimane in essere anche se i dententori del copyright, o qualsiasi altra parte, è stata avvisata della possibilità di tali danneggiamenti.

Se decidete di utilizzare questo software, lo fate a vostro rischio e pericolo. Se pensate che i termini di questa negazione di garanzia non si confacciano alle vostre esigenze, o al vostro modo di considerare un software, o ancora al modo in cui avete sempre trattato software di terze parti, non usatelo. Se lo usate, accettate espressamente questa negazione di garanzia e la piena responsabilità per qualsiasi tipo di danno, di qualsiasi natura, possa derivarne.