Class: AHProcess::AnalyticHierarchyProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/ahprocess/analytic_hierarchy_process.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(decision_matricies, criteria_matrix = [], no_decisions = 1) ⇒ AnalyticHierarchyProcess

Returns a new instance of AnalyticHierarchyProcess.



7
8
9
10
11
# File 'lib/ahprocess/analytic_hierarchy_process.rb', line 7

def initialize(decision_matricies, criteria_matrix = [], no_decisions = 1)
  @no_decisions       = no_decisions
  @criteria_matrix    = AHPMatrix.new(criteria_matrix)
  @decision_matricies = decision_matricies.map { |matrix| AHPMatrix.new(matrix) }
end

Instance Attribute Details

#criteria_matrixObject (readonly)

Returns the value of attribute criteria_matrix.



5
6
7
# File 'lib/ahprocess/analytic_hierarchy_process.rb', line 5

def criteria_matrix
  @criteria_matrix
end

#decision_matriciesObject (readonly)

Returns the value of attribute decision_matricies.



5
6
7
# File 'lib/ahprocess/analytic_hierarchy_process.rb', line 5

def decision_matricies
  @decision_matricies
end

#no_decisionsObject (readonly)

Returns the value of attribute no_decisions.



5
6
7
# File 'lib/ahprocess/analytic_hierarchy_process.rb', line 5

def no_decisions
  @no_decisions
end

Instance Method Details

#consistency_ratios(random_consistency_index) ⇒ Object



24
25
26
27
# File 'lib/ahprocess/analytic_hierarchy_process.rb', line 24

def consistency_ratios(random_consistency_index)
  return [decision_matricies.map { |pv| pv.consistency_ratio(random_consistency_index) }] if criteria_matrix.empty?
  [decision_matricies.map { |pv| pv.consistency_ratio(random_consistency_index) }, criteria_matrix.consistency_ratio(random_consistency_index)]
end

#decideObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/ahprocess/analytic_hierarchy_process.rb', line 13

def decide
  return decision_matricies.map(&:preference_vector).first.to_a if criteria_matrix.empty?

  decision_preference_vectors = decision_matricies.map(&:preference_vector)
  criteria_preference_vector  = criteria_matrix.preference_vector

  (0...no_decisions).map do |decision_index|
    criteria_preference_vector.inner_product(decision_preference_vectors.map { |pv| pv[decision_index] })
  end
end