Spaces:
Sleeping
Sleeping
aishani-s20 commited on
Commit ·
ea65582
1
Parent(s): 760fb86
changed grader
Browse files- server/graders.py +15 -7
server/graders.py
CHANGED
|
@@ -3,32 +3,40 @@
|
|
| 3 |
|
| 4 |
"""
|
| 5 |
Standalone graders for the Quantum Circuit Optimization Environment.
|
|
|
|
| 6 |
"""
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def grade_easy(observation) -> float:
|
| 11 |
metadata = getattr(observation, 'metadata', {}) or {}
|
| 12 |
final_count = getattr(observation, 'gate_count', 0)
|
| 13 |
initial_count = metadata.get("initial_count", final_count)
|
| 14 |
if initial_count == 0:
|
| 15 |
-
return
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
| 18 |
def grade_medium(observation) -> float:
|
| 19 |
metadata = getattr(observation, 'metadata', {}) or {}
|
| 20 |
final_count = getattr(observation, 'gate_count', 0)
|
| 21 |
initial_count = metadata.get("initial_count", final_count)
|
| 22 |
if initial_count == 0:
|
| 23 |
-
return
|
| 24 |
compression = (initial_count - final_count) / initial_count
|
| 25 |
-
return
|
|
|
|
| 26 |
|
| 27 |
def grade_hard(observation) -> float:
|
| 28 |
metadata = getattr(observation, 'metadata', {}) or {}
|
| 29 |
final_count = getattr(observation, 'gate_count', 0)
|
| 30 |
initial_count = metadata.get("initial_count", final_count)
|
| 31 |
if initial_count == 0:
|
| 32 |
-
return
|
| 33 |
compression = (initial_count - final_count) / initial_count
|
| 34 |
-
return
|
|
|
|
| 3 |
|
| 4 |
"""
|
| 5 |
Standalone graders for the Quantum Circuit Optimization Environment.
|
| 6 |
+
Scores are strictly within (0.0, 1.0) — never exactly 0.0 or 1.0.
|
| 7 |
"""
|
| 8 |
|
| 9 |
+
|
| 10 |
+
def _strict(score: float) -> float:
|
| 11 |
+
"""Clamp score to strictly (0.0, 1.0) as required by the platform."""
|
| 12 |
+
return max(0.01, min(0.99, score))
|
| 13 |
+
|
| 14 |
|
| 15 |
def grade_easy(observation) -> float:
|
| 16 |
metadata = getattr(observation, 'metadata', {}) or {}
|
| 17 |
final_count = getattr(observation, 'gate_count', 0)
|
| 18 |
initial_count = metadata.get("initial_count", final_count)
|
| 19 |
if initial_count == 0:
|
| 20 |
+
return _strict(0.99)
|
| 21 |
+
compression = (initial_count - final_count) / initial_count
|
| 22 |
+
return _strict(compression)
|
| 23 |
+
|
| 24 |
|
| 25 |
def grade_medium(observation) -> float:
|
| 26 |
metadata = getattr(observation, 'metadata', {}) or {}
|
| 27 |
final_count = getattr(observation, 'gate_count', 0)
|
| 28 |
initial_count = metadata.get("initial_count", final_count)
|
| 29 |
if initial_count == 0:
|
| 30 |
+
return _strict(0.99)
|
| 31 |
compression = (initial_count - final_count) / initial_count
|
| 32 |
+
return _strict(compression / 0.20)
|
| 33 |
+
|
| 34 |
|
| 35 |
def grade_hard(observation) -> float:
|
| 36 |
metadata = getattr(observation, 'metadata', {}) or {}
|
| 37 |
final_count = getattr(observation, 'gate_count', 0)
|
| 38 |
initial_count = metadata.get("initial_count", final_count)
|
| 39 |
if initial_count == 0:
|
| 40 |
+
return _strict(0.99)
|
| 41 |
compression = (initial_count - final_count) / initial_count
|
| 42 |
+
return _strict(compression / 0.35)
|