Skip to content
Dilara Caglar
CourseworkCompleted course assignment

Autodiff, SQP and Topology Optimization

From-scratch SQP in JAX and a SIMP cantilever study; SQP converged in 6 iterations while the topology run ended infeasible.

My contribution

I implemented the core pieces inside the course's JAX starter notebooks: the vectorized constraint and Jacobian evaluation, the KKT step solve, the backtracking Armijo line search with an adaptive penalty, and the user objective and plots for the SIMP cantilever.

Affiliation
Computational Design of Cyber-Physical Systems
Dates
Spring 2026
Role
Individual assignment on course starter notebooks
Topics
Optimization and Simulation
Tools
JAX, Python
Contents
  1. The problem
  2. My contribution
  3. Constraints
  4. Design decisions
  5. What was difficult
  6. Evidence
  7. Current status
  8. What I would change next

01

The problem

I needed a constrained optimizer I fully understood, because every later project in the course is an optimization problem. That meant knowing where automatic differentiation can mislead, what guarantees a descent step, and how the KKT conditions become an algorithm. I then applied it to topology optimization, the method behind lightweight brackets and aerospace parts.

02

My contribution

I implemented the core pieces inside the course's JAX starter notebooks: the vectorized constraint and Jacobian evaluation, the KKT step solve, the backtracking Armijo line search with an adaptive penalty, and the user objective and plots for the SIMP cantilever. The course staff provided the FEM assembly, mesh and plotting scaffolding. I also wrote the derivations by hand (descent guarantee, Lagrangian, KKT matrix).

03

Constraints

The SQP problem was small (4 variables, 3 equality constraints), but the topology problem had 600 design variables and a fixed budget of 80 SLSQP iterations. Everything ran in Colab with 64-bit precision turned on, which is slower but matters for optimization accuracy.

04

Design decisions

I wrote SQP from scratch rather than calling a library solver, so I could see each piece working. For the merit function I chose a quadratic penalty and increased ρ by 10× whenever the step was not a descent direction, because the slope is ∇fᵀp − ρ‖c‖², so a large enough ρ always makes it negative. For topology optimization I used SIMP with penalty 3 and a density filter, the standard choice because it pushes material to solid or void and prevents checkerboarding.

05

What was difficult

Two things surprised me. JAX returned a derivative of 2.0 at the kink of |2x + ln 3|, where no derivative exists, which showed me autodiff reports a one-sided slope with no warning. Separately, the topology run ended infeasible: the volume fraction drifted to about 0.45 against a 0.40 limit, and the compliance history briefly went negative, which is physically impossible and points to a nearly singular stiffness matrix at an early iterate. I documented both rather than hiding them.

06

Evidence

SQP converged in 6 iterations to f(x*) = 1.5490, with constraint violation 4.7 × 10⁻¹⁴ and stationarity 6.4 × 10⁻¹³; it dropped from 3.1 × 10⁻³ to 4.7 × 10⁻¹⁴ in two iterations, the superlinear convergence Newton's method predicts. The cantilever reached a compliance of 194.16 with a clear truss layout, and I have the convergence, merit, volume and deflection plots.

07

Current status

Simulation only: a completed course assignment in JAX notebooks.

08

What I would change next

I would fix the volume constraint first, with a longer iteration budget, a tighter constraint tolerance, or an optimality-criteria update designed for this problem. I would also guard non-smooth points explicitly instead of trusting autodiff there.

Related work