Sure, here is one of the structs in question:
@with_kw struct Roster{T1 <: SVector{MAXPLAYERS, String15},
T2 <: SVector{MAXPLAYERS, Int16}}
# Player Info
Name :: T1 = @SVector fill(String15(""), MAXPLAYERS)
Age :: T1 = @SVector fill(String15(""), MAXPLAYERS)
Nat :: T1 = @SVector fill(String15(""), MAXPLAYERS)
Prs :: T1 = @SVector fill(String15(""), MAXPLAYERS)
# Ratings
St :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
Tk :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
Ps :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
Sh :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
Sm :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
Ag :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
# Abilities
KAb :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
TAb :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
PAb :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
SAb :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
# Stats
Gam :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
Sav :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
Ktk :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
Kps :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
Sht :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
Gls :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
Ass :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
DP :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
Inj :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
Sus :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
Fit :: T2 = @SVector fill(Int16(0), MAXPLAYERS)
end
And one of the functions (using the solution recommended above):
function calc_metric(baseline, sims)
nteams = length(baseline.lg)
nreps = length(sims)
pl_fields = (:Gam, :Sav, :Ktk, :Kps, :Sht, :Gls, :Ass, :DP)
tm_fields = (:Pl, :W, :D, :L, :GF, :GA, :GD, :Pts)
sumSq = 0
for sim in sims
# Player Stats
for i in eachindex(pl_fields)
for j in eachindex(baseline.lg)
x = getfield_unroll(baseline.lg[j].roster, pl_fields[i])
y = getfield_unroll(sim.lg[j].roster, pl_fields[i])
sumSq += sum((Int64.(x - y)).^2)
end
end
# Team Stats
for i in eachindex(tm_fields)
for j in eachindex(baseline.lg_table)
x = getfield_unroll(baseline.lg_table[j], tm_fields[i])
y = getfield_unroll(sim.lg_table[j], tm_fields[i])
sumSq += sum((Int64.(x - y))^2)
end
end
end
# Refers to RMSE per team (not total number of variables)
RMSE = sqrt(sumSq/(nteams*nreps))
return RMSE
end