Numerical Optimization I: One Dimension

Eugeniy E. Mikhailov and Greg Bentsen

Logistics and Agenda

Homework 4 due Monday Oct 19 at 11:59pm


Agenda


Today

Numerical Optimization

What is optimization?

Many problems in physics ask us to find the best value of a variable xx.

x*=argminx∈[a,b]f(x)\boxed{x_* = \arg\min_{x\in[a,b]} f(x)}


Question: How can a computer find x*x_* if we only know how to evaluate f(x)f(x)?

Local and global minima

A local minimum has lower energy than nearby configurations.

A global minimum has the lowest energy among all allowed configurations.

Why is it easy for a numerical method to mistake a local minimum for a global minimum?

Protein Folding

Protein Folding: a grand challenge in physics & biology

Proteins are chains of amino acids that fold into complex three-dimensional structures.

Folding is driven by competing chemical interactions:


Source: https://www.drugdesign.org/chapters/protein-structure/
Source: https://www.drugdesign.org/chapters/protein-structure/

Protein Folding and Optimization

The challenge: Given a sequence of amino acids, what spatial structures can the protein adopt?

  • Finding stable configurations is naturally an energy minimization problem.
  • An enormous number of possible configurations!
  • Each configuration is a local minimum (optimum) in an extremely complicated energy landscape.
https://phys.org/news/2024-01-breakthrough-complicated-protein.html
https://phys.org/news/2024-01-breakthrough-complicated-protein.html


Recent breakthrough: AlphaFold used AI to predict protein structures with remarkable accuracy, revolutionizing structural biology and contributing to the 2024 Nobel Prize in Chemistry.

Protein Folding and Optimization

Today:

A Toy Protein-Folding Model

Competing energies

We combine a bending penalty and an attractive bead-bead interaction:

E(θ)=κ(1−cosθ)−ϵexp[−(2acos(θ/2)−r0)22σ2]\boxed{E(\theta)=\kappa(1-\cos\theta)-\epsilon\exp\!\left[-\frac{(2a\cos(\theta/2)-r_0)^2}{2\sigma^2}\right]}

  • κ\kappa: bending stiffness (straight configurations favored)
  • ϵ\epsilon: bead-bead interaction strength (negative energy near r13=r0r_{13}=r_0)
  • r0r_0: preferred bead-bead separation
  • σ\sigma: width of the interaction well
Default parameters: a=1, \kappa=1, \epsilon=3, r_0=1, \sigma=0.2.
Default parameters: a=1a=1, κ=1\kappa=1, ϵ=3\epsilon=3, r0=1r_0=1, σ=0.2\sigma=0.2.
Source: generated with ChatGPT
Source: generated with ChatGPT

Competition: bending penalty versus attraction between beads

Demo: python code/folding_1d.py

Local and global minima

Default parameters: a=1a=1, κ=1\kappa=1, ϵ=3\epsilon=3, r0=1r_0=1, σ=0.2\sigma=0.2.

At the default parameters the landscape has three local minima:


Why two ground states? E(−θ)=E(θ)E(-\theta)=E(\theta): mirror-related configurations have the same energy.

Optimization with Derivatives

Connection to root finding

For an interior stationary point, we require

dEdθ|θ*≡E′(θ*)=0.\boxed{\left.\frac{d E}{d \theta}\right\rvert_{\theta^*} \equiv E'(\theta_*)=0.}

We already know two methods for solving equations of the form g(x)=0g(x)=0:

But beware: a stationary point could be a minimum or maximum.

E(2)(θ*)>0:local minimum,E(2)(θ*)<0:local maximum.E^{(2)}(\theta_*)>0:\ \text{local minimum},\qquad E^{(2)}(\theta_*)<0:\ \text{local maximum}.

Boundary minima also need to be checked separately.

Differentiating the folding energy

Let r=r13(θ)=2acos(θ/2)r=r_{13}(\theta) = 2a\cos(\theta/2), where ∂r/∂θ≡r′=−asin(θ/2)\partial r / \partial \theta \equiv r'=-a\sin(\theta/2).

E′(θ)=κsinθ+ϵσ2(r−r0)r′exp[−(r−r0)22σ2].E'(\theta)=\kappa\sin\theta+\frac{\epsilon}{\sigma^2}(r-r_0)r'\exp\!\left[-\frac{(r-r_0)^2}{2\sigma^2}\right].


Demo: python code/root_vs_min.py

What can go wrong?

In addition, in some situations the derivative E′(θ)E'(\theta) may be unavailable or expensive to compute.

Question: Could we locate a minimum using only evaluations of EE, without any derivatives?

Derivative-Free Optimization

Why the golden ratio?

Choose points with the same fractional spacing at each iteration:

x1=b−b−aφ,x2=a+b−aφ,φ=1+52.x_1=b-\frac{b-a}{\varphi},\qquad x_2=a+\frac{b-a}{\varphi},\qquad\varphi=\frac{1+\sqrt5}{2}.

The choice φ2=φ+1\varphi^2=\varphi+1 ensures that one interior point survives and its stored ff-value can be reused.

  • Two function evaluations to initialize.
  • Only one new function evaluation per iteration.
  • Bracket width shrinks by 1/φ≈0.6181/\varphi\approx0.618 each iteration.
Source: generated with ChatGPT
Source: generated with ChatGPT


Demo: python code/golden_section_stepper.py

How many iterations?

After nn iterations, the bracket width is

Ln=φ−nL0.L_n=\varphi^{-n}L_0.

To obtain Ln≤δL_n\le\delta:

n≥ln(L0/δ)lnφ.\boxed{n\ge\frac{\ln(L_0/\delta)}{\ln\varphi}.}

Example: Starting from L0=0.6L_0=0.6, estimate the number of iterations needed for δ=10−6\delta=10^{-6}.

(Each iteration costs one new energy evaluation after initialization.)

Bracket choice matters

Initial bracket Expected minimum
[−0.5,0.5][-0.5,0.5] Straight metastable state
[1.8,2.4][1.8,2.4] Folded state, positive angle
[−2.4,−1.8][-2.4,-1.8] Folded state, negative angle
[−π,π][-\pi,\pi] No guarantee: function is not unimodal

Surprise: On our symmetric example, golden-section search on the full interval converges near θ=0\theta=0, which is not the global minimum.

How could we search more globally?

A simple strategy in one dimension:

  1. Evaluate the energy on a coarse grid.
  2. Identify promising intervals containing local minima.
  3. Run a local optimizer in each interval.
  4. Compare the resulting energies (and check the endpoints).


This strategy helps explore a multimodal landscape but does not guarantee finding an arbitrarily narrow, hidden minimum.

Challenge: What becomes harder when there are two or three independent bending angles?

Review


Next lecture: four- and five-bead chains, energy landscapes in several dimensions, and gradient descent as an iterated map.