![]() |
Re: OPR Formula
1 Attachment(s)
Quote:
And I found the algorithm somewhere online, I don't remember where from. Sorry. I'll attach it. |
Re: OPR Formula
Quote:
[A][x]=[b] for [x], where [A] is a symmetric nonnegative-definite matrix, [x] is the vector of OPR's, and [b] is the vector of alliance score sums. If you factor [A] using Cholesky, you get [L] such that [L][L]T=[A], so you can substitute that for [A] to get [L][L]T[x]=[b] ... and that is easily solved in two steps: substitute [y] for [L]T[x] to get [L][y]=[b] and solve for [y] using forward substitution, then once [y] is known solve [L]T[x]=[y] for [x] using back substitution. [EDIT] I hope you get this working. I'm quite curious to see how fast it runs in an Excel VBA macro. The whole process -- Cholesky factorization, forward substitution and backward substitution to get OPR, then forward substitution and backward substitution again to get CCWM -- takes a bit over 12 seconds for a 2053x2053 [A] matrix on my machine using a 32-bit Delphi console app. [/EDIT] [EDIT2] Instead of the lower triangular matrix [L], some Cholesky implementations give give an upper triangular [U] such that [U]T[U]=[A]. The solution process is similar. The algorithm you posted produces [L]. [/EDIT2] |
Re: OPR Formula
Quote:
I have attached the matrices that I used for A, L, U, B, and Y, and the results for OPR are in X. Thanks |
Re: OPR Formula
1 Attachment(s)
Quote:
Why did you use both [L] and [U]? It's one or the other. Attached ZIP file contains test matrix [A] and test vector [b]. Run your code on that test matrix and test vector, and compare your results to the [L] matrix and the [y] and [x] vectors (also in the ZIP file) to locate where the problem is. |
Re: OPR Formula
Quote:
Quote:
Quote:
|
Re: OPR Formula
1 Attachment(s)
Quote:
See if you can generate those from the raw data. Data is fixed-field; columns are: red1 red2 red3 blu1 blu2 blu3 redAllianceScore blueAllianceScore There are different ways to populate the [A] matrix and [b] vector as the data file is being read. This is how I did it: The data file is read and processed in a single pass. For each line of the data file, as the team numbers are being read, each new team number encountered is assigned a TeamID, starting with 1 and incrementing by 1 with each new team. The TeamID is used as the index into the [A] matrix and [b] vector. |
Re: OPR Formula
Quote:
|
Re: OPR Formula
Quote:
|
Re: OPR Formula
Quote:
|
Re: OPR Formula
Quote:
[M] has dimensions 2m x n, where m is the # of matches in the raw data file and n is the number of teams. [s] has dimensions n x 1. As you read the data file, for each new team# you encounter assign a sequential TeamID. Use that TeamID (instead of the team#) as the index into [M] and [s]. For each line (match) read from the raw data file, do the following: row+=1; M[row,red1TeamID]=1; M[row,red2TeamID]=1; M[row,red3TeamID]=1; s[row]=redAllianceScore; row+=1; M[row,blu1TeamID]=1; M[row,blu2TeamID]=1; M[row,blu3TeamID]=1; s[row]=bluAllianceScore; When you are done, you will have a set of overdetermined linear equations [M][x]≈[s] If you multiply both sides by [M]T, you get [M]T[M][x]=[M]T[s] The above are called the normal equations (of the overdetermined linear system), and solving these normal equations for [x] gives the least-squares solution. Notice that [M]T[M] is [A] and [M]T[s] is [b]. So this approach takes more storage space and more computing, but it might be less confusing to code. |
Re: OPR Formula
2 Attachment(s)
Quote:
Quote:
Quote:
Also attached is the spreadsheet from earlier I had neglected to attach by accident, twice. |
Re: OPR Formula
Quote:
Also create an array named TeamNum[]. Size it to be bigger than the expected total number of teams (in the data file you are analyzing). As you read each TeamNumber from the data file, do the following logic: if (TeamID[TeamNumber]==0) {_id++; TeamID[TeamNumber]=_id; TeamNum[_id]=TeamNumber;} The above arrays are then used to lookup a team's ID if you know the team's NUMBER, or to lookup a team's NUMBER if you know the team's ID. |
Re: OPR Formula
1 Attachment(s)
Quote:
rawdata.txt your raw data file A.csv the [A] matrix of the Normal Equations [A][x]=[b] b.csv the [b] vector L.csv the Cholesky lower-triangular factorization of [A] y.csv the solution to [L][y]=[b] x.csv the solution to [L]T[x]=[y] stats.txt the analysis report |
Re: OPR Formula
1 Attachment(s)
I've been following this and other OPR discussions for awhile, and I thought I'd share my Excel template for calculating it on the fly (requires an Internet connection).
I use mmult(minverse(play count matrix), total score vector). |
Re: OPR Formula
Quote:
|
| All times are GMT -5. The time now is 04:17. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi