Skip to content

Phase 8: Smart Solver Mode#109

Closed
4awmy wants to merge 9 commits into
mainfrom
phase-8-smart-solve
Closed

Phase 8: Smart Solver Mode#109
4awmy wants to merge 9 commits into
mainfrom
phase-8-smart-solve

Conversation

@4awmy
Copy link
Copy Markdown
Owner

@4awmy 4awmy commented May 3, 2026

Comparison engine for multiple solvers and modal UI panel for recommendations.

4awmy and others added 9 commits April 30, 2026 11:10
Comprehensive updates across all solvers and GUI pages:

**Engine Improvements:**
- Enhanced root finder with improved iteration tracking
- Extended calculus engine with all numerical integration methods
- Improved network solver with better convergence handling
- Better step-by-step data collection for all solvers

**GUI Enhancements:**
- Ch 2 (Linear Systems): Dynamic n×n matrix grid input, load example problems, iteration table display
- Ch 1 (Root Finding): Load example problems dropdown, iteration table in right panel, fixed input field layout
- Ch 3 (Numerical Calculus): Enhanced layout and visualization
- All pages: Iteration tables showing step-by-step solver progress

**User Experience:**
- Load example buttons allow quick testing with predefined problems from numerical_methods_problems.md
- Iteration tables display convergence progress (iteration #, values, errors)
- Better input validation and error handling
- Improved result display panels

This enables users to:
✅ Solve all problems from numerical methods problem sheet
✅ Use matrix grid for easy linear system entry
✅ View detailed iteration history
✅ Load pre-configured examples for testing

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@4awmy 4awmy self-assigned this May 3, 2026
@4awmy
Copy link
Copy Markdown
Owner Author

4awmy commented May 3, 2026

Self-review: ComparisonRunner implemented with recommendation logic. Integrated into all 4 main chapter pages. @copilot review requested.

@4awmy
Copy link
Copy Markdown
Owner Author

4awmy commented May 3, 2026

Review: Phase 8 — Smart Solver Mode

@gemini please fix the following issues on branch phase-8-smart-solve:


BUG 1 — Silent exception swallow loses divergence reason (breaks DiagnosticEngine)

File: numcore_engine/solvers/comparison.py, line ~37

Current:

except Exception:
    continue  # Skip solvers that fail for this specific input

This discards the error message, so when all methods fail the _generate_recommendation has no per-method cause to show. Replace with:

except Exception as exc:
    results.append(SimulationData(
        title=name,
        metadata={"diverged": True, "error_reason": str(exc), "iterations": 0},
        computation_time_ms=(time.perf_counter() - start_time) * 1000,
        x_data=[],
        y_data=[]
    ))

This keeps failed solvers in results with diverged=True and a reason string, so the diagnostic panel can display error_reason per method.


BUG 2 — All-diverged case not signaled to UI

File: numcore_engine/solvers/comparison.py, line ~53

if not valid_results:
    best_method_data = results[0]

There is no all_diverged flag in ComparisonResult for the UI to detect. Update ComparisonResult in models.py to add the field, and set it here:

all_diverged = len(valid_results) == 0
return ComparisonResult(
    best_method=best_method_data.title if not all_diverged else None,
    results=results,
    recommendation=recommendation,
    all_diverged=all_diverged
)

Then in SmartSolverPanel, check comparison_result.all_diverged and show the diagnostic panel instead of the recommendation card.


DESIGN — SmartSolverPanel is CTkToplevel (popup), spec requires inline CTkFrame

File: numcore_gui/smart_solver_panel.py, line ~6

The spec (US2) says Smart Solve results appear inline in the chapter page, not in a separate window. Change the base class from CTkToplevel to CTkFrame so it can be embedded:

class SmartSolverPanel(ctk.CTkFrame):
    def __init__(self, master, comparison_result: ComparisonResult = None, **kwargs):
        super().__init__(master, fg_color=BLACK, **kwargs)
        # Remove self.title(), self.geometry(), self.lift(), self.focus_set()
        # Keep all content widgets

Chapter pages can then create it with SmartSolverPanel(page_frame) and show/hide it with .grid().


MINOR — Hardcoded colors instead of theme constants

File: numcore_gui/smart_solver_panel.py, lines ~32 and ~66

Replace:

text_color="#4CAF50"   # line 32
bg_color = "#2E7D32"   # line 66

With theme imports:

from numcore_gui.theme import SUCCESS, PANEL
text_color=SUCCESS     # line 32
bg_color = PANEL if not is_best else "#1b5e20"  # or add HIGHLIGHT to theme.py

CLEANUP — Remove artifact files

Remove gemini_*.log, issue*.md, ISSUES.md from the commit.

@4awmy
Copy link
Copy Markdown
Owner Author

4awmy commented May 3, 2026

Fixed: SmartSolverPanel is now an inline frame. Exception swallowing fixed. Added all_diverged signal. @claude please review.

@4awmy
Copy link
Copy Markdown
Owner Author

4awmy commented May 3, 2026

Closing — all changes from this phase are included in the squash-merge of PR #111 (phase-11-final-polish) into main. All review fixes have been applied and verified.

@4awmy 4awmy closed this May 3, 2026
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.

1 participant