Class: OPRCalc::ScoreSet
- Inherits:
-
Object
- Object
- OPRCalc::ScoreSet
- Defined in:
- lib/opr-calc/score_set.rb
Instance Attribute Summary collapse
-
#ablue ⇒ Object
Returns the value of attribute ablue.
-
#ared ⇒ Object
Returns the value of attribute ared.
-
#scoreblue ⇒ Object
Returns the value of attribute scoreblue.
-
#scorered ⇒ Object
Returns the value of attribute scorered.
Instance Method Summary collapse
-
#ccwm(recalc = false) ⇒ Object
Calculated contribution to winning margin: the average amount of points that a team contributes to their alliance’s winning margin.
-
#dpr(recalc = false) ⇒ Object
Defensive power rating: the average amount of points that a team lets the other alliance score.
-
#initialize(ared, ablue, scorered, scoreblue) ⇒ ScoreSet
constructor
A new instance of ScoreSet.
-
#opr(recalc = false) ⇒ Object
Offensive power rating: the average amount of points that a team contributes to their alliance’s score.
- #opr_calculate(a, score) ⇒ Object
Constructor Details
#initialize(ared, ablue, scorered, scoreblue) ⇒ ScoreSet
Returns a new instance of ScoreSet.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/opr-calc/score_set.rb', line 43 def initialize(ared, ablue, scorered, scoreblue) raise TypeError, 'ared must be a Matrix' unless ared.is_a? Matrix raise TypeError, 'ablue must be a Matrix' unless ablue.is_a? Matrix raise TypeError, 'scorered must be a Matrix' unless scorered.is_a? Matrix raise TypeError, 'scoreblue must be a Matrix' unless scoreblue.is_a? Matrix @ared = ared @ablue = ablue @scorered = scorered @scoreblue = scoreblue end |
Instance Attribute Details
#ablue ⇒ Object
Returns the value of attribute ablue.
21 22 23 |
# File 'lib/opr-calc/score_set.rb', line 21 def ablue @ablue end |
#ared ⇒ Object
Returns the value of attribute ared.
21 22 23 |
# File 'lib/opr-calc/score_set.rb', line 21 def ared @ared end |
#scoreblue ⇒ Object
Returns the value of attribute scoreblue.
21 22 23 |
# File 'lib/opr-calc/score_set.rb', line 21 def scoreblue @scoreblue end |
#scorered ⇒ Object
Returns the value of attribute scorered.
21 22 23 |
# File 'lib/opr-calc/score_set.rb', line 21 def scorered @scorered end |
Instance Method Details
#ccwm(recalc = false) ⇒ Object
Calculated contribution to winning margin: the average amount of points that a team contributes to their alliance’s winning margin.
This value is high for a good team.
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/opr-calc/score_set.rb', line 191 def ccwm(recalc = false) if !@ccwm || recalc || @ccwm_recalc a = alliance_smooshey @ared, @ablue red_wm = Matrix.build(@scorered.row_size, @scorered.column_size) do |row, column| @scorered[row, column] - @scoreblue[row, column] end blue_wm = Matrix.build(@scoreblue.row_size, @scoreblue.column_size) do |row, column| @scoreblue[row, column] - @scorered[row, column] end score = alliance_smooshey red_wm, blue_wm @ccwm = opr_calculate a, score @ccwm_recalc = false end @ccwm end |
#dpr(recalc = false) ⇒ Object
Defensive power rating: the average amount of points that a team lets the other alliance score.
This is low for a good team.
172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/opr-calc/score_set.rb', line 172 def dpr(recalc = false) if !@dpr || recalc || @dpr_recalc a = alliance_smooshey @ared, @ablue # scoreblue and scorered are intentionally # swapped; that's how dpr works. score = alliance_smooshey @scoreblue, @scorered @dpr = opr_calculate a, score @dpr_recalc = false end @dpr end |
#opr(recalc = false) ⇒ Object
Offensive power rating: the average amount of points that a team contributes to their alliance’s score.
This is high for a good team.
156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/opr-calc/score_set.rb', line 156 def opr(recalc = false) if !@opr || recalc || @opr_recalc a = alliance_smooshey @ared, @ablue score = alliance_smooshey @scorered, @scoreblue @opr = opr_calculate a, score @opr_recalc = false end @opr end |
#opr_calculate(a, score) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/opr-calc/score_set.rb', line 139 def opr_calculate(a, score) p = a.t * a s = a.t * score l = p.cholesky_factor # l.output # l.t.output y = forward_substitute l, s back_substitute l.t, y end |