Bill Harris <[EMAIL PROTECTED]> writes:

> I've attached the crude but documented file I've got right now.  At
> least it has the process documented.  Feel free to make use of (or
> improve) it, as you see fit.

Oops; I meant to inline it.  Second try:

......................................................................

NB. A program to apply Saaty's method in an interactive fashion.
NB. according to the link in http://actifeld.com/A%20Possible%20Method.doc

NB. 2006-03-02
NB. John Randall developed the basic algorithm on the J Programming Forum
NB. Raul Miller, Tarmo Veskioja, Devon McCormick, and Roger Hui contributed to 
the dialog
NB. Bill Harris put a few other pieces on.

NB. The steps:
NB. Define the Client Preference Matrix as described on p. 6 of that article
NB. Run (%+/)power on that matrix to find the principle eigenvector.
NB. Run cr to calculate the Consistency Ratio; if it is much in excess of
NB.   0.1, the judgments used to create the CPM are probably too random.
NB. Create preference matrices for each of the alternatives on each of 
NB.   the dimensions used in the CPM.  Calculate the principal eigenvectors
NB.   and consistency ratio for each.
NB. Create the Option Performance Matrix by assembling all the principal 
NB.   eigenvectors for the preference matrices.
NB. Multiply OPM time CVV to get the Value For Money vector.  

NB. Calculate principal eigenvectors of the matrix cpm by
NB.   (%+/) power cpm

NB. Calculate the principal eigenvalue of the matrix cpm by
NB.   ev cpm

NB. Calculate the consistency ratio of the matrix cpm by
NB.   cr cpm 

NB. The VFM shows in each position the relative preference the decision-maker
NB.   has shown for that alternative: OPM * CVV = VFM

NB. If the Option Performance Matrix is
NB. opm=: |:a,b,c,:d  
NB. where a, b, c, and d are the principal eigenvectors of each option matrix

NB. then 
NB. (%/+)opm mp cpm 
NB. is the Value For Money (VFM) matrix, giving the relative 
NB. values of each alternative


mp=:+/ . *
normalize=:%(>./@:|)
iterate=:normalize@:mp
init=:[: ? # # 0:
power=:13 : 'y.&iterate^:_ init y.'

NB. If the array a is an n x n matrix, calculate n:
n =: #

NB. Calculate the principal eigenvalue
NB. Postmultiply the current principal eigenvector by the matrix
NB. Divide that vector (unnormalized) by the principal eigenvector
NB. See p. 258 of Kincaid and Cheney's Numerical Analysis 3rd edition
cureigenvec =: (%+/) @: power
neweigenvec =: mp cureigenvec
ev=: [: {. neweigenvec % cureigenvec

NB. Calculate the consistency ratio
cr =: (ev - n) % <: @: n



NB. Test matrices from Geoff Coyle's paper referenced above:

NB. peigen s/b 0.232,0.402,0.061,0.305, cr of 0.055
cpm=: >(1,(%3),5, 1);(3,1,5,1);((%5),(%5),1,(%5));(1,1,5,1)

NB. peigen s/b 0.751,0.178,0.071 w/ cr of 0.072
exp=: >(1,5,9);((%5),1,3);((%9),(%3),1) NB. Expenses

NB. peigen s/b 0.480,0.406,0.114 w/ cr of 0.026
und=: >(1,1,5);(1,1,3);((%5),(%3),1) NB. "Understandability

NB. peigen s/b 0.077,0.231,0.692 w/ cr of 0
rod=: >(1,(%3),%9);(3,1,%3);9 3 1 NB. "Replication of detail", p. 7

NB. peigen s/b 0.066,0.615,0.319 w/ cr of 0
pod=: >(1,(%9),(%5));(9,1,2);(5,(%2),1) NB. Prediction of dynamics

......................................................................
-- 
Bill Harris                      http://facilitatedsystems.com/weblog/
Facilitated Systems                              Everett, WA 98208 USA
http://facilitatedsystems.com/                  phone: +1 425 337-5541

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to