"""DOTS, Wilks2 and IPF GL: one powerlifting total scored by the three formulas in use, DOTS (Konertz, BVDK 2019), Wilks2 (Wilks 2020) and IPF GL points (IPF 2020, classic or equipped three-lift coefficients). Coefficients and clamps as in OpenPowerlifting's implementation. Inputs: sex (male or female, default male), bodyweight_kg (30 to 250, default 83), total_kg (0.1 to 2000, default 500), equipped (True for single- or multi-ply, default False). Returns: dotsScore, wilksScore, glScore (points), bwRatio (total over bodyweight). mysi, DOTS, Wilks2 and IPF GL points, mysi.dev/dots-wilks-gl-combined, version 1, changed 2026-12-04. MIT. """ import math def _dots_wilks_gl_combined_num(name, value, low, high): if isinstance(value, bool) or not isinstance(value, (int, float)) or not low <= value <= high: raise ValueError(f"{name} must be a number from {low} to {high}") return float(value) def dots_wilks_gl_combined(sex="male", bodyweight_kg=83, total_kg=500, equipped=False): if sex not in ("male", "female"): raise ValueError("sex must be one of: male, female") if not isinstance(equipped, bool): raise ValueError("equipped must be true or false") bw = _dots_wilks_gl_combined_num("bodyweight_kg", bodyweight_kg, 30, 250) total = _dots_wilks_gl_combined_num("total_kg", total_kg, 0.1, 2000) male = sex == "male" # DOTS: a·x^4 + b·x^3 + c·x^2 + d·x + e, bodyweight held at 40-210 (men), 40-150 (women) k = ((-0.000001093, 0.0007391293, -0.1918759221, 24.0900756, -307.75076) if male else (-0.0000010706, 0.0005158568, -0.1126655495, 13.6175032, -57.96288)) x = min(210 if male else 150, max(40, bw)) dots = total * 500 / (k[0] * x ** 4 + k[1] * x ** 3 + k[2] * x ** 2 + k[3] * x + k[4]) # Wilks2 (2020): a + b·x + ... + f·x^5, bodyweight held at 40-200.95 (men), 40-150.95 (women) w = ((47.4617885411949, 8.47206137941125, 0.073694103462609, -0.00139583381094385, 7.07665973070743e-6, -1.20804336482315e-8) if male else (-125.425539779509, 13.7121941940668, -0.0330725063103405, -0.0010504000506583, 9.38773881462799e-6, -2.3334613884954e-8)) x = min(200.95 if male else 150.95, max(40, bw)) wilks = total * 600 / sum(c * x ** i for i, c in enumerate(w)) # IPF GL (2020) Table 1, three-lift total: 100 / (A − B·e^(−C·bodyweight)). 0 under 35 kg as # OpenPowerlifting goodlift.rs; the IPF defines the formula from 40 kg (men), 35 kg (women) a, b, c = {(True, False): (1199.72839, 1025.18162, 0.00921), (True, True): (1236.25115, 1449.21864, 0.01644), (False, False): (610.32796, 1045.59282, 0.03048), (False, True): (758.63878, 949.31382, 0.02435)}[(male, equipped)] gl = 0.0 if bw < 35 else total * max(0.0, 100 / (a - b * math.exp(-c * bw))) return {"dotsScore": dots, "wilksScore": wilks, "glScore": gl, "bwRatio": total / bw} DOTS_WILKS_GL_COMBINED_CASES = [ ({"sex": "female", "bodyweight_kg": 63, "total_kg": 395, "equipped": False}, {"dotsScore": 424.828, "wilksScore": 505.056, "glScore": 86.4194}), ({"sex": "male", "bodyweight_kg": 92.04, "total_kg": 1035, "equipped": True}, {"glScore": 112.85}), ({"sex": "male", "bodyweight_kg": 80, "total_kg": 1000, "equipped": False}, {"wilksScore": 819.1}), ] def dots_wilks_gl_combined_check(tolerance=1e-3): for given, want in DOTS_WILKS_GL_COMBINED_CASES: got = dots_wilks_gl_combined(**given) for name, value in want.items(): close = abs(got[name] - value) <= tolerance * max(1, abs(value)) assert close, (name, got[name], value) return "ok" if __name__ == "__main__": import json, sys dots_wilks_gl_combined_check() given = dict(a.split("=", 1) for a in sys.argv[1:] if "=" in a) js = lambda v: v.lstrip("-")[:1].isdigit() or v[:1] in '[{".' or v in ("true", "false", "null") given = {k: json.loads(v) if js(v) else v for k, v in given.items()} if given: print(json.dumps(dots_wilks_gl_combined(**given)))