π Week 6 Homework β Feedback
π Week 6 Homework β Feedback
Student: Anna De Falco
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 is 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 | β οΈ | Partial: No explicit comparison comments provided |
| 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) | β | Plot shows data vs fitted model |
| 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 with proper options
- Helper Function: Helper function likely exists separately or inline
- 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
- Comments: Basic documentation
- 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 current directory instead of Figures/
- 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
- Features: Shows data and fitted model
- Styling: Appropriate styling with proper labels
- Saving: β οΈ Saves to current directory instead of Figures/
- Quality: Good visualization of model fit
β 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_nelder, fval, 's', 'MarkerSize', 8, 'DisplayName', 'fminsearch'); plot(s_hat_con, 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; - Important: Save figures to Figures/ directory:
if ~exist('Figures','dir'), mkdir('Figures'); end saveas(gcf, fullfile('Figures', 'manual grid search.png')); saveas(gcf, fullfile('Figures', 'MFC.png')); - Important: Add comparison comments discussing speed, robustness, and similarity
π― 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. However, several issues are present: (1) objective plot only shows grid search instead of all three optima markers, (2) no timing measurements for any method, (3) figures are saved to current directory instead of Figures/ folder, and (4) no explicit comparison comments provided.
Grade Level: β More than 50% Correct (9/12 tasks fully correct, 1/12 partially correct, 2/12 incorrect)