Class: AHProcess::AHPMatrix
- Inherits:
-
Object
- Object
- AHProcess::AHPMatrix
- Extended by:
- Forwardable
- Includes:
- Comparable
- Defined in:
- lib/ahprocess/ahp_matrix.rb
Instance Attribute Summary collapse
-
#matrix ⇒ Object
readonly
Returns the value of attribute matrix.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #column_sum ⇒ Object
- #consistency_index ⇒ Object
- #consistency_ratio(random_consistency_index) ⇒ Object
-
#initialize(matrix = []) ⇒ AHPMatrix
constructor
A new instance of AHPMatrix.
- #lambda_max ⇒ Object
- #normalize ⇒ Object
- #preference_vector ⇒ Object
Constructor Details
#initialize(matrix = []) ⇒ AHPMatrix
Returns a new instance of AHPMatrix.
11 12 13 |
# File 'lib/ahprocess/ahp_matrix.rb', line 11 def initialize(matrix = []) @matrix = Matrix[*matrix] end |
Instance Attribute Details
#matrix ⇒ Object (readonly)
Returns the value of attribute matrix.
9 10 11 |
# File 'lib/ahprocess/ahp_matrix.rb', line 9 def matrix @matrix end |
Instance Method Details
#<=>(other) ⇒ Object
15 16 17 |
# File 'lib/ahprocess/ahp_matrix.rb', line 15 def <=>(other) @matrix <=> other.matrix end |
#column_sum ⇒ Object
27 28 29 |
# File 'lib/ahprocess/ahp_matrix.rb', line 27 def column_sum Vector[*(column_vectors.map { |v| v.inject(:+) })] end |
#consistency_index ⇒ Object
35 36 37 |
# File 'lib/ahprocess/ahp_matrix.rb', line 35 def consistency_index (lambda_max - row_count) / (row_count - 1) end |
#consistency_ratio(random_consistency_index) ⇒ Object
39 40 41 |
# File 'lib/ahprocess/ahp_matrix.rb', line 39 def consistency_ratio(random_consistency_index) consistency_index / random_consistency_index end |
#lambda_max ⇒ Object
31 32 33 |
# File 'lib/ahprocess/ahp_matrix.rb', line 31 def lambda_max preference_vector.inner_product column_sum end |
#normalize ⇒ Object
19 20 21 |
# File 'lib/ahprocess/ahp_matrix.rb', line 19 def normalize AHPMatrix.new(Matrix.columns(column_vectors.map { |cv| cv / cv.inject(:+).to_f })) end |
#preference_vector ⇒ Object
23 24 25 |
# File 'lib/ahprocess/ahp_matrix.rb', line 23 def preference_vector Vector[*(normalize.row_vectors.map { |rv| rv.inject(:+).to_f / rv.size })] end |