Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
rrs
viewer
log-segmentation
Commits
31971f1b
Unverified
Commit
31971f1b
authored
Nov 19, 2022
by
Juon Kawakami
🥗
Browse files
init
parent
342fea6f
Changes
73
Show whitespace changes
Inline
Side-by-side
output/.gitkeep
0 → 100644
View file @
31971f1b
scripts/competition/evaluation/config.py
0 → 100755
View file @
31971f1b
all_teams
=
[
"RI1"
,
"MRL"
,
"CSU"
,
"AIT"
]
final_teams
=
[
"MRL"
,
"CSU"
,
"AIT"
]
team_names
=
{
# "BAS" : "Baseline (no agents)",
"CSU"
:
"CSU-Yunlu"
,
"MRL"
:
"MRL"
,
"RI1"
:
"Ri-one"
,
"AIT"
:
"AIT-Rescue"
}
setup
=
{
'name'
:
"setup day"
,
'shortname'
:
"setup"
,
'maps'
:
[
"kobe-test"
],
'teams'
:
all_teams
}
day1
=
{
'name'
:
"Preliminary Day 1"
,
'shortname'
:
"Day1"
,
'maps'
:
[
"vc1"
,
"joao1"
,
"berlin1"
,
"eindhoven1"
,
"mexico1"
],
'teams'
:
all_teams
,
# 'merge_with' : day1,
# 'highlight' : 8
}
day2
=
{
'name'
:
"Preliminary Day 2"
,
'shortname'
:
"Day2"
,
'maps'
:
[
"ny1"
,
"kobe1"
,
"sydney1"
,
"sakae1"
,
"paris1"
],
'teams'
:
all_teams
,
# 'merge_with' : day1,
# 'highlight' : 8
}
semi
=
{
'name'
:
"Semifinal"
,
'shortname'
:
"Semifinal"
,
'maps'
:
[
"vc2"
,
"berlin2"
,
"eindhoven2"
,
"istanbul1"
,
"sf1"
,
"ny2"
,
"paris2"
,
"kobe2"
],
'teams'
:
all_teams
,
'show_ranks'
:
3
}
final
=
{
'name'
:
"Finals"
,
'shortname'
:
"final"
,
'maps'
:
[
"montreal1"
,
"sf2"
,
"sydney2"
,
"berlin3"
,
"kobe3"
,
"sakae2"
,
"eindhoven3"
,
"paris3"
],
'teams'
:
final_teams
,
'show_ranks'
:
2
}
# final = {'name' : "Finals",
# 'shortname' : "final",
# 'maps' : ["Eindhoven1"],
# 'teams' : all_teams,
# 'merge_with' : day3,
# 'show_ranks' : 1}
rounds
=
[
day1
,
day2
,
semi
,
final
]
# semi_teams = ["RAK", "SBC", "POS", "IAM", "MRL", "RI1", "SEU", "RMA"]
# final_teams = ["POS", "IAM", "SEU", "RMA"]
# day1 = {'name' : "Preliminaries Day 1",
# 'shortname' : "Preliminary1",
# 'maps' : ["VC1", "Paris1", "Kobe1", "Berlin1", "Istanbul1"],
# 'teams' : all_teams}
# day2 = {'name' : "Preliminaries Day 2",
# 'shortname' : "Preliminary2",
# 'maps' : ["Kobe2", "Paris2", "Istanbul2", "Berlin2", "VC2"],
# 'teams' : all_teams
# 'merge_with' : day1
# 'highlight' : 8}
# semi = {'name' : "Semifinals",
# 'shortname' : "Semifinals",
# 'maps' : ["Kobe2", "Paris2", "Istanbul2", "Berlin2", "VC2"],
# 'teams' : semi_teams,
# 'highlight' : 4}
# final = {'name' : "Finals",
# 'shortname' : "Finals",
# 'maps' : ["Kobe2", "Paris2", "Istanbul2", "Berlin2", "VC2"],
# 'teams' : ["Paris5", "Berlin5", "Kobe4", "Istanbul5", "VC5"],
# 'show_ranks' : 3}
# rounds = [day1, day2, semi, final]
log_location
=
"../../logs/2022"
add_downloads
=
True
scripts/competition/evaluation/make_html.py
0 → 100755
View file @
31971f1b
#!/usr/bin/python
import
sys
,
os
,
stat
,
glob
import
config
all_teams
=
config
.
all_teams
team_names
=
config
.
team_names
template
=
"""
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
lang="en" xml:lang="en">
<head>
<title>Results for map %(mapname)s</title>
<style type="text/css">
body { font-family: sans-serif; }
table { border-collapse: collapse; }
.running { color:red; }
tr.first { background-color: #E9D44A; }
tr.second { background-color: #C8C8C8; }
tr.third { background-color: #C89D4C; }
div.init-map { float:left;
text-align:center; }
</style>
</head>
<body>
<h1>Results for %(mapname)s</h1>
%(map_download)s
<br clear="all" />
<div class="init-map"><a href="snapshot-init.png"><img src="snapshot-init-small.png" width="400" height="300" alt="Initial situation for %(mapname)s" /></a>
<br />
Initial score: %(init_score).2f</div>
<a href="plot-%(mapname)s.svg"><img src="plot-%(mapname)s.svg" width="400" height="300" alt="Plot of agent scores vs time for %(mapname)s" /></a>
<br clear="all" />
<br />
%(log_download)s
%(table)s
</body>
</html>
"""
class
TeamEntry
(
object
):
def
__init__
(
self
,
team
,
mapdata
):
self
.
id
=
team
self
.
name
=
team_names
[
team
]
self
.
map
=
mapdata
self
.
dir
=
os
.
path
.
join
(
self
.
map
.
path
,
team
)
self
.
running
=
True
self
.
init_score
=
None
self
.
final_score
=
0.0
self
.
last_score
=
0.0
self
.
scores
=
None
self
.
max_time
=
0
self
.
rank
=
-
1
self
.
jlog
=
None
self
.
full_log
=
None
if
self
.
valid
():
for
line
in
open
(
os
.
path
.
join
(
self
.
dir
,
"init-score.txt"
)):
self
.
init_score
=
float
(
line
.
strip
())
for
line
in
open
(
os
.
path
.
join
(
self
.
dir
,
"scores.txt"
)):
self
.
scores
=
[
float
(
s
)
for
s
in
line
.
split
()]
self
.
last_score
=
self
.
scores
[
-
1
]
try
:
for
line
in
open
(
os
.
path
.
join
(
self
.
dir
,
"final-score.txt"
)):
self
.
final_score
=
float
(
line
.
strip
())
self
.
running
=
False
except
:
pass
self
.
max_time
=
len
(
self
.
scores
)
-
1
try
:
self
.
full_log
=
self
.
get_logfile
(
self
.
map
.
mapname
)[
1
]
self
.
jlog
=
self
.
get_jlogfile
(
self
.
map
.
mapname
)[
1
]
except
:
pass
def
valid
(
self
):
if
not
os
.
path
.
exists
(
self
.
dir
):
return
False
return
True
def
get_logfile
(
self
,
mapdir
):
# files = glob.glob(os.path.join(mapdir, "*-%s*.gz" % self.name))
files
=
glob
.
glob
(
os
.
path
.
join
(
mapdir
,
"*-%s*.7z"
%
self
.
name
))
if
len
(
files
)
!=
1
:
#Can't identify team logfile
raise
KeyError
size
=
os
.
stat
(
files
[
0
])[
stat
.
ST_SIZE
]
return
(
size
,
files
[
0
])
def
get_jlogfile
(
self
,
mapdir
):
files
=
glob
.
glob
(
os
.
path
.
join
(
mapdir
,
"*-%s*.jlog.zip"
%
self
.
name
))
if
len
(
files
)
!=
1
:
#Can't identify team logfile
raise
KeyError
size
=
os
.
stat
(
files
[
0
])[
stat
.
ST_SIZE
]
return
(
size
,
files
[
0
])
def
get_screenshots
(
self
):
times
=
list
(
self
.
map
.
get_screenshot_timepoints
())
for
t
in
times
[:
-
1
]:
path
=
os
.
path
.
join
(
self
.
dir
,
"snapshot-%d.png"
%
t
)
tn_path
=
os
.
path
.
join
(
self
.
dir
,
"snapshot-%d-tn.jpg"
%
t
)
if
os
.
path
.
exists
(
path
)
and
t
<=
self
.
max_time
:
yield
(
t
,
path
,
tn_path
,
self
.
scores
[
t
])
else
:
yield
(
t
,
None
,
None
,
None
)
if
self
.
max_time
!=
self
.
map
.
turns
:
#final snapshot would not correspond to others - don't use it
yield
(
self
.
max_time
,
None
,
None
,
None
)
else
:
path
=
os
.
path
.
join
(
self
.
dir
,
"snapshot-final.png"
)
tn_path
=
os
.
path
.
join
(
self
.
dir
,
"snapshot-final-tn.jpg"
)
yield
(
self
.
max_time
,
path
,
tn_path
,
self
.
scores
[
self
.
max_time
])
class
MapData
(
object
):
def
__init__
(
self
,
mapname
,
teams
=
None
):
self
.
mapname
=
mapname
self
.
teamdict
=
None
self
.
entries
=
[]
self
.
init_score
=
-
1
self
.
turns
=
-
1
self
.
path
=
None
self
.
started
=
False
if
os
.
path
.
exists
(
"%s-eval"
%
mapname
):
self
.
path
=
"%s-eval"
%
mapname
elif
os
.
path
.
exists
(
os
.
path
.
join
(
mapname
,
"plot-%s.svg"
%
mapname
)):
self
.
path
=
mapname
elif
os
.
path
.
exists
(
"plot-%s.svg"
%
mapname
):
self
.
path
=
"."
else
:
print
>>
sys
.
stderr
,
"Couldn't find eval directory for map %s."
%
mapname
return
used_teams
=
teams
if
teams
else
all_teams
for
t
in
used_teams
:
try
:
entry
=
TeamEntry
(
t
,
self
)
if
entry
.
valid
():
self
.
entries
.
append
(
entry
)
self
.
init_score
=
entry
.
init_score
self
.
turns
=
max
(
self
.
turns
,
entry
.
max_time
)
elif
teams
is
not
None
:
self
.
entries
.
append
(
entry
)
except
:
print
>>
sys
.
stderr
,
"Couldn't find eval directory for map %s team %s."
%
(
mapname
,
t
)
return
for
t
in
self
.
entries
:
if
t
.
max_time
!=
self
.
turns
:
t
.
final_score
=
0.0
sorted_by_score
=
sorted
(
self
.
entries
,
key
=
lambda
t
:
-
t
.
final_score
)
if
sorted_by_score
[
0
].
last_score
!=
0.0
:
self
.
started
=
True
i
=
1
prev_score
=
-
1
prev_teams
=
[]
for
t
in
sorted_by_score
:
# print >> sys.stderr, t.final_score, prev_score, i
if
t
.
final_score
!=
prev_score
:
prev_teams
=
[]
for
prev
in
prev_teams
:
prev
.
rank
=
i
t
.
rank
=
i
prev_teams
.
append
(
t
)
prev_score
=
t
.
final_score
i
+=
1
self
.
step_ranking
(
self
.
entries
)
# for i, t in enumerate(sorted_by_score):
# t.rank = i+1
def
step_ranking
(
self
,
entries
):
sorted_by_score
=
sorted
(
entries
,
key
=
lambda
t
:
-
t
.
final_score
)
best
=
sorted_by_score
[
0
].
final_score
n
=
len
(
entries
)
delta
=
best
/
(
2.0
*
n
)
def
get_upper_bound
(
t
):
score
=
best
upper
=
2
*
n
while
score
>
t
.
final_score
:
score
-=
delta
upper
-=
1
return
upper
+
1
prev_rank
=
2
*
n
prev_score
=
sorted_by_score
[
0
].
final_score
sorted_by_score
[
0
].
rank
=
2
*
n
for
t
in
sorted_by_score
[
1
:]:
upper
=
get_upper_bound
(
t
)
if
prev_score
==
t
.
final_score
:
t
.
rank
=
prev_rank
elif
upper
>=
prev_rank
:
t
.
rank
=
prev_rank
-
1
else
:
t
.
rank
=
upper
if
t
.
rank
<
1
:
t
.
rank
=
1
prev_rank
=
t
.
rank
prev_score
=
t
.
final_score
def
get_team
(
self
,
id
):
if
self
.
teamdict
is
None
:
self
.
teamdict
=
dict
((
t
.
id
,
t
)
for
t
in
self
.
entries
)
return
self
.
teamdict
[
id
]
def
get_screenshot_timepoints
(
self
):
t
=
50
while
t
<
self
.
turns
:
yield
t
t
+=
50
yield
self
.
turns
def
get_mapfile
(
self
):
names
=
[
"%s.7z"
%
self
.
mapname
,
"%s-map.tar.gz"
%
self
.
mapname
,
"%s-map.tgz"
%
self
.
mapname
,
"%s.tgz"
%
self
.
mapname
,
"%s.tar.gz"
%
self
.
mapname
]
for
fname
in
names
:
if
os
.
path
.
exists
(
fname
):
size
=
os
.
stat
(
fname
)[
stat
.
ST_SIZE
]
return
size
,
fname
return
0
,
None
def
get_logpackage
(
self
):
path
=
"%s-logs.7z"
%
self
.
mapname
descent
=
3
while
not
os
.
path
.
exists
(
path
)
and
descent
>
0
:
path
=
os
.
path
.
join
(
".."
,
path
)
descent
-=
1
if
not
os
.
path
.
exists
(
path
):
return
0
,
None
size
=
os
.
stat
(
path
)[
stat
.
ST_SIZE
]
return
size
,
path
def
sizeof_fmt
(
num
):
for
x
in
[
'bytes'
,
'KB'
,
'MB'
,
'GB'
,
'TB'
]:
if
num
<
1024.0
:
return
"%3.1f%s"
%
(
num
,
x
)
num
/=
1024.0
def
list_to_row
(
l
,
elem
=
'td'
):
elems
,
classes
=
l
if
classes
:
cl_string
=
'class="%s"'
%
", "
.
join
(
classes
)
else
:
cl_string
=
""
delim
=
"</%s><%s>"
%
(
elem
,
elem
)
return
"<tr %s><%s>"
%
(
cl_string
,
elem
)
+
delim
.
join
(
elems
)
+
"</%s></tr>"
%
elem
if
__name__
==
'__main__'
:
mapname
=
sys
.
argv
[
1
]
data
=
MapData
(
mapname
)
init_score
=
data
.
init_score
pack_size
,
pack_path
=
data
.
get_logpackage
()
log_download
=
""
if
pack_path
:
archive_url
=
"http://sourceforge.net/projects/roborescue/files/logs/2011/%s/%s-all.tar"
%
(
mapname
,
mapname
)
log_download
=
'<a href="%s">Download all logs</a> (Size: %s)'
%
(
archive_url
,
sizeof_fmt
(
pack_size
))
map_size
,
map_path
=
data
.
get_mapfile
()
map_download
=
""
if
map_path
:
map_download
=
'<a href="%s">Download map</a> (Size: %s)'
%
(
map_path
,
sizeof_fmt
(
map_size
))
sorted_by_rank
=
sorted
(
data
.
entries
,
key
=
lambda
t
:
-
t
.
rank
)
def
make_table_row
(
team
,
count
):
classes
=
[]
if
team
==
sorted_by_rank
[
0
]:
classes
.
append
(
"first"
)
elif
team
==
sorted_by_rank
[
1
]:
classes
.
append
(
"second"
)
elif
team
==
sorted_by_rank
[
2
]:
classes
.
append
(
"third"
)
if
team
.
final_score
==
team
.
last_score
:
result
=
[
team
.
name
,
"%.6f"
%
team
.
final_score
,
"%d"
%
team
.
rank
]
else
:
result
=
[
team
.
name
,
"<span class=
\"
running
\"
>%.6f</span>"
%
team
.
last_score
,
"%d"
%
team
.
rank
]
for
t
,
path
,
tn_path
,
score
in
team
.
get_screenshots
():
if
path
:
html
=
'<a href="%s"><img src="%s" width="100" height="75" alt="Map at turn %d" /></a><br />%.4f'
%
(
path
,
tn_path
,
t
,
score
)
else
:
html
=
''
result
.
append
(
html
)
if
config
.
add_downloads
and
team
.
valid
():
try
:
size
,
log
=
team
.
get_logfile
(
data
.
path
)
jsize
,
jlog
=
team
.
get_jlogfile
(
data
.
path
)
# log_url = log
# log_url = "http://sourceforge.net/projects/roborescue/files/%s/%s/%s/download" % (config.log_location, data.mapname, log)
log_url
=
"%s"
%
(
log
)
jlog_url
=
"../viewer/?jlog=../%s/%s&full_log=../%s/%s"
%
(
mapname
,
jlog
,
mapname
,
log_url
)
# log_url = "http://sourceforge.net/projects/roborescue/files/logs/2011/%s" % log
result
+=
[
'<a href="%s">View Simulation</a> (%s)<br/><a href="%s">Download Simulation</a> (%s)'
%
(
jlog_url
,
sizeof_fmt
(
jsize
),
log_url
,
sizeof_fmt
(
size
))]
except
KeyError
:
pass
else
:
result
.
append
(
""
)
#result += [""] * (count - len(result))
return
result
,
classes
headers
=
[
"Team"
,
"Score"
,
"Points"
]
headers
+=
[
"%d"
%
t
for
t
in
data
.
get_screenshot_timepoints
()]
headers
.
append
(
"Logfile"
)
table
=
'<table border="2" cellspacing="0" cellpadding="5">'
table
+=
list_to_row
((
headers
,
None
),
"th"
)
for
t
in
data
.
entries
:
table
+=
list_to_row
(
make_table_row
(
t
,
len
(
headers
)))
+
"
\n
"
table
+=
"</table"
print
template
%
locals
()
scripts/competition/evaluation/make_overview.py
0 → 100755
View file @
31971f1b
#!/usr/bin/python
import
sys
,
os
,
stat
,
glob
import
config
,
make_html
template
=
"""
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
lang="en" xml:lang="en">
<head>
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
<title>RoboCup 2021 Rescue Simulation League Results</title>
<style type="text/css">
body { font-family: sans-serif; }
table { border-collapse: collapse; margin-bottom:5em }
tr.first { background-color: #E9D44A; }
tr.second { background-color: #C8C8C8; }
tr.third { background-color: #C89D4C; }
tr.qualified { background-color: #AABBFF; }
div.init-map { float:left;
text-align:center; }
</style>
</head>
<body>
<h1>RoboCup 2021 Rescue Simulation League Results</h1>
<p>Click on the map names to get detailed results and logfiles</p>
%(map_download)s
%(body)s
</body>
</html>
"""
class
DayData
(
object
):
def
__init__
(
self
,
name
,
shortname
,
maps
,
teams
,
highlight
=
None
,
show_ranks
=
None
):
self
.
name
=
name
self
.
shortname
=
shortname
self
.
teams
=
teams
self
.
maps
=
maps
self
.
runs
=
[]
self
.
prev_day
=
None
self
.
highlight
=
highlight
self
.
show_ranks
=
show_ranks
self
.
started
=
False
self
.
runs
=
[
make_html
.
MapData
(
m
,
teams
)
for
m
in
self
.
maps
]
self
.
calculate_result
()
def
calculate_result
(
self
):
self
.
total_ranks
=
dict
((
t
,
0
)
for
t
in
self
.
teams
)
self
.
total_scores
=
dict
((
t
,
0.0
)
for
t
in
self
.
teams
)
self
.
final_rank
=
{}
for
run
in
self
.
runs
:
if
not
run
.
started
:
continue
self
.
started
=
True
for
team
in
run
.
entries
:
self
.
total_ranks
[
team
.
id
]
+=
team
.
rank
self
.
total_scores
[
team
.
id
]
+=
team
.
final_score
if
self
.
prev_day
:
for
t
in
self
.
prev_day
.
teams
:
self
.
total_ranks
[
t
]
+=
self
.
prev_day
.
total_ranks
[
t
]
self
.
total_scores
[
t
]
+=
self
.
prev_day
.
total_scores
[
t
]
sorted_teams
=
sorted
(
self
.
teams
,
key
=
lambda
t
:
-
self
.
total_scores
[
t
])
sorted_teams
=
sorted
(
sorted_teams
,
key
=
lambda
t
:
-
self
.
total_ranks
[
t
])
for
i
,
t
in
enumerate
(
sorted_teams
):
self
.
final_rank
[
t
]
=
i
+
1
def
add_day
(
self
,
day
):
self
.
prev_day
=
day
self
.
calculate_result
()
def
get_team_data
(
self
,
team
):
single_results
=
[]
for
run
in
self
.
runs
:
try
:
t
=
run
.
get_team
(
team
)
single_results
.
append
((
t
.
final_score
,
t
.
rank
))
except
:
single_results
.
append
((
0
,
-
1
))
return
single_results
,
(
self
.
total_scores
[
team
],
self
.
total_ranks
[
team
],
self
.
final_rank
[
team
])
def
__str__
(
self
):
s
=
"%s:
\n
"
%
self
.
name
for
t
in
self
.
teams
:
ts
=
"%s: "
%
t
res
,
(
tot_score
,
tot_rank
,
rank
)
=
self
.
get_team_data
(
t
)
ts
+=
"| "
.
join
(
"%7.3f %2d"
%
r
for
r
in
res
)
ts
+=
" | %7.3f %3d | %2d "
%
(
tot_score
,
tot_rank
,
rank
)
s
+=
ts
+
"
\n
"
return
s
def
get_mappack
():
path
=
"maps2011.tar.gz"
if
not
os
.
path
.
exists
(
path
):
return
0
,
None
size
=
os
.
stat
(
path
)[
stat
.
ST_SIZE
]
return
size
,
path
if
__name__
==
'__main__'
:
all_teams
=
make_html
.
all_teams
datadict
=
{}
runs
=
[]
for
cdata
in
config
.
rounds
:
highlight
=
cdata
.
get
(
'highlight'
,
None
)
show_ranks
=
cdata
.
get
(
'show_ranks'
,
None
)
if
show_ranks
is
True
:
show_ranks
=
3
data
=
DayData
(
cdata
[
'name'
],
cdata
[
'shortname'
],
cdata
[
'maps'
],
cdata
[
'teams'
],
highlight
,
show_ranks
)
if
not
data
.
started
:
continue
if
'merge_with'
in
cdata
:
merge_config
=
cdata
[
'merge_with'
]
merge_data
=
datadict
[
merge_config
[
'name'
]]
data
.
add_day
(
merge_data
)
datadict
[
cdata
[
'name'
]]
=
data
runs
.
append
(
data
)
# day1 = DayData("Preliminaries Day 1", "Preliminary1", ["VC1", "Paris1", "Kobe1", "Berlin1", "Istanbul1"], all_teams)
# day2 = DayData("Preliminaries Day 2", "Preliminary2", ["Kobe2", "Paris2", "Istanbul2", "Berlin2", "VC2"], all_teams, 8)
# day2.add_day(day1)
# semi = DayData("Semifinals", "Semifinals", ["Paris3", "Istanbul3", "Berlin3", "Kobe3", "Istanbul4", "Berlin4", "VC4", "Paris4"], semi_teams, 4)
# final = DayData("Finals", "Finals", ["Paris5", "Berlin5", "Kobe4", "Istanbul5", "VC5"], final_teams, 0)
mapsize
,
mapfile
=
get_mappack
()
mapsize
=
make_html
.
sizeof_fmt
(
mapsize
)
map_download
=
"""<p>Download all maps <a href="%s">here</a> (%s)</p>"""
%
(
mapfile
,
mapsize
)
if
mapfile
else
""
def
make_table_row
(
day
,
team
):
results
=
[]
res
,
(
tot_score
,
tot_rank
,
final_rank
)
=
day
.
get_team_data
(
team
)
results
.
append
(
make_html
.
team_names
[
team
])
for
(
score
,
rank
),
run
in
zip
(
res
,
day
.
runs
):
if
not
run
.
started
:
continue
results
.
append
(
"%.2f"
%
score
)
teamdata
=
run
.
get_team
(
team
)
jlog_url
=
"../%s"
%
(
teamdata
.
jlog
)
full_log_url
=
"../%s"
%
(
teamdata
.
full_log
)
viewer_url
=
"viewer/?jlog=%s&full_log=%s"
%
(
jlog_url
,
full_log_url
)
results
.
append
(
"%d <a href='%s'><i class='far fa-play-circle'></i></a>"
%
(
rank
,
viewer_url
))
if
day
.
prev_day
:
_
,
(
prev_score
,
prev_rank
,
_
)
=
day
.
prev_day
.
get_team_data
(
team
)
results
.
append
(
"%.2f"
%
prev_score
)
results
.
append
(
"%d"
%
prev_rank
)
results
.
append
(
"%.2f"
%
tot_score
)
results
.
append
(
"%d"
%
tot_rank
)
results
.
append
(
"%d"
%
final_rank
)
classes
=
[]
if
day
.
show_ranks
is
not
None
and
final_rank
<=
day
.
show_ranks
:
if
final_rank
==
1
:
classes
.
append
(
"first"
)
elif
final_rank
==
2
:
classes
.
append
(
"second"
)
elif
final_rank
==
3
:
classes
.
append
(
"third"
)
elif
day
.
highlight
is
not
None
:
if
final_rank
<=
day
.
highlight
:
classes
.
append
(
"qualified"
)
return
results
,
classes
def
make_header
(
day
):
result
=
[
'<th rowspan="2">Team</th>'
]
result2
=
[]
for
m
,
run
in
zip
(
day
.
maps
,
day
.
runs
):
if
not
run
.
started
:
continue
result
.
append
(
'<th colspan="2"><a href="%s/index.html">%s</a> <a href="%s/%s.tgz" ><i class="fas fa-download"></i></a></th>'
%
(
run
.
path
,
m
,
m
,
m
))
result2
.
append
(
"<th>Score</th>"
)
result2
.
append
(
"<th>Points</th>"
)
if
day
.
prev_day
:
result
.
append
(
'<th colspan="2">%s</th>'
%
day
.
prev_day
.
shortname
)
result2
.
append
(
"<th>Score</th>"
)
result2
.
append
(
"<th>Points</th>"
)
result
.
append
(
'<th colspan="2">Total</th>'
)
result2
.
append
(
"<th>Score</th>"
)
result2
.
append
(
"<th>Points</th>"
)
result
.
append
(
'<th rowspan="2">Rank</th>'
)
return
result
,
result2
body
=
""
for
run
in
runs
:
if
not
run
.
started
:
continue
body
+=
"<h2>%s</h2>
\n
"
%
run
.
name
table
=
'<table border="2" cellspacing="0" cellpadding="5">'
h1
,
h2
=
make_header
(
run
)
table
+=
"<tr>"
+
""
.
join
(
h1
)
+
"</tr>
\n
"
table
+=
"<tr>"
+
""
.
join
(
h2
)
+
"</tr>
\n
"
for
t
in
run
.
teams
:
table
+=
make_html
.
list_to_row
(
make_table_row
(
run
,
t
))
+
"
\n
"
table
+=
"</table>"
body
+=
table
print
template
%
locals
()
scripts/competition/evaluation/plot-scores.gnu
0 → 100755
View file @
31971f1b
set title system("echo Scores for $RCR_MAP")
set datafile missing "-"
set key outside vertical
set ylabel "score"
set xlabel "time"
count = system("echo $RCR_COUNT")
set style line 1 lt 1 lc rgb "red"
set style line 2 lt 1 lc rgb "green"
set style line 3 lt 1 lc rgb "blue"
set style line 4 lt 1 lc rgb "cyan"
set style line 5 lt 1 lc rgb "yellow"
set style line 6 lt 1 lc rgb "black"
set style line 7 lt 1 lc rgb "magenta"
set style line 8 lt 1 lc rgb "orange"
set style line 9 lt 2 lc rgb "red"
set style line 10 lt 2 lc rgb "green"
set style line 11 lt 2 lc rgb "blue"
set style line 12 lt 2 lc rgb "black"
set style line 13 lt 4 lc rgb "red"
set style line 14 lt 4 lc rgb "green"
set style line 15 lt 4 lc rgb "blue"
set style line 16 lt 4 lc rgb "black"
set style increment user
set terminal svg dashed lw 2 size 1024,768
set output system("echo plot-$RCR_MAP.svg")
#test
set style data lines
plot 'scores.dat' using 1 title columnheader(1), for [i=2:count] '' using i title columnheader(i)
#pause -1
\ No newline at end of file
scripts/competition/evaluation/transpose.py
0 → 100755
View file @
31971f1b
#!/usr/bin/python
import
sys
result
=
[]
for
line
in
open
(
sys
.
argv
[
1
]):
elems
=
line
.
split
(
" "
)
if
elems
[
0
].
startswith
(
'"'
):
i
=
0
while
not
elems
[
i
].
endswith
(
'"'
):
i
+=
1
title
=
" "
.
join
(
elems
[
0
:
i
+
1
])
data
=
elems
[
i
+
1
:]
else
:
title
=
elems
[
0
]
data
=
elems
[
1
:]
column
=
[
title
]
for
e
in
data
:
column
.
append
(
e
)
result
.
append
(
column
)
if
not
result
:
exit
def
get_row
(
colum
,
row
):
if
row
<
len
(
colum
):
return
colum
[
row
]
return
"?"
#colum[-1]
#print [len(r) for r in result]
count
=
len
(
result
[
0
])
for
row
in
xrange
(
0
,
count
):
print
" "
.
join
(
get_row
(
col
,
row
).
strip
()
for
col
in
result
)
scripts/competition/remote-control/autoRun.sh
0 → 100755
View file @
31971f1b
#! /bin/bash
.
$(
dirname
$0
)
/config.sh
MAPS
=
"
$*
"
function
getFreeCluster
()
{
COUNT
=
"0 0 0"
while
[
1
]
;
do
for
i
in
$CLUSTERS
;
do
SERVER
=
$(
getServerHost
$i
)
RUNNING_TEAM
=
""
PRECOMPUTE
=
""
TURN
=
"-"
eval
$(
ssh
$REMOTE_USER
@
$SERVER
cat
$KERNELDIR
/boot/
$LOCKFILE_NAME
2>/dev/null
)
if
[
!
-z
$RUNNING_TEAM
]
;
then
COUNT[
$i
]=
0
else
COUNT[
$i
]=
$((
${
COUNT
[
$i
]
}
+
1
))
fi
echo
"cluster"
$i
"FREE "
${
COUNT
[
$i
]
}
"Time"
if
[
${
COUNT
[
$i
]
}
-eq
5
]
;
then
FREE
=
$i
return
;
fi
done
sleep
10
done
}
FREE
=
0
ALL
=()
count
=
0
;
uploadMaps.sh
TEAM_SHORTHANDS2
=
$(
shuf
-e
$TEAM_SHORTHANDS
)
echo
$TEAM_SHORTHANDS2
echo
"MAPS
$MAPS
"
echo
"=========================="
for
MAP
in
$MAPS
;
do
# echo $MAP
for
TEAM
in
$TEAM_SHORTHANDS2
;
do
# echo $TEAM
ALL+
=
"
$MAP
-
$TEAM
"
count
=
$((
$count
+
1
))
done
done
for
item
in
$ALL
;
do
arr
=
$(
echo
$item
|
tr
"-"
"
\n
"
)
MAP
=
${
arr
[0]
}
TEAM
=
${
arr
[1]
}
getFreeCluster
run.sh
$FREE
$MAP
$TEAM
&
#xterm -T "run.sh $FREE $MAP $TEAM" -e "run.sh $FREE $MAP $TEAM" &
done
scripts/competition/remote-control/autoShowRun.sh
0 → 100755
View file @
31971f1b
#! /bin/bash
.
$(
dirname
$0
)
/config.sh
COUNT
=
"0 0 0"
while
[
1
]
;
do
clear
showRuns.sh
sleep
5
done
scripts/competition/remote-control/cancelRun.sh
0 → 100755
View file @
31971f1b
#!/bin/bash
.
$(
dirname
$0
)
/config.sh
CLUSTER
=
$1
# MAP=$2
# TEAM=$3
# NAME=$TEAM_NAMES[$TEAM]
SERVER
=
$(
getServerHost
$CLUSTER
)
eval
$(
ssh
$REMOTE_USER
@
$SERVER
cat
$KERNELDIR
/boot/
$LOCKFILE_NAME
2>/dev/null
)
#if [ -z $PID ]; then
# echo "nothing seems to be running on cluster $CLUSTER"
#else
echo
"killing kernel..."
ssh
$REMOTE_USER
@
$SERVER
kill
-9
$PID
ssh
$REMOTE_USER
@
$SERVER
killall
-9
java
#ssh $REMOTE_USER@$SERVER rm $KERNELDIR/boot/$LOCKFILE_NAME
#fi;
echo
"killing clients"
for
i
in
1 2 3
;
do
CLIENT
=
$(
getClientHost
$CLUSTER
$i
)
ssh
$REMOTE_USER
@
$CLIENT
killall
-9
java
done
;
scripts/competition/remote-control/check.sh
0 → 100755
View file @
31971f1b
#!/bin/bash
.
$(
dirname
$0
)
/config.sh
for
HOST
in
$HOSTS
;
do
ssh
$REMOTE_USER
@
$HOST
"echo
$HOST
"
done
scripts/competition/remote-control/cleanLogs.sh
0 → 100755
View file @
31971f1b
#!/bin/bash
.
$(
dirname
$0
)
/config.sh
$(
dirname
$0
)
/commandToClients.sh
"rm
$LOGDIR
/* -rf"
scripts/competition/remote-control/commandToClients.sh
0 → 100755
View file @
31971f1b
#!/bin/bash
.
$(
dirname
$0
)
/config.sh
for
HOST
in
$CLIENT_HOSTS
;
do
ssh
$REMOTE_USER
@
$HOST
$1
done
scripts/competition/remote-control/commandToKernels.sh
0 → 100755
View file @
31971f1b
#!/bin/bash
.
$(
dirname
$0
)
/config.sh
for
HOST
in
$SERVER_HOSTS
;
do
ssh
$REMOTE_USER
@
$HOST
$*
done
scripts/competition/remote-control/compile.sh
0 → 100755
View file @
31971f1b
#!/bin/bash
.
$(
dirname
$0
)
/config.sh
if
[
"
$1
"
==
""
]
;
then
TEAMS
=
$TEAM_SHORTHANDS
else
TEAMS
=
$1
fi
for
t
in
$TEAMS
;
do
cd
$LOCAL_HOMEDIR
/code/
$TEAM
/
./compile.sh
done
scripts/competition/remote-control/config.sh
0 → 100755
View file @
31971f1b
LOCAL_USER
=
rescue
REMOTE_USER
=
rescue
SOURCEFORGE_USER
=
mgoe
RECORDSDIR
=
records-logs
MAPDIR
=
maps
KERNELDIR
=
server
CODEDIR
=
code
SCRIPTDIR
=
scripts/remote-control
LOGDIR
=
logs
DISTDIR
=
logdist
EVALDIR
=
evaluation
RSYNC_OPTS
=
-CE
CLUSTERS
=
"1 2"
HOSTS
=
"c1-1 c1-2 c1-3 c1-4 c2-1 c2-2 c2-3 c2-4"
SERVER_HOSTS
=
"c1-1 c2-1"
CLIENT_HOSTS
=
"c1-2 c1-3 c1-4 c2-2 c2-3 c2-4"
# HOSTS=localhost
# SERVER_HOSTS=localhost
# CLIENT_HOSTS=localhost
KERNEL_WAITING_TIME
=
5
PRECOMPUTE_TIMEOUT
=
125
DAY
=
Final
YEAR
=
2021
TEAM_SHORTHANDS
=
"CSU MRL RI1 AIT"
declare
-A
TEAM_NAMES
TEAM_NAMES[CSU]
=
CSU-Yunlu
TEAM_NAMES[MRL]
=
MRL
TEAM_NAMES[RI1]
=
Ri-one
TEAM_NAMES[AIT]
=
AIT-Rescue
DIR
=
$(
pwd
)
declare
-A
CONNECT_VIEWER
CONNECT_VIEWER[1]
=
no
CONNECT_VIEWER[2]
=
yes
CONNECT_VIEWER[3]
=
yes
#return hostname of the kernel server of the given cluster
function
getServerHost
()
{
echo
c
$1
-1
# echo 10.10.10.$11
# echo localhost
}
#return hostnames of the client servers of the given cluster
function
getClientHost
()
{
local
i
=
$((
$2
+
1
))
echo
"c
$1
-
$i
"
# echo localhost
}
LOCAL_HOMEDIR
=
/home/
$LOCAL_USER
LOCKFILE_NAME
=
rsl_run.lock
LOCKFILE_NAME_PRECOMP
=
/home/
$REMOTE_USER
/rsl_precomp.lock
STATFILE_NAME
=
rsl_last_run.stat
scripts/competition/remote-control/copyAllCodes.sh
0 → 100755
View file @
31971f1b
#!/bin/bash
.
$(
dirname
$0
)
/config.sh
/bin/sh copyToClients.sh
$LOCAL_HOMEDIR
/
$CODEDIR
/
$CODEDIR
scripts/competition/remote-control/copyCode.sh
0 → 100755
View file @
31971f1b
#!/bin/bash
.
$(
dirname
$0
)
/config.sh
if
[
"
$1
"
==
""
]
;
then
TEAMS
=
$TEAM_SHORTHANDS
else
TEAMS
=
$1
fi
for
t
in
$TEAMS
;
do
TEAM_USER
=
$(
echo
$t
|
tr
'[A-Z]'
'[a-z]'
)
rsync
-rcLv
$RSYNC_OPTS
/home/
$TEAM_USER
/code/ /home/
$LOCAL_USER
/code/
$TEAM
/
done
scripts/competition/remote-control/copyToAll.sh
0 → 100755
View file @
31971f1b
#!/bin/bash
.
$(
dirname
$0
)
/config.sh
for
HOST
in
$HOSTS
;
do
echo
"
$HOST
: "
scp
-r
$1
$REMOTE_USER
@
$HOST
:
$2
done
scripts/competition/remote-control/copyToClients.sh
0 → 100755
View file @
31971f1b
#!/bin/bash
.
$(
dirname
$0
)
/config.sh
for
HOST
in
$CLIENT_HOSTS
;
do
scp
-r
$1
$REMOTE_USER
@
$HOST
:
$2
done
scripts/competition/remote-control/copyToKernels.sh
0 → 100755
View file @
31971f1b
#!/bin/bash
.
$(
dirname
$0
)
/config.sh
for
HOST
in
$SERVER_HOSTS
;
do
scp
-r
$1
$REMOTE_USER
@
$HOST
:
$2
done
Prev
1
2
3
4
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment