π Week 6 Homework β Feedback
π Week 6 Homework β Feedback
Student: Chiara Tombolini
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. 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: Uses obj_reparam = @(x) obj(1./(1 + exp(-x))) |
| 4.2 | Create objective wrapper | β | Correct: Objective wrapper defined within fminsearch call |
| 4.3 | Call fminsearch and convert result | β | Correctly calls fminsearch and converts x back to s |
| 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 uses βDisplayβ,βiterβ instead of βoffβ |
| 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 154-162) discussing speed, robustness, and similarity |
| 7.1 | Plot objective with all three optima | β | Missing: Plot (lines 121-135) only shows grid search with reference lines, missing fminsearch and fmincon optima markers |
| 7.2 | Plot model fit (data vs model) | β | Plot shows data vs fitted model output over time |
| 7.3 | Save figures in Figures/ folder | β | Figures correctly saved using saveas() and savefig() |
π 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 uses βDisplayβ,βiterβ instead of βoffβ
- 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() and savefig()
- 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 and detailed comparison comments
- 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 with reference lines
- Features: Shows objective function curve with true s and estimated s lines, but only for grid search
- Styling: Good styling with proper labels, legend, grid
- Saving: β Saves to Figures/ directory in both PNG and FIG formats
- Issue: Missing fminsearch and fmincon optima markers - should show all three methodsβ results on the same plot
Figure 2: Model Fit β
- Layout: Plot showing observed data vs fitted model output over time
- Features: Shows data and fitted model from grid search
- Styling: Appropriate styling with proper labels, legend, grid
- Saving: β Saves to Figures/ directory in both PNG and FIG formats
- Quality: Good visualization of model fit
β Suggestions for Improvement
- CRITICAL: Update objective plot (Figure 2) to show all three optima:
fig2 = figure; plot(s_grid, SSE, 'LineWidth', 1.8); hold on; plot(s_hat_grid, obj(s_hat_grid), 'ko', 'MarkerSize', 8, 'LineWidth', 1.5); plot(s_hat_fminsearch, obj(s_hat_fminsearch), 'rs', 'MarkerSize', 8, 'LineWidth', 1.5); plot(s_hat_fmincon, obj(s_hat_fmincon), 'bd', 'MarkerSize', 8, 'LineWidth', 1.5); xline(s_true, '--k', 'True s', 'LineWidth', 1); xlabel('Savings rate s'); ylabel('Sum of Squared Errors (SSE)'); title('Objective Function: SSE vs Savings Rate'); legend({'SSE','Grid min','fminsearch','fmincon','True s'}, 'Location','best'); grid on; - 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; - Minor: Change fmincon display option to βoffβ:
options = optimoptions('fmincon', 'Display', 'off', 'Algorithm', 'interior-point');
π― 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 and excellent comparison comments discussing speed, robustness, and similarity in detail. 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. Additionally, fmincon uses βDisplayβ,βiterβ instead of βoffβ.
Grade Level: β More than 50% Correct (10/12 tasks fully correct, 1/12 partially correct, 1/12 incorrect)