Track pentanomial dist. in tests.
By default, all tests will do this. If you are migrating an existing database, it would be advised to run the following code in the django shell... >>> from OpenBench.models import Test >>> Test.objects.all().update(use_tri=True, use_penta=False)
This commit is contained in:
1 parent
7bf3c54249
commit
8e5afa9a2e
3 files changed
+77
-57
No files matched your search
+30
-10
@@ -65,13 +65,24 @@ class Result(Model):
|
||||
|
||||
test = ForeignKey('Test', PROTECT, related_name='test')
|
||||
machine = ForeignKey('Machine', PROTECT, related_name='machine')
|
||||
updated = DateTimeField(auto_now=True)
|
||||
|
||||
# Trinomial Distributions
|
||||
losses = IntegerField(default=0)
|
||||
draws = IntegerField(default=0)
|
||||
wins = IntegerField(default=0)
|
||||
|
||||
# Pentanomial Distributions
|
||||
LL = IntegerField(default=0)
|
||||
LD = IntegerField(default=0)
|
||||
DD = IntegerField(default=0)
|
||||
DW = IntegerField(default=0)
|
||||
WW = IntegerField(default=0)
|
||||
|
||||
# Overall collection of Results
|
||||
games = IntegerField(default=0)
|
||||
wins = IntegerField(default=0)
|
||||
losses = IntegerField(default=0)
|
||||
draws = IntegerField(default=0)
|
||||
crashes = IntegerField(default=0)
|
||||
timeloss = IntegerField(default=0)
|
||||
updated = DateTimeField(auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
return '{0} {1}'.format(self.test.dev.name, self.machine.__str__())
|
||||
@@ -123,12 +134,20 @@ class Test(Model):
|
||||
upperllr = FloatField(default=0.0) # SPRT
|
||||
max_games = IntegerField(default=0) # GAMES
|
||||
|
||||
# Summary of all associated result objects
|
||||
games = IntegerField(default=0)
|
||||
wins = IntegerField(default=0)
|
||||
draws = IntegerField(default=0)
|
||||
losses = IntegerField(default=0)
|
||||
error = BooleanField(default=False)
|
||||
# Collection of all individual Result() objects
|
||||
games = IntegerField(default=0) # Overall
|
||||
losses = IntegerField(default=0) # Trinomial
|
||||
draws = IntegerField(default=0) # Trinomial
|
||||
wins = IntegerField(default=0) # Trinomial
|
||||
LL = IntegerField(default=0) # Pentanomial
|
||||
LD = IntegerField(default=0) # Pentanomial
|
||||
DD = IntegerField(default=0) # Pentanomial
|
||||
DW = IntegerField(default=0) # Pentanomial
|
||||
WW = IntegerField(default=0) # Pentanomial
|
||||
|
||||
# Switching all future tests to Pentanomial
|
||||
use_tri = BooleanField(default=False)
|
||||
use_penta = BooleanField(default=True)
|
||||
|
||||
# All status flags associated with the test
|
||||
passed = BooleanField(default=False)
|
||||
@@ -137,6 +156,7 @@ class Test(Model):
|
||||
deleted = BooleanField(default=False)
|
||||
approved = BooleanField(default=False)
|
||||
awaiting = BooleanField(default=False)
|
||||
error = BooleanField(default=False)
|
||||
|
||||
# Datetime house keeping for meta data
|
||||
creation = DateTimeField(auto_now_add=True)
|
||||
|
||||
@@ -58,62 +58,50 @@ def gitDiffLink(test):
|
||||
|
||||
def shortStatBlock(test):
|
||||
|
||||
tri_line = 'Games: %d W: %d L: %d D: %d' % (test.games, test.wins, test.losses, test.draws)
|
||||
penta_line = 'Pntml(0-2): %d, %d, %d, %d, %d' % (test.LL, test.LD, test.DD, test.DW, test.WW)
|
||||
|
||||
if test.test_mode == "SPRT":
|
||||
|
||||
currentllr = twoDigitPrecision(test.currentllr)
|
||||
lowerllr = twoDigitPrecision(test.lowerllr)
|
||||
upperllr = twoDigitPrecision(test.upperllr)
|
||||
elolower = twoDigitPrecision(test.elolower)
|
||||
eloupper = twoDigitPrecision(test.eloupper)
|
||||
|
||||
llrbounds = '({}, {}) '.format(lowerllr, upperllr)
|
||||
|
||||
return 'LLR: {0} {1}[{2}, {3}]\n'.format(currentllr, llrbounds, elolower, eloupper) \
|
||||
+ 'Games: {0} W: {1} L: {2} D: {3}'.format(test.games, test.wins, test.losses, test.draws)
|
||||
top_line = 'LLR: %0.2f (%0.2f, %0.2f) [%0.2f, %0.2f]' % (
|
||||
test.currentllr, test.lowerllr, test.upperllr, test.elolower, test.eloupper)
|
||||
|
||||
if test.test_mode == "GAMES":
|
||||
|
||||
lower, elo, upper = OpenBench.stats.ELO(test.wins, test.losses, test.draws)
|
||||
error = max(upper - elo, elo - lower)
|
||||
top_line = 'Elo: %0.2f +- %0.2f (95%%) [N=%d]' % (elo, max(upper - elo, elo - lower), test.max_games)
|
||||
|
||||
elo = twoDigitPrecision(elo)
|
||||
error = twoDigitPrecision(error)
|
||||
if test.use_penta:
|
||||
return '\n'.join([top_line, tri_line, penta_line])
|
||||
|
||||
return 'Elo: {0} +- {1} (95%) [N={2}]\n'.format(elo, error, test.max_games) \
|
||||
+ 'Games: {0} W: {1} L: {2} D: {3}'.format(test.games, test.wins, test.losses, test.draws)
|
||||
if test.use_tri:
|
||||
return '\n'.join([top_line, tri_line])
|
||||
|
||||
return 'Test uses neither Trinomoal nor Pentanomial'
|
||||
|
||||
def longStatBlock(test):
|
||||
|
||||
threads = OpenBench.utils.extract_option(test.dev_options, 'Threads')
|
||||
hash = OpenBench.utils.extract_option(test.dev_options, 'Hash')
|
||||
threads = int(OpenBench.utils.extract_option(test.dev_options, 'Threads'))
|
||||
hash = int(OpenBench.utils.extract_option(test.dev_options, 'Hash'))
|
||||
timecontrol = test.dev_time_control + ['s', '']['=' in test.dev_time_control]
|
||||
test_type = 'SPRT' if test.test_mode is 'SPRT' else 'Conf'
|
||||
|
||||
lower, elo, upper = OpenBench.stats.ELO(test.wins, test.losses, test.draws)
|
||||
error = max(upper - elo, elo - lower)
|
||||
|
||||
elo = twoDigitPrecision(elo)
|
||||
error = twoDigitPrecision(error)
|
||||
elo_line = 'Elo | %0.2f +- %0.2f (95%%)' % (elo, max(upper - elo, elo - lower))
|
||||
conf_line = '%-5s | %s Threads=%d Hash=%dMB' % (test_type, timecontrol, threads, hash)
|
||||
|
||||
if test.test_mode == 'SPRT':
|
||||
tri_line = 'Games | N: %d W: %d L: %d D: %d' % (test.games, test.wins, test.losses, test.draws)
|
||||
penta_line = 'Penta | [%d, %d, %d, %d, %d]' % (test.LL, test.LD, test.DD, test.DW, test.WW)
|
||||
|
||||
lowerllr = twoDigitPrecision(test.lowerllr)
|
||||
currentllr = twoDigitPrecision(test.currentllr)
|
||||
upperllr = twoDigitPrecision(test.upperllr)
|
||||
elolower = twoDigitPrecision(test.elolower)
|
||||
eloupper = twoDigitPrecision(test.eloupper)
|
||||
timecontrol = test.dev_time_control + ['s', '']['=' in test.dev_time_control]
|
||||
llr_line = 'LLR | %0.2f (%0.2f, %0.2f) [%0.2f, %0.2f]' % (
|
||||
test.currentllr, test.lowerllr, test.upperllr, test.elolower, test.eloupper)
|
||||
|
||||
return 'ELO | {0} +- {1} (95%)\n'.format(elo, error) \
|
||||
+ 'SPRT | {0} Threads={1} Hash={2}MB\n'.format(timecontrol, threads, hash) \
|
||||
+ 'LLR | {0} ({1}, {2}) [{3}, {4}]\n'.format(currentllr, lowerllr, upperllr, elolower, eloupper) \
|
||||
+ 'GAMES | N: {0} W: {1} L: {2} D: {3}'.format(test.games, test.wins, test.losses, test.draws)
|
||||
if test.use_penta:
|
||||
return '\n'.join([elo_line, conf_line, llr_line, tri_line, penta_line])
|
||||
|
||||
if test.test_mode == 'GAMES':
|
||||
if test.use_tri:
|
||||
return '\n'.join([elo_line, conf_line, llr_line, tri_line])
|
||||
|
||||
timecontrol = test.dev_time_control + ['s', '']['=' in test.dev_time_control]
|
||||
|
||||
return 'ELO | {0} +- {1} (95%)\n'.format(elo, error) \
|
||||
+ 'CONF | {0} Threads={1} Hash={2}MB\n'.format(timecontrol, threads, hash) \
|
||||
+ 'GAMES | N: {0} W: {1} L: {2} D: {3}'.format(test.games, test.wins, test.losses, test.draws)
|
||||
return 'Test uses neither Trinomoal nor Pentanomial'
|
||||
|
||||
def testResultColour(test):
|
||||
|
||||
|
||||
+20
-8
@@ -833,8 +833,7 @@ def update_test(request, machine):
|
||||
games = losses + draws + wins
|
||||
|
||||
# Pentanomial Implementation
|
||||
# ll, dl, dd, dw, ww = map(int, request.POST['pentanomial'].split())
|
||||
# games = ll + dl + dd + dw + ww
|
||||
LL, LD, DD, DW, WW = map(int, request.POST['pentanomial'].split())
|
||||
|
||||
with transaction.atomic():
|
||||
|
||||
@@ -842,10 +841,15 @@ def update_test(request, machine):
|
||||
if test.finished or test.deleted:
|
||||
return { 'stop' : True }
|
||||
|
||||
test.losses += losses
|
||||
test.losses += losses # Trinomial
|
||||
test.draws += draws
|
||||
test.wins += wins
|
||||
test.games += games
|
||||
test.LL += LL # Pentanomial
|
||||
test.LD += LD
|
||||
test.DD += DD
|
||||
test.DW += DW
|
||||
test.WW += WW
|
||||
test.games += games # Overall
|
||||
|
||||
test.error = test.error or has_error
|
||||
|
||||
@@ -871,10 +875,18 @@ def update_test(request, machine):
|
||||
|
||||
# Update Result object; No risk from concurrent access
|
||||
Result.objects.filter(id=result_id).update(
|
||||
games = F('games') + games, wins = F('wins' ) + wins,
|
||||
losses = F('losses') + losses, draws = F('draws' ) + draws,
|
||||
crashes = F('crashes') + crashes, timeloss = F('timeloss') + timelosses,
|
||||
updated=timezone.now()
|
||||
games = F('games' ) + games,
|
||||
losses = F('losses' ) + losses,
|
||||
draws = F('draws' ) + draws,
|
||||
wins = F('wins' ) + wins,
|
||||
LL = F('LL' ) + LL,
|
||||
LD = F('LD' ) + LD,
|
||||
DD = F('DD' ) + DD,
|
||||
DW = F('DW' ) + DW,
|
||||
WW = F('WW' ) + WW,
|
||||
crashes = F('crashes' ) + crashes,
|
||||
timeloss = F('timeloss') + timelosses,
|
||||
updated = timezone.now()
|
||||
)
|
||||
|
||||
# Update Profile object; No risk from concurrent access
|
||||
|
||||
Reference in new issue
Block a user