Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions examples/circle_packing/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ def validate_packing(centers, radii):
True if valid, False otherwise
"""
n = centers.shape[0]

# Check for NaN values
if np.isnan(centers).any():
print("NaN values detected in circle centers")
return False

if np.isnan(radii).any():
print("NaN values detected in circle radii")
return False

# Check if radii are nonnegative and not nan
for i in range(n):
Expand Down Expand Up @@ -205,6 +214,17 @@ def evaluate(program_path):
centers = np.array(centers)
if not isinstance(radii, np.ndarray):
radii = np.array(radii)

# Check for NaN values before validation
if np.isnan(centers).any() or np.isnan(radii).any():
print("NaN values detected in solution")
return {
"sum_radii": 0.0,
"target_ratio": 0.0,
"validity": 0.0,
"eval_time": float(time.time() - start_time),
"combined_score": 0.0,
}

# Validate solution
valid = validate_packing(centers, radii)
Expand Down
Loading