st1=: 3 : 0
i=. 1+(,~y) [EMAIL PROTECTED] #saaty_scale
b=. >/~i.y
((b*i) + |:b*i+#saaty_scale) { 1,(,%) saaty_scale
)
ts 'st 200'
0.0278371 2.09798e6
ts 'st1 200'
0.0155319 2.42886e6
Faster by a factor of 1.8 but more space by factor of 1.2.
----- Original Message -----
From: "Tarmo Veskioja" <[EMAIL PROTECTED]>
To: "Programming forum" <[email protected]>
Sent: Thursday, March 02, 2006 9:15 AM
Subject: Re: [Jprogramming] LAPACK question: principal eigenvector
It would be interesting to compare the timings on random Saaty matrices:
saaty_scale =: \:~ }. (,%)~ >:i.9
str =: 13 : '( =/~ i.#y.) + (y.*bd ) + |: (bd=. >/~ i.#y.) * %y.'
saaty_rand =: 13 : '(y. , y.) $ saaty_scale {~ ? (#saaty_scale) #~ *: y.'
st =: 13 : 'str saaty_rand y.' NB. st 4
ts 'm25 =: st 25'
0.000256178 33792
ts '(%+/) power m25'
0.00129039 7936
ts 'weigh_exact m25'
0.00268665 75520
ts 'm200 =: st 200'
0.0300049 2.09818e6
ts '(%+/) power m200'
0.0370592 30784
ts 'weigh_exact m200'
0.598927 4.1961e6
I can see now that my solution is inferior. Thanks! Although I have yet
to study the 'power' to fully understand it.
Also, is it possible to speed up the generation of random matrices (st)?
That would prove useful when calculating mean random consistency index,
which is needed for computing a (relative) consistency ratio.
I think the original relative consistency ratios were computed on 10000
random matrices up to size 10. I have computed it on 1000000 matrices up
to size 10. One comparative study has been done here:
A Note on the Computation of the Mean Random Consistency Index of the
Analytic Hierarchy Process (Ahp)
http://www.springerlink.com/app/home/contribution.asp?wasp=f9a08c1c17334b8e826c96ffe09a2dbe&referrer=parent&backto=issue,2,5;journal
,47,55;linkingpublicationresults,1:100341,1
For complete matrices the precomputed ratios are OK, but for incomplete
matrices one usually has to do it on the fly.
John Randall wrote:
>Here is a slightly more comprehensible form of the power method code I
>posted yesterday. It will correctly calculate the principal eigenvectors
>in Coyle's paper.
>
>mp=:+/ . *
>normalize=:%(>./@:|)
>iterate=:normalize@:mp
>init=:[: ? # # 0:
>power=:13 : 'y.&iterate^:_ init y.'
>
>rod=. >(1,(%3),%9);(3,1,%3);9 3 1 NB. "Replication of detail", p. 7
>
> (%+/) power rod
>0.0769231 0.230769 0.692308
>
>0.077 0.231 0.692 NB. Coyle
>
>
>Tarmo Veskioja wrote:
>
>
>>I can reproduce Coyle's results (see 'm weigh_iter 5') if I use the
>>first iteration of finding the right eigenvector - this has been the
>>tradition in AHP, at least in the early days.
>>
>>
>
>Interesting. Is this because of technical limitations or a philosophical
>perspective?
>
>
I think it was not so much because of technical limitations but of human
limitations - the calculation of only the first iteration is simple and
computationally feasible to do without a computer and almost any
layperson can do it in Excel. Using MMULT function (or VBA macro) in
Excel for matrix multiplication is already advanced stuff. And the added
precision seemed insignificant compared to possible misjudgements on the
Saaty scale.
>
>
>>There are ongoing discussions between using inexact vs exact weights and
>>between using left or right eigenvectors. Saaty prefers right
>>eigenvector. If the pairwise comparisons have been made by people, then
>>the differences (exact / inexact, left/right) are usually so small that
>>the results are more sensitive to subjective assessments.
>>
>>
>>
>
>Whether you should be looking at left or right eigenvectors depends
>basically on whether you think of your matrices multiplying on the left or
>right. In any case, the left eigenvalues of A are the right eigenvalues
>of |:A, so you don't need a separate method.
>
>
Exactly. I think Saaty also had some other considerations to favor the
right eigenvector, but I will have to look for those articles.
Bill's idea of a J Wiki for AHP is cool!
Tarmo
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm