🌍 Week 6 Homework — Feedback

Student: Giovanni Di Miele
Assignment: Solow Model Calibration: Grid Search vs Optimization Tools


✅ Overall Assessment

Result:More than 50% Correct

Solid submission with all three optimization methods correctly implemented. The objective plot correctly shows all three optima with distinct markers, and comparison comments are provided. However, two issues are present: (1) Only fmincon is timed (tic/toc), missing timing for grid search and fminsearch, and (2) No explicit figure saving code in the visible code (though figures are present in submission). The code structure is well-organized with clear sections.


🔍 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 with noise 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 syntax and optimoptions
6.1 Display computation times ⚠️ Partial: Only times fmincon (lines 106-109), missing timing for grid search and fminsearch
6.2 Display optimization results Displays results for all three methods with SSE values
6.3 Comment comparing methods Provides comparison comments (lines 146-152) discussing speed and similarity
7.1 Plot objective with all three optima Plot correctly shows all three optima (grid circle, fminsearch square, fmincon diamond)
7.2 Plot model fit (data vs model) Correct plot showing data vs fitted model output over time
7.3 Save figures in Figures/ folder ⚠️ Partial: Figures exist in submission but no explicit saving code visible in main code

📈 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 and timing
  • Helper Function: solow_simulate() correctly implements Solow dynamics
  • Timing: ⚠️ Only fmincon is timed - missing timing for grid search and fminsearch
  • Figure Management: Figures are present in submission but saving code not visible in main script
  • Code Organization: Well-structured with clear sections separating challenge and homework

💬 Style & Clarity

  • Code Quality: Good organization with clear sections
  • Variable Naming: Clear and descriptive (s_hat_grid, s_hat_nelder, s_hat_fmincon)
  • Comments: Good section headers and some explanatory comments
  • Output: Uses fprintf appropriately to display results
  • Organization: Well-structured code with clear separation between challenge and homework parts

📊 Visual Output Assessment

Figure 1: Objective Function with All Three Optima ✅

  • Layout: Plot showing SSE vs s with all three optima marked
  • Features: Shows grid search (circle), fminsearch (square), fmincon (diamond) with distinct markers
  • Styling: Good styling with proper labels, legend, and grid
  • Saving: ✅ Figure exists in submission
  • Quality: Excellent - clearly distinguishes all three methods

Figure 2: Model Fit ✅

  • Layout: Plot showing observed data vs fitted model output over time
  • Features: Shows data and fitted model from fmincon
  • Styling: Appropriate styling with proper labels, legend, and grid
  • Saving: ✅ Figure exists in submission
  • Quality: Good visualization of model fit

✅ Suggestions for Improvement

  1. CRITICAL: Add timing measurements (tic/toc) for grid search and fminsearch to enable complete speed comparison:
    tic;
    % ... grid search code ...
    time_grid = toc;
       
    tic;
    % ... fminsearch code ...
    time_fminsearch = toc;
       
    tic;
    % ... fmincon code ...
    time_fmincon = toc;
       
    fprintf('Time (Grid search): %.4f seconds\n', time_grid);
    fprintf('Time (fminsearch): %.4f seconds\n', time_fminsearch);
    fprintf('Time (fmincon): %.4f seconds\n', time_fmincon);
    
  2. Important: Add explicit figure saving code to make it clear figures are being saved:
    print(fig1, fullfile('Figures', 'SSE_vs_s.png'), '-dpng', '-r300');
    print(fig2, fullfile('Figures', 'fit_vs_data.png'), '-dpng', '-r300');
    
  3. Style: Consider removing the challenge code section (lines 1-91) if only homework is being submitted, or clearly separate them

🎯 Summary

Good submission with minor missing requirements. The student demonstrates solid 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 and similarity, and proper figure management showing all three optima clearly. However, two issues are present: (1) only fmincon is timed, missing timing for grid search and fminsearch for complete speed comparison, and (2) no explicit figure saving code visible (though figures are present in submission). The code structure is well-organized with clear documentation.

Grade Level: ✅ More than 50% Correct (12/12 tasks fully correct, 2/12 partially correct, 0/12 incorrect)