erlang_c_calculator 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/MIT-License.md +19 -0
- data/README.md +19 -0
- data/Rakefile +2 -0
- data/erlang_c_calculator.gemspec +24 -0
- data/lib/erlang_c/version.rb +3 -0
- data/lib/erlang_c_calculator.rb +39 -0
- data/lib/math.rb +15 -0
- data/spec/math_spec.rb +34 -0
- metadata +82 -0
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use ree@erlang
|
data/Gemfile
ADDED
data/MIT-License.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2010 by Chandu Tennety, Janova Software
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
## What does it do?
|
2
|
+
Given the average call arrival rate per second, the average service time and acceptable wait time, calculate the load, Erlang C probability that a caller waits, and the number of agents needed to service the call station.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
gem install erlang_c_calculator
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
require 'rubygems'
|
9
|
+
require 'erlang_c_calculator'
|
10
|
+
|
11
|
+
e = ErlangC::Calculator.new(0.01, 300, 20)
|
12
|
+
e.traffic_intensity # => 3.0
|
13
|
+
e.agents_needed # => 6
|
14
|
+
|
15
|
+
## Dependencies
|
16
|
+
ErlangC Calculator does not have any dependencies.
|
17
|
+
|
18
|
+
## References
|
19
|
+
This gem uses material from the online book ["Call Center Mathematics"](http://www.math.vu.nl/~koole/ccmath/book.pdf) by Professor [Ger Koole](http://www.math.vu.nl/~koole/) of the [VU University of Amsterdam](http://www.vu.nl/en/)'s [Department of Mathematics](http://www.math.vu.nl/). More tools and research are available at the [CCMath website](http://www.ccmath.com).
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "erlang_c/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "erlang_c_calculator"
|
7
|
+
s.version = ErlangC::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Chandu Tennety"]
|
10
|
+
s.email = ["chandu.tennety@janova.us"]
|
11
|
+
s.homepage = "http://rubygems.org/gems/erlang_c_calculator"
|
12
|
+
s.summary = %q{Calculate the various terms associated with the Erlang C formula.}
|
13
|
+
s.description = %q{Given the average call arrival rate per second, the average
|
14
|
+
service time and acceptable wait time, calculate the load,
|
15
|
+
Erlang C probability that a caller waits, and the number of
|
16
|
+
agents needed to service the call station.}
|
17
|
+
|
18
|
+
s.rubyforge_project = "erlang_c_calculator"
|
19
|
+
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'math'
|
2
|
+
|
3
|
+
module ErlangC
|
4
|
+
class Calculator
|
5
|
+
include Math
|
6
|
+
|
7
|
+
attr_accessor :arrival_rate, :serv_time, :wait_time
|
8
|
+
|
9
|
+
def initialize(arrival_rate, serv_time, wait_time = 30)
|
10
|
+
@arrival_rate, @serv_time, @wait_time = arrival_rate, serv_time, wait_time
|
11
|
+
end
|
12
|
+
|
13
|
+
def traffic_intensity
|
14
|
+
(arrival_rate * serv_time).to_f
|
15
|
+
end
|
16
|
+
|
17
|
+
def erlang_c_probability(m)
|
18
|
+
u = traffic_intensity
|
19
|
+
|
20
|
+
return 1 if u > m
|
21
|
+
|
22
|
+
product = (0..m).inject(1){|prod, j| (prod * j/u) + 1}
|
23
|
+
1.0/((product * (m - u)/u) + 1)
|
24
|
+
end
|
25
|
+
|
26
|
+
def average_wait(num_agents)
|
27
|
+
(erlang_c_probability(num_agents) * serv_time) / (num_agents - traffic_intensity)
|
28
|
+
end
|
29
|
+
|
30
|
+
def agents_needed
|
31
|
+
agents = (traffic_intensity + 1).to_i
|
32
|
+
while average_wait(agents) >= wait_time
|
33
|
+
agents += 1
|
34
|
+
end
|
35
|
+
agents
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
data/lib/math.rb
ADDED
data/spec/math_spec.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec'
|
2
|
+
require 'lib/erlang_c_calculator'
|
3
|
+
require 'lib/math'
|
4
|
+
|
5
|
+
module ErlangC
|
6
|
+
describe Math do
|
7
|
+
before do
|
8
|
+
class TestClass
|
9
|
+
include Math
|
10
|
+
end
|
11
|
+
|
12
|
+
@test = TestClass.new
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#factorial" do
|
16
|
+
it "for 5 should be 120" do
|
17
|
+
@test.factorial(5).should == 120
|
18
|
+
end
|
19
|
+
|
20
|
+
it "for 1 should be 1" do
|
21
|
+
@test.factorial(1).should == 1
|
22
|
+
end
|
23
|
+
|
24
|
+
it "for 0 should be 1" do
|
25
|
+
@test.factorial(0).should == 1
|
26
|
+
end
|
27
|
+
|
28
|
+
it "for 2 should be 2" do
|
29
|
+
@test.factorial(2).should == 2
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: erlang_c_calculator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Chandu Tennety
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-02-01 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: |-
|
23
|
+
Given the average call arrival rate per second, the average
|
24
|
+
service time and acceptable wait time, calculate the load,
|
25
|
+
Erlang C probability that a caller waits, and the number of
|
26
|
+
agents needed to service the call station.
|
27
|
+
email:
|
28
|
+
- chandu.tennety@janova.us
|
29
|
+
executables: []
|
30
|
+
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files: []
|
34
|
+
|
35
|
+
files:
|
36
|
+
- .gitignore
|
37
|
+
- .rvmrc
|
38
|
+
- Gemfile
|
39
|
+
- MIT-License.md
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- erlang_c_calculator.gemspec
|
43
|
+
- lib/erlang_c/version.rb
|
44
|
+
- lib/erlang_c_calculator.rb
|
45
|
+
- lib/math.rb
|
46
|
+
- spec/math_spec.rb
|
47
|
+
has_rdoc: true
|
48
|
+
homepage: http://rubygems.org/gems/erlang_c_calculator
|
49
|
+
licenses: []
|
50
|
+
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
requirements: []
|
75
|
+
|
76
|
+
rubyforge_project: erlang_c_calculator
|
77
|
+
rubygems_version: 1.5.0
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: Calculate the various terms associated with the Erlang C formula.
|
81
|
+
test_files:
|
82
|
+
- spec/math_spec.rb
|