Minimizing Milling Cycle Time using Simulated Annealing

Yong Suh, California State University, Sacramento, Mechanical Engineering

Author Profile
Initial Publication Date: October 7, 2025

Summary

In this activity, students explore the trade-offs in machining: spindle speed, feed per tooth, axial and radial depth of cut that affect material removal rate in milling machining. The settings also affect cutting forces, power demand, surface roughness, and tool life. The objective of the problem is to find the parameter values for minimizing the machining cycle time (time to remove a given workpiece volume) subject to realistic constraints. Students will implement and compare their own implementation of Simulated Annealing and MATLAB's built-in solvers to solve the non-linear constrained problem in MATLAB.

Share your modifications and improvements to this activity through the Community Contribution Tool »

Learning Goals

After completing this activity, students will be able to:
1. Translate a machining performance model into a concrete optimization formulation with constraints.
2. Implement the Simulated Annealing (SA) algorithm and debug it using simple diagnostics.
3. Use MATLAB's built-in solver (simulannealbnd) with penalty and OutputFcn strategies.
4. Interpret which constraints are active at the optimum and related that to machining intuition (e.g., trading offs of roughness, force, tool life)
5. Critically assess solver convergence behavior, parameter tuning, and practical limitations.

Context for Use

This activity fits well in the computational methods or manufacturing processes course. It can be completed in a 2–3-hour lab session, ideally after students have already seen basic optimization methods. Students may work in pairs. The instructor should provide them with a skeleton Live Script with problem constraints already filled; the students fill in the optimization routines.

Description and Teaching Materials

Part 1 (Optional): Hand Calculation
- Students pick a candidate design x=[n, fz, ap, ae], calculate feed rate, MRR, cutting power, force, surface roughness, and tool life.
- Check whether it satisfies all constraints (Power <= Pmax, force <= Max, Ra <= limit, Tool life >= Tmin).
- This activity builds intuition on how each parameter affects time vs. constraints.

Part 2: Own implementation of Simulated Annealing (SA) in MATLAB
- Provide function signatures (e.g., constcon(x,P) returns time and constraint residuals, penalty(x,P,rho) returns penalized objective.
- Students code sa_milling(...); a simulated annealing with temperature schedule and Metropolis rule.
- They test convergence with diagnostic prints (e.g., print x every 50 calls) and tune hyperparameters.
- They capture the best feasible design and record which constraints are tight.

Part 3: Built-in solver
- Use MATLAB's simulannealbnd with a penalized objective and an OutputFcn to stop early when feasible.
- Optionally chain a final fmincon refinement starting from the best SA solution to snap onto feasibility boundaries.
- Compare designs from student's own SA implementation versus built-in. How close are the times?


Student Handout for Minimizing Milling Cycle Time Assignment (Acrobat (PDF) 123kB Sep27 25) 

Teaching Notes and Tips

- Seeding matters: Always start SA from a hand-verified feasible point to reduce wasted exploration.
- Penalty tuning: begin with moderate rho (e.g., 10^5), not huge — too high penalties lock the search.
- Constraint diagnostics: instruct students to report residuals for all four constraints, and note which ones are essentially zero.


Assessment

Evaluate students on:
- Correct implementation and debugging of SA (does it converge, diagnostic prints).
- Quality of final design (cycle time, feasibility, active constraints).
- Comparative reporting: difference between DIY and built-in, discussion of solver behavior and pitfalls.

References and Resources

- Standard machining theory texts (e.g., Machining and CNC) for cutting force, tool life equations.
- MATLAB Global Optimization Toolbox documentation for simulannealbnd, fmincon.
- Example solver template and diagnostic scripts (provided by the instructor) as starter files.