π Week 6 Homework β Feedback
π Week 6 Homework β Feedback
Student: Sofia Bruga
Assignment: Solow Model Calibration: Grid Search vs Optimization Tools
β Overall Assessment
Result: β More than 50% Correct
Good submission with all three optimization methods correctly implemented. The model fit plot shows all three methods for comparison. Comparison comments are provided. However, two issues are present: (1) Objective plot only shows grid search instead of all three optima markers (fminsearch and fmincon should also be marked on the objective plot), and (2) timing measurements are missing for all three methods. The code structure is good.
π 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 | β | fmincon correctly called with proper 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 90-93) discussing speed, robustness, and similarity |
| 7.1 | Plot objective with all three optima | β | Missing: Plot (lines 37-42) only shows grid search curve, missing fminsearch and fmincon optima markers |
| 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 | β | Figures correctly saved using saveas() |
π 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 with proper options
- Helper Function:
solow_simulate()correctly implements Solow dynamics - Timing: β Missing - No timing measurements for any method
- Figure Management: Creates Figures directory and saves figures properly using saveas()
- 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_fminsearch,s_hat_fmincon) - Comments: Good documentation with section labels
- Output: Uses fprintf appropriately
- Organization: Well-structured code with clear separation of methods
π Visual Output Assessment
Figure 1: Objective Function β οΈ
- Layout: Plot showing SSE vs s for grid search only
- Features: Shows objective function curve but only for grid search
- Styling: Good styling with proper labels and title
- Saving: β Saves to Figures/ directory
- Issue: Missing fminsearch and fmincon optima markers - should show all three methodsβ results on the same plot
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 (grid, fminsearch, fmincon) with distinct line styles
- Styling: Appropriate styling with proper labels, legend, grid
- Saving: β Saves to Figures/ directory
- Quality: Excellent visualization comparing all three methods
β Suggestions for Improvement
- CRITICAL: Update objective plot (Figure 1) to show all three optima:
figure; plot(s_grid, SSE, 'LineWidth', 1.5); hold on; grid on; plot(s_hat_grid, obj(s_hat_grid), 'o', 'MarkerSize', 8, 'DisplayName', 'Grid'); plot(s_hat_fminsearch, fval, 's', 'MarkerSize', 8, 'DisplayName', 'fminsearch'); plot(s_hat_fmincon, fval_con, 'd', 'MarkerSize', 8, 'DisplayName', 'fmincon'); xlabel('s'); ylabel('SSE(s)'); title('Objective function: SSE vs s'); legend('Location','best'); saveas(gcf, 'Figures/SSE_gridsearch.png'); - 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;
π― Summary
Good submission with missing requirements. The student demonstrates 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 speed, robustness, and similarity, and excellent model fit plot showing all three methods. However, two issues are present: (1) objective plot only shows grid search instead of all three optima markers, and (2) no timing measurements for any method.
Grade Level: β More than 50% Correct (10/12 tasks fully correct, 0/12 partially correct, 2/12 incorrect)