Quote:
Originally Posted by Rachel Lim
I believe most of the time is taken up by looping through arrays, especially T while looking for unique teams and creating the A matrix.
|
There should be no looping involved.
Here's some pseudo-code which creates A, b, and T with one non-looping pass thru the 8column data
Code:
//one pass thru the 8col data;
//for each row do the following:
//populate the b column vector (alliance scores):
b[++ib]=rs; b[++ib]=bs;
//assign a unique Column Number to each team:
f1(r1); f1(r2); f1(r3); f1(b1); f1(b2); f1(b3);
//populate the A matrix:
row++;
A[row,aTeamCol[r1]]=1;
A[row,aTeamCol[r2]]=1;
A[row,aTeamCol[r3]]=1;
row++;
A[row,aTeamCol[b1]]=1;
A[row,aTeamCol[b2]]=1;
A[row,aTeamCol[b3]]=1;
function f1(n:word); //n is team number
if aTeamCol[n]==0 { Col++; aTeamCol[n]=Col; T[Col]=n }