fabes 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ before_install:
7
+ - gem install bundler --pre
data/CHANGELOG ADDED
@@ -0,0 +1,12 @@
1
+ === Fabes ===
2
+
3
+ = v0.0.1
4
+ - Improved the alternative selection, now using a basic 'epsilon-greedy' multi-armed bandit
5
+ # http://stevehanov.ca/blog/index.php?id=132
6
+ # http://www.cs.mcgill.ca/~vkules/bandits.pdf
7
+ # http://www.cs.nyu.edu/~mohri/pub/bandit.pdf
8
+
9
+ - Advancing with tests, though some love is needed
10
+
11
+ = v0.0.0
12
+ - Basic implementation of the system, based on existing gems: split, vanity, some rails insights :)
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'redis'
4
+ gem 'sinatra'
5
+
6
+ group :development do
7
+ gem "mocha"
8
+ gem "pry"
9
+ gem "shoulda", ">= 0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "> 1.0.0"
12
+ gem "jeweler", ">= 1.8.4"
13
+ gem "simplecov", ">= 0"
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,56 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ coderay (1.0.7)
5
+ git (1.2.5)
6
+ jeweler (1.8.4)
7
+ bundler (~> 1.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ rdoc
11
+ json (1.7.3)
12
+ metaclass (0.0.1)
13
+ method_source (0.8)
14
+ mocha (0.12.0)
15
+ metaclass (~> 0.0.1)
16
+ multi_json (1.3.6)
17
+ pry (0.9.10)
18
+ coderay (~> 1.0.5)
19
+ method_source (~> 0.8)
20
+ slop (~> 3.3.1)
21
+ rack (1.4.1)
22
+ rack-protection (1.2.0)
23
+ rack
24
+ rake (0.9.2.2)
25
+ rdoc (3.12)
26
+ json (~> 1.4)
27
+ redis (3.0.1)
28
+ shoulda (3.0.1)
29
+ shoulda-context (~> 1.0.0)
30
+ shoulda-matchers (~> 1.0.0)
31
+ shoulda-context (1.0.0)
32
+ shoulda-matchers (1.0.0)
33
+ simplecov (0.6.4)
34
+ multi_json (~> 1.0)
35
+ simplecov-html (~> 0.5.3)
36
+ simplecov-html (0.5.3)
37
+ sinatra (1.3.2)
38
+ rack (~> 1.3, >= 1.3.6)
39
+ rack-protection (~> 1.2)
40
+ tilt (~> 1.3, >= 1.3.3)
41
+ slop (3.3.2)
42
+ tilt (1.3.3)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ bundler (> 1.0.0)
49
+ jeweler (>= 1.8.4)
50
+ mocha
51
+ pry
52
+ rdoc (~> 3.12)
53
+ redis
54
+ shoulda
55
+ simplecov
56
+ sinatra
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Alejandro Andres
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,18 @@
1
+ = fabes {<img src="https://secure.travis-ci.org/fuzzyalej/fabes.png" />}[http://travis-ci.org/fuzzyalej/fabes] {<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/fuzzyalej/fabes]
2
+
3
+ Fabes is an a/b testing gem
4
+
5
+ == Contributing to fabes
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Sources
16
+
17
+ * {split gem}[https://github.com/andrew/split/]
18
+ * {vanity gem}[https://github.com/assaf/vanity/]
data/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "fabes"
18
+ gem.homepage = "http://github.com/fuzzyalej/fabes"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Fabulous A/B Experimenting System}
21
+ gem.description = %Q{Fabes is an A/B testing system for your ruby projects}
22
+ gem.email = "fuzzy.alej@gmail.com"
23
+ gem.authors = ["Alejandro Andres"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ task :default => :test
36
+
37
+ require 'rdoc/task'
38
+ Rake::RDocTask.new do |rdoc|
39
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
+
41
+ rdoc.rdoc_dir = 'rdoc'
42
+ rdoc.title = "fabes #{version}"
43
+ rdoc.rdoc_files.include('README*')
44
+ rdoc.rdoc_files.include('lib/**/*.rb')
45
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/fabes.gemspec ADDED
@@ -0,0 +1,93 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "fabes"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Alejandro Andres"]
12
+ s.date = "2012-07-23"
13
+ s.description = "Fabes is an A/B testing system for your ruby projects"
14
+ s.email = "fuzzy.alej@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".travis.yml",
22
+ "CHANGELOG",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "fabes.gemspec",
30
+ "lib/fabes.rb",
31
+ "lib/fabes/admin.rb",
32
+ "lib/fabes/admin/public/application.css",
33
+ "lib/fabes/admin/views/index.haml",
34
+ "lib/fabes/admin/views/layout.haml",
35
+ "lib/fabes/alternative.rb",
36
+ "lib/fabes/configuration.rb",
37
+ "lib/fabes/connection_adapters/abstract_adapter.rb",
38
+ "lib/fabes/connection_adapters/redis_adapter.rb",
39
+ "lib/fabes/connection_handling.rb",
40
+ "lib/fabes/experiment.rb",
41
+ "lib/fabes/helper.rb",
42
+ "lib/fabes/utils.rb",
43
+ "test/helper.rb",
44
+ "test/test_abstract_adapter.rb",
45
+ "test/test_alternative.rb",
46
+ "test/test_configuration.rb",
47
+ "test/test_experiment.rb",
48
+ "test/test_helper.rb",
49
+ "test/test_redis_adapter.rb"
50
+ ]
51
+ s.homepage = "http://github.com/fuzzyalej/fabes"
52
+ s.licenses = ["MIT"]
53
+ s.require_paths = ["lib"]
54
+ s.rubygems_version = "1.8.24"
55
+ s.summary = "Fabulous A/B Experimenting System"
56
+
57
+ if s.respond_to? :specification_version then
58
+ s.specification_version = 3
59
+
60
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
61
+ s.add_runtime_dependency(%q<redis>, [">= 0"])
62
+ s.add_runtime_dependency(%q<sinatra>, [">= 0"])
63
+ s.add_development_dependency(%q<mocha>, [">= 0"])
64
+ s.add_development_dependency(%q<pry>, [">= 0"])
65
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
66
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
67
+ s.add_development_dependency(%q<bundler>, ["> 1.0.0"])
68
+ s.add_development_dependency(%q<jeweler>, [">= 1.8.4"])
69
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
70
+ else
71
+ s.add_dependency(%q<redis>, [">= 0"])
72
+ s.add_dependency(%q<sinatra>, [">= 0"])
73
+ s.add_dependency(%q<mocha>, [">= 0"])
74
+ s.add_dependency(%q<pry>, [">= 0"])
75
+ s.add_dependency(%q<shoulda>, [">= 0"])
76
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
77
+ s.add_dependency(%q<bundler>, ["> 1.0.0"])
78
+ s.add_dependency(%q<jeweler>, [">= 1.8.4"])
79
+ s.add_dependency(%q<simplecov>, [">= 0"])
80
+ end
81
+ else
82
+ s.add_dependency(%q<redis>, [">= 0"])
83
+ s.add_dependency(%q<sinatra>, [">= 0"])
84
+ s.add_dependency(%q<mocha>, [">= 0"])
85
+ s.add_dependency(%q<pry>, [">= 0"])
86
+ s.add_dependency(%q<shoulda>, [">= 0"])
87
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
88
+ s.add_dependency(%q<bundler>, ["> 1.0.0"])
89
+ s.add_dependency(%q<jeweler>, [">= 1.8.4"])
90
+ s.add_dependency(%q<simplecov>, [">= 0"])
91
+ end
92
+ end
93
+
@@ -0,0 +1,59 @@
1
+ body {
2
+ font: normal 12px auto Verdana, Arial, Helvetica, sans-serif;
3
+ color: #FDF3E7;
4
+ background: #3B3738;
5
+ }
6
+
7
+ a {
8
+ color: #7E8F7C;
9
+ }
10
+
11
+ h2 {
12
+ font-size: 20px;
13
+ text-align: left;
14
+ margin-top: 50px;
15
+ }
16
+
17
+ h2.span {
18
+ font-size: 16px;
19
+ }
20
+
21
+ table {
22
+ width: 700px;
23
+ padding: 0px;
24
+ margin: 0px;
25
+ }
26
+
27
+ th {
28
+ border-right: 1px solid #A64C2E;
29
+ border-bottom: 1px solid #A64C2E;
30
+ border-top: 1px solid #D53500;
31
+ border-left: 1px solid #D53500;
32
+ letter-spacing: 2px;
33
+ text-transform: uppercase;
34
+ text-align: center;
35
+ font-size: 13px;
36
+ padding: 10px;
37
+ background: #C63D0F;
38
+ color: #FFFFFF;
39
+ text-shadow: 1px 1px 1px black;
40
+ }
41
+
42
+ td {
43
+ border-right: 1px solid #C1DAD7;
44
+ border-bottom: 1px solid #C1DAD7;
45
+ background: #FDF3E7;
46
+ padding: 6px;
47
+ color: #3B3738;
48
+ font-size: 13px;
49
+ }
50
+
51
+ #container {
52
+ margin: 50px auto;
53
+ text-align: center;
54
+ overflow: hidden;
55
+ }
56
+
57
+ #content {
58
+ display: inline-block;
59
+ }
@@ -0,0 +1,17 @@
1
+ .experiments
2
+ -@experiments.each do |experiment|
3
+ -name = experiment.name
4
+ .experiment
5
+ %h2= "Experiment: #{name.capitalize}"
6
+ %table{id: name.first, cellspacing: 0, summary: "Data for experiment '#{name}'"}
7
+ %tr
8
+ %th{scope: 'col'} Alternative
9
+ %th{scope: 'col'} Participants
10
+ %th{scope: 'col'} Hits
11
+ %th{scope: 'col'} Weight
12
+ - experiment.alternatives.each do |alternative|
13
+ %tr
14
+ %td{title: alternative.id}= alternative.payload
15
+ %td= alternative.participants
16
+ %td= alternative.hits
17
+ %td= alternative.weight
@@ -0,0 +1,11 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title= @title || 'Fabes Administration Panel'
5
+ %link{href: request.env['SCRIPT_NAME'] + '/application.css', media: 'all', rel: 'stylesheet', type: 'text/css'}
6
+ %body
7
+ #container
8
+ #header
9
+ .logo
10
+ #content
11
+ =yield
@@ -0,0 +1,15 @@
1
+ require 'sinatra'
2
+
3
+ module Fabes
4
+ class Admin < Sinatra::Base
5
+ dir = File.dirname File.expand_path __FILE__
6
+ set :views, dir + '/admin/views'
7
+ set :public_folder, dir + '/admin/public'
8
+ set :static, true
9
+
10
+ get '/' do
11
+ @experiments = Fabes::Experiment.all
12
+ haml :index
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,54 @@
1
+ module Fabes
2
+ class Alternative
3
+ #TODO: move some of these to attr_reader
4
+ attr_accessor :weight, :payload, :participants, :hits, :id
5
+
6
+ def initialize(payload)
7
+ @id = generate_id
8
+ @weight = 0.0
9
+ @participants = 0
10
+ @hits = 0
11
+ @payload = payload
12
+ end
13
+
14
+ def increment_participants!
15
+ @participants = @participants.to_i + 1
16
+ Fabes.db.increment_participants!(id)
17
+ end
18
+
19
+ def increment_hits!
20
+ @hits = @hits.to_i + 1
21
+ Fabes.db.increment_hits!(id)
22
+ end
23
+
24
+ def update_weight
25
+ @weight = calculate_weight
26
+ Fabes.db.update_weight(id, @weight)
27
+ end
28
+
29
+ def self.create_from(data)
30
+ alternative = new(data.delete :payload)
31
+ data.each do |k, v|
32
+ alternative.send "#{k}=", v
33
+ end
34
+ alternative
35
+ rescue
36
+ raise 'Error creating an alternative'
37
+ end
38
+
39
+ def weight
40
+ @weight.to_f
41
+ end
42
+
43
+ private
44
+
45
+ def generate_id
46
+ #TODO: maybe this could be easier with a redis counter?
47
+ rand(36**10).to_s(36)
48
+ end
49
+
50
+ def calculate_weight
51
+ @hits.to_f / @participants.to_f
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,17 @@
1
+ module Fabes
2
+ class Configuration
3
+ attr_accessor :adapter, :db
4
+
5
+ def initialize
6
+ @adapter = 'redis'
7
+ @db = nil
8
+ end
9
+
10
+ def use(db_config)
11
+ @adapter = db_config[:adapter].to_s
12
+ @db = db_config[:db] || ENV['FABES_DB_URL'] || ENV['REDISTOGO_URL']
13
+ rescue => e
14
+ raise "Bad 'use' config: #{e.message}"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,29 @@
1
+ module Fabes
2
+ module ConnectionHandling
3
+ extend self
4
+
5
+ def establish_connection(db, adapter)
6
+ #TODO: automagically parse db a la rails
7
+ #REF: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_handling.rb
8
+ adapter_method = "#{adapter}_connection"
9
+ send adapter_method, db
10
+ rescue => e
11
+ raise "Could not find #{adapter} adapter!"
12
+ end
13
+
14
+ def parse_connection_url(url)
15
+ end
16
+ end
17
+
18
+ module ConnectionAdapters
19
+ class AbstractAdapter
20
+ def clear!;end
21
+ def save_experiment(experiment);end
22
+ def find_experiment(name);end
23
+ def increment_participants!(id);end
24
+ def increment_hits!(id);end
25
+ def update_weight(id, weight);end
26
+ def all_experiments;end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,109 @@
1
+ module Fabes
2
+ module ConnectionHandling
3
+ def self.redis_connection(db)
4
+ require 'redis'
5
+ db ||= ::Redis.new
6
+ ConnectionAdapters::RedisAdapter.new(db)
7
+ end
8
+ end
9
+
10
+ module ConnectionAdapters
11
+ class RedisAdapter < AbstractAdapter
12
+ def initialize(redis)
13
+ @redis = redis
14
+ end
15
+
16
+ def clear!
17
+ @redis.flushdb
18
+ end
19
+
20
+ def save_experiment(experiment)
21
+ add_to_current_experiments(experiment.name)
22
+ save_experiment_data(experiment)
23
+ rescue
24
+ raise "Unable to save experiment"
25
+ end
26
+
27
+ def find_experiment(name)
28
+ if @redis.sismember "fabes:experiments", name
29
+ load_experiment(name)
30
+ else
31
+ nil
32
+ end
33
+ end
34
+
35
+ def increment_hits!(id)
36
+ @redis.hincrby "fabes:alternatives_pool:#{id}", 'hits', 1
37
+ end
38
+
39
+ def increment_participants!(id)
40
+ @redis.hincrby "fabes:alternatives_pool:#{id}", 'participants', 1
41
+ end
42
+
43
+ def update_weight(id, weight)
44
+ @redis.hset "fabes:alternatives_pool:#{id}", 'weight', weight
45
+ end
46
+
47
+ def all_experiments
48
+ experiments = Array.new
49
+ names = get_all_experiment_names
50
+ names.each do |name|
51
+ experiments << load_experiment(name)
52
+ end
53
+ experiments
54
+ end
55
+
56
+ private
57
+
58
+ def get_all_experiment_names
59
+ @redis.smembers 'fabes:experiments'
60
+ end
61
+
62
+ def add_to_current_experiments(name)
63
+ @redis.sadd "fabes:experiments", name
64
+ end
65
+
66
+ def save_experiment_data(experiment)
67
+ save_alternatives(experiment.name, experiment.alternatives)
68
+ end
69
+
70
+ def save_alternatives(base, alternatives)
71
+ alternatives.each do |alt|
72
+ add_to_alternatives(base, alt.id)
73
+ data = Array.new
74
+ alt.instance_variables.each do |var|
75
+ data << var.slice(1..-1) << alt.instance_variable_get(var)
76
+ end
77
+ @redis.hmset "fabes:alternatives_pool:#{alt.id}", *data
78
+ end
79
+ end
80
+
81
+ def add_to_alternatives(base, alternative)
82
+ @redis.rpush "fabes:alternatives:#{base}", alternative
83
+ end
84
+
85
+ def load_experiment(name)
86
+ experiment = Experiment.new(name)
87
+ alternatives = load_alternatives(name)
88
+ alternatives.each do |alternative|
89
+ experiment.add_alternative(alternative)
90
+ end
91
+ experiment
92
+ end
93
+
94
+ def load_alternatives(base)
95
+ alternatives = Array.new
96
+ ids = @redis.lrange "fabes:alternatives:#{base}", 0, -1
97
+ ids.each do |id|
98
+ alternatives.push load_alternative(id)
99
+ end
100
+ alternatives
101
+ end
102
+
103
+ def load_alternative(id)
104
+ data = @redis.hgetall "fabes:alternatives_pool:#{id}"
105
+ Alternative.create_from data
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,2 @@
1
+ require 'fabes/connection_adapters/abstract_adapter'
2
+ require 'fabes/connection_adapters/redis_adapter'
@@ -0,0 +1,66 @@
1
+ module Fabes
2
+ class Experiment
3
+ attr_accessor :name, :description, :alternatives
4
+
5
+ def initialize(name, *alternatives)
6
+ @name = name
7
+ @alternatives = alternatives.map do |alternative|
8
+ Fabes::Alternative.new alternative
9
+ end
10
+ save
11
+ end
12
+
13
+ def self.find_or_create(name, *alternatives)
14
+ #TODO: What happens if same experiment but different alternatives?
15
+ #TODO: check the validation of alternatives
16
+ experiment = find(name) or new(name, *alternatives)
17
+ end
18
+
19
+ def self.find(name)
20
+ Fabes.db.find_experiment name
21
+ end
22
+
23
+ def self.all
24
+ Fabes.db.all_experiments
25
+ end
26
+
27
+ #TODO: make this an option and add different alternative selection algorithms
28
+ def select_alternative!
29
+ if exploration?
30
+ random_alternative
31
+ else #exploitation
32
+ heaviest_alternative
33
+ end
34
+ end
35
+
36
+ def find_alternative(id)
37
+ @alternatives.select {|alternative| alternative.id == id }.first or control
38
+ end
39
+
40
+ def save
41
+ Fabes.db.save_experiment(self)
42
+ end
43
+
44
+ def add_alternative(alternative)
45
+ @alternatives.push alternative
46
+ end
47
+
48
+ def control
49
+ @alternatives.first
50
+ end
51
+
52
+ private
53
+
54
+ def exploration?
55
+ rand() < 0.2 # 20% of times
56
+ end
57
+
58
+ def random_alternative
59
+ @alternatives.shuffle.first
60
+ end
61
+
62
+ def heaviest_alternative
63
+ @alternatives.max {|alternative| alternative.weight}
64
+ end
65
+ end
66
+ end