🌍 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

  1. 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;
    
  2. 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;
    
  3. 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)