Skip to content

Optimize ScheduleSolver pruning and scalability#23

Draft
google-labs-jules[bot] wants to merge 1 commit intomainfrom
optimize-solver-pruning-scalability-3159618345961881619
Draft

Optimize ScheduleSolver pruning and scalability#23
google-labs-jules[bot] wants to merge 1 commit intomainfrom
optimize-solver-pruning-scalability-3159618345961881619

Conversation

@google-labs-jules
Copy link
Contributor

This change optimizes the backend ScheduleSolver to address potential performance issues and correctness bugs.

  1. Correctness Fix: The solver uses pruning to skip low-scoring branches. However, when compactness is 'low', adding courses can increase the score (via gap bonuses). The previous pruning logic assumed score monotonically decreases (or stays same), leading to incorrect pruning of optimal schedules. This is fixed by disabling pruning when such bonuses are active.
  2. Scalability Optimization: For standard cases (no bonuses), the pruning condition was partial < min_heap. This fails to prune branches that have the same score as the current worst solution in the heap. Since we only replace if new > min, generating equal-score solutions is wasteful. The condition is updated to partial <= min_heap, which drastically reduces search space (e.g., from 70s to 0.005s in a 10-group stress test).
  3. Test Updates: Updated tests/test_logic.py to align with the current solver implementation (Meta-Candidates returning a single structure for identical times). Added tests/test_pruning.py and tests/test_scalability.py to verify the fixes.

PR created automatically by Jules for task 3159618345961881619 started by @OsakaLOOP

- Fix test_logic.py to match current solver logic (handling Meta-Candidates and selected=True).
- Fix unsafe pruning bug in generate_schedules where bonus points (compactness='low') were ignored, causing optimal schedules to be missed.
- Optimize pruning condition to use strict inequality (`<=`) when safe, reducing runtime from >70s to <0.01s for cases with many equivalent solutions.
- Add tests/test_pruning.py and tests/test_scalability.py to verify correctness and performance.
@google-labs-jules
Copy link
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants