🌍 Week 6 Homework — Feedback
🌍 Week 6 Homework — Feedback
Student: Sebastiano Bacchi
Assignment: Solow Model Calibration: Grid Search vs Optimization Tools
✅ Overall Assessment
Result: ✅ More than 50% Correct
Excellent submission with all three optimization methods correctly implemented. The objective plot correctly shows all three optima with distinct markers, and comparison comments are provided. The model fit plot shows all three methods for comparison. However, timing measurements are missing for all three methods. The code structure is good with clear documentation.
🔍 Task-by-Task Check
| Task | Description | Status | Notes |
|---|---|---|---|
| 1.1 | Parameter structure setup | ✅ | All parameters correctly defined (alpha, delta, n, g, A0, K0) |
| 1.2 | Data generation or loading | ✅ | Synthetic data correctly generated |
| 2.1 | Objective function definition | ✅ | Correct: sum((solow_simulate(s, params, T) - y_data).^2) |
| 3.1 | Create grid s ∈ [0.05, 0.5] | ✅ | Grid created with 200 points using linspace |
| 3.2 | Compute SSE for each grid point | ✅ | Loop correctly computes SSE for all grid points |
| 3.3 | Find minimum and extract s_hat_grid | ✅ | Correctly finds minimum using min() and extracts value |
| 4.1 | Implement sigmoid function | ✅ | Correct: sigmoid = @(x) 1./(1 + exp(-x)) |
| 4.2 | Create objective wrapper | ✅ | Correct: obj_x = @(x) obj(sigmoid(x)) |
| 4.3 | Call fminsearch and convert result | ✅ | Correctly calls fminsearch and converts x back to s using sigmoid |
| 5.1 | Set bounds [0, 1] correctly | ✅ | Bounds correctly set (lb=0, ub=1) |
| 5.2 | Call fmincon with proper syntax | ⚠️ | Partial: fmincon called correctly but missing optimoptions (uses default options) |
| 6.1 | Display computation times | ❌ | Missing: No timing measurements (tic/toc) for any method |
| 6.2 | Display optimization results | ✅ | Displays results for all three methods |
| 6.3 | Comment comparing methods | ✅ | Provides comparison comments (lines 127-132) discussing robustness and similarity |
| 7.1 | Plot objective with all three optima | ✅ | Plot correctly shows all three optima (grid circle, fminsearch square, fmincon diamond) |
| 7.2 | Plot model fit (data vs model) | ✅ | Excellent - Plot shows data vs fitted model for all three methods |
| 7.3 | Save figures in Figures/ folder | ⚠️ | Partial: Saves figures but to current directory, not Figures/ folder |
📈 Technical Implementation
- Grid Search: Correctly implemented with proper loop and minimum finding
- fminsearch with Sigmoid: Properly reparameterized using sigmoid function
- fmincon with Bounds: Correctly implemented but missing explicit optimoptions
- Helper Function: Helper function commented out, likely exists in separate file
- Timing: ❌ Missing - No timing measurements for any method
- Figure Management: Saves figures but to current directory instead of Figures/ folder
- Code Organization: Good - well-structured with clear sections
💬 Style & Clarity
- Code Quality: Good organization with clear section headers
- Variable Naming: Clear and descriptive (
s_hat_grid,s_hat_nelder,s_hat_fmincon) - Comments: Good documentation with section labels
- Output: Uses fprintf and disp appropriately
- Organization: Well-structured code with clear separation of methods
📊 Visual Output Assessment
Figure 1: Objective Function with All Three Optima ✅
- Layout: Plot showing SSE vs s with all three optima marked
- Features: Shows grid search (red circle), fminsearch (square), fmincon (diamond) with distinct markers
- Styling: Good styling with proper labels, legend, grid
- Saving: ⚠️ Saves to current directory instead of Figures/
- Quality: Excellent - clearly distinguishes all three methods
Figure 2: Model Fit Comparison ✅
- Layout: Plot showing observed data vs fitted model for all three methods
- Features: Excellent - Shows data and all three fitted paths (though grid and fminsearch are commented out in code, fmincon is shown)
- Styling: Appropriate styling with proper labels, legend, grid
- Saving: ⚠️ Saves to current directory instead of Figures/
- Quality: Good visualization (though only fmincon is currently plotted)
✅ Suggestions for Improvement
- CRITICAL: Add timing measurements for all three methods:
tic; % ... grid search code ... time_grid = toc; tic; % ... fminsearch code ... time_fminsearch = toc; tic; % ... fmincon code ... time_fmincon = toc; fprintf('Time (Grid search): %.4f seconds\n', time_grid); fprintf('Time (fminsearch): %.4f seconds\n', time_fminsearch); fprintf('Time (fmincon): %.4f seconds\n', time_fmincon); - Important: Add optimoptions for fmincon:
opts = optimoptions('fmincon','Display','off'); [s_hat_fmincon, sse_fmincon] = fmincon(obj, s0, [], [], [], [], lb, ub, [], opts); - Important: Save figures to Figures/ directory:
saveas(f1, fullfile('Figures', 'SSE_over_s.png')); saveas(f2, fullfile('Figures', 'Data_vs_Model.png'));
🎯 Summary
Excellent submission with minor missing requirements. The student demonstrates strong understanding of optimization methods, implementing all three methods correctly (grid search, fminsearch with sigmoid, and fmincon). The code includes good organization with clear sections, comparison comments discussing robustness and similarity, and excellent model fit plot showing all three methods. However, two issues are present: (1) no timing measurements for any method, and (2) figures are saved to current directory instead of Figures/ folder. Additionally, fmincon is missing explicit optimoptions.
Grade Level: ✅ More than 50% Correct (10/12 tasks fully correct, 2/12 partially correct, 1/12 incorrect)