Skip to content

Commit 4bc59f8

Browse files
committed
Update evaluator.py
1 parent 5845e2f commit 4bc59f8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

examples/circle_packing/evaluator.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ def validate_packing(centers, radii):
3535
True if valid, False otherwise
3636
"""
3737
n = centers.shape[0]
38+
39+
# Check for NaN values
40+
if np.isnan(centers).any():
41+
print("NaN values detected in circle centers")
42+
return False
43+
44+
if np.isnan(radii).any():
45+
print("NaN values detected in circle radii")
46+
return False
3847

3948
# Check if circles are inside the unit square
4049
for i in range(n):
@@ -196,6 +205,17 @@ def evaluate(program_path):
196205
centers = np.array(centers)
197206
if not isinstance(radii, np.ndarray):
198207
radii = np.array(radii)
208+
209+
# Check for NaN values before validation
210+
if np.isnan(centers).any() or np.isnan(radii).any():
211+
print("NaN values detected in solution")
212+
return {
213+
"sum_radii": 0.0,
214+
"target_ratio": 0.0,
215+
"validity": 0.0,
216+
"eval_time": float(time.time() - start_time),
217+
"combined_score": 0.0,
218+
}
199219

200220
# Validate solution
201221
valid = validate_packing(centers, radii)

0 commit comments

Comments
 (0)