π Week 6 Homework β Feedback
π Week 6 Homework β Feedback
Student: Bakytkul Baltabay
Assignment: Solow Model Calibration: Grid Search vs Optimization Tools
β Overall Assessment
Result: β οΈ Partial <50% Correct
Submission attempts all three optimization methods but contains critical errors in the objective function definition and grid search implementation. The objective function (line 24) is incorrectly defined, missing parentheses and squaring the sum instead of summing squared differences. The grid search uses fminsearch instead of finding the grid minimum, which defeats the purpose of manual grid search. fminsearch and fmincon are implemented but use the incorrect objective function. Missing timing measurements and proper comparison comments.
π Task-by-Task Check
| Task | Description | Status | Notes |
|---|---|---|---|
| 1.1 | Parameter structure setup | β | All parameters correctly defined |
| 1.2 | Data generation or loading | β | Synthetic data with noise correctly generated |
| 2.1 | Objective function definition | β | Critical Error: Line 24: sum(solow_simulate(s_grid,params,T) - y_data)^2 is wrong - should be sum((solow_simulate(s,params,T) - y_data).^2) |
| 3.1 | Create grid s β [0.05, 0.5] | β | Grid created with 200 points |
| 3.2 | Compute SSE for each grid point | β οΈ | Computes SSE but using incorrect objective function |
| 3.3 | Find minimum and extract s_hat_grid | β | Critical Error: Line 44 uses fminsearch(obj, s_true) instead of extracting grid minimum |
| 4.1 | Implement sigmoid function | β | Correct: sigmoid = @(x) 1./(1 + exp(-x)) |
| 4.2 | Create objective wrapper | β | Correct wrapper created |
| 4.3 | Call fminsearch and convert result | β οΈ | Uses incorrect objective function |
| 5.1 | Set bounds [0, 1] correctly | β | Bounds correctly set (lb=0, ub=1) |
| 5.2 | Call fmincon with proper syntax | β οΈ | Syntax correct but uses wrong objective function |
| 6.1 | Display computation times | β | Missing: No tic/toc measurements |
| 6.2 | Display optimization results | β οΈ | Displays some results but incomplete |
| 6.3 | Comment comparing methods | β οΈ | Partial: Basic comments provided but not comprehensive |
| 7.1 | Plot objective with all three optima | β | Missing: Plot only shows grid search curve, no optima markers for fminsearch/fmincon |
| 7.2 | Plot model fit (data vs model) | β | Plot created showing data vs fitted model |
| 7.3 | Save figures in Figures/ folder | β | Figures correctly saved in PDF format |
π Technical Implementation
- Objective Function: β Critical Error - Line 24:
obj = @(s_grid)sum(solow_simulate(s_grid,params,T) - y_data)^2;- Missing parentheses: should be
sum((model - data).^2)notsum(model - data)^2 - The
^2is applied to the sum, not to individual differences - Should be:
obj = @(s) sum((solow_simulate(s, params, T) - y_data).^2);
- Missing parentheses: should be
- Grid Search: β Critical Error - Line 44 uses
fminsearch(obj, s_true)instead of extracting the minimum from the grid:s_hat_grid = s_grid(idx_min); - fminsearch with Sigmoid: Uses incorrect objective function
- fmincon: Uses incorrect objective function
- Helper Function: Need to verify if
solow_simulate()function is provided (not visible in main code) - Figure Management: Saves to Figures/ directory
π¬ Style & Clarity
- Code Quality: Basic organization with clear sections
- Variable Naming: Some inconsistencies (uses
l0instead ofs0for fmincon) - Comments: Minimal comments
- Output: Uses fprintf appropriately
- Organization: Basic structure but missing some elements
π Visual Output Assessment
Figure 1: Objective Function β οΈ
- Layout: Plot showing SSE vs s
- Features: Only shows grid search curve
- Issue: Missing optima markers for fminsearch and fmincon on the objective plot
- Saving: β Saves PDF to Figures/ directory
Figure 2: Model Fit β
- Layout: Plot showing data vs fitted model
- Features: Shows data and fitted model
- Saving: β Saves PDF to Figures/ directory
β Suggestions for Improvement
- CRITICAL: Fix objective function definition (line 24):
obj = @(s) sum((solow_simulate(s, params, T) - y_data).^2);Note: The parentheses and
.^2are essential - we need to square each difference first, then sum. - CRITICAL: Fix grid search minimum extraction (line 44):
[~, idx_min] = min(SSE); s_hat_grid = s_grid(idx_min); % Extract from grid, don't use fminsearch! - CRITICAL: Update objective plot to show all three optima:
plot(s_hat_grid, obj(s_hat_grid), 'ro', 'MarkerSize', 8, 'DisplayName', 'Grid'); plot(s_hat_nelder, obj(s_hat_nelder), 'bs', 'MarkerSize', 8, 'DisplayName', 'fminsearch'); plot(s_hat_fmincon, obj(s_hat_fmincon), 'gd', 'MarkerSize', 8, 'DisplayName', 'fmincon'); -
CRITICAL: Add timing measurements (tic/toc) for all three methods
-
Important: Expand comparison comments to discuss speed, robustness, and similarity in detail
- Style: Provide
solow_simulate()helper function if itβs not included
π― Summary
Submission with critical errors requiring correction. The student attempts all three optimization methods and includes both required figures. However, there are critical errors: (1) objective function is incorrectly defined (missing parentheses, squaring sum instead of summing squares), (2) grid search uses fminsearch instead of extracting grid minimum, and (3) all methods use the incorrect objective function. The code structure is basic with some organization, but missing timing measurements and comprehensive comparison comments. The objective plot only shows the curve without marking all three optima.
Grade Level: β οΈ Partial <50% Correct (6/12 tasks fully correct, 3/12 partially correct, 3/12 incorrect)