Class: Ropt::CooperativeGames::ShapleyValue
- Inherits:
-
Object
- Object
- Ropt::CooperativeGames::ShapleyValue
- Defined in:
- lib/ropt/cooperative_games/shapley_value.rb
Overview
class for calculating of Shapley Value something super-additive convex cooperative game
Constant Summary collapse
- DEFAULT_VALUE_OF_COALITION =
0
Instance Attribute Summary collapse
-
#coalitions ⇒ Object
Returns the value of attribute coalitions.
-
#coefficients ⇒ Object
Returns the value of attribute coefficients.
-
#number_gamers ⇒ Object
Returns the value of attribute number_gamers.
-
#round ⇒ Object
Returns the value of attribute round.
-
#validator ⇒ Object
Returns the value of attribute validator.
Instance Method Summary collapse
-
#initialize(coalitions, number_gamers, round = 3) ⇒ ShapleyValue
constructor
A new instance of ShapleyValue.
- #solve ⇒ Object
Constructor Details
#initialize(coalitions, number_gamers, round = 3) ⇒ ShapleyValue
10 11 12 13 14 15 16 |
# File 'lib/ropt/cooperative_games/shapley_value.rb', line 10 def initialize(coalitions, number_gamers, round = 3) @coalitions = coalitions @number_gamers = number_gamers @coefficients = Ropt::CooperativeGames::CoalitionsCoefficients.new(number_gamers).call @validator = Ropt::CooperativeGames::Validator.new @round = round end |
Instance Attribute Details
#coalitions ⇒ Object
Returns the value of attribute coalitions.
7 8 9 |
# File 'lib/ropt/cooperative_games/shapley_value.rb', line 7 def coalitions @coalitions end |
#coefficients ⇒ Object
Returns the value of attribute coefficients.
7 8 9 |
# File 'lib/ropt/cooperative_games/shapley_value.rb', line 7 def coefficients @coefficients end |
#number_gamers ⇒ Object
Returns the value of attribute number_gamers.
7 8 9 |
# File 'lib/ropt/cooperative_games/shapley_value.rb', line 7 def number_gamers @number_gamers end |
#round ⇒ Object
Returns the value of attribute round.
7 8 9 |
# File 'lib/ropt/cooperative_games/shapley_value.rb', line 7 def round @round end |
#validator ⇒ Object
Returns the value of attribute validator.
7 8 9 |
# File 'lib/ropt/cooperative_games/shapley_value.rb', line 7 def validator @validator end |
Instance Method Details
#solve ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ropt/cooperative_games/shapley_value.rb', line 18 def solve validator.validate_arguments(coefficients, coalitions, number_gamers) singletons = singleton_coalitions validator.validate_coalitions_consistency(coalitions, singletons.keys) vector = calculate_vector_shapley(singletons) validator.validate_result(coalitions, singletons.keys, vector) vector end |