Numerical Optimization I: One Dimension
Eugeniy E. Mikhailov and Greg Bentsen
Logistics and Agenda
Homework 4 due Monday Oct 19 at 11:59pm
Agenda
- This week: Optimization in 1D
- Next week: Opimization in multiple dimensions + combinatoric
optimization
Today
- Optimization in one dimension
- Local versus global minima
- Revisit root-finding: bisection and Newton–Raphson
- Golden-section search: minimize without derivatives
- Motivation: protein folding
Numerical Optimization
What is optimization?
Many problems in physics ask us to find the best value of a
variable
.
- Mechanics: find configurations of minimum potential
energy.
- Data fitting: choose parameters that minimize
.
- Statistical mechanics: find energetically favorable states.
Question: How can a computer find
if we only know how to evaluate
?
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:
- Hydrogen bonding, electrostatic interactions, hydrophobic effects,
van der Waals forces, etc.
- The resulting structure determines much of the protein’s biological
function.
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
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:
- Build a dramatically simplified model that captures the competition
between different physical interactions.
- Use numerical optimization to find the lowest-energy
configurations.
A Toy Protein-Folding Model
Three beads, two links, one angle
Consider three beads constrained to a 2D plane, connected by two
rigid links of length
.
- Fix the position of bead 1 and the direction of the first link.
- The single degree of freedom is the bending angle
.
- The straight chain corresponds to
.
Source: generated with ChatGPT
Geometry: by the law of cosines,
Competing energies
We combine a bending penalty and an
attractive bead-bead interaction:
- :
bending stiffness (straight configurations favored)
- :
bead-bead interaction strength (negative energy near
)
- :
preferred bead-bead separation
- :
width of the interaction well
Default parameters:
,
,
,
,
.
Source: generated with ChatGPT
Competition: bending penalty versus attraction
between beads
Demo: python code/folding_1d.py
Local and global minima
Default parameters:
,
,
,
,
.
At the default parameters the landscape has three local
minima:
- :
a metastable straight configuration,
.
- :
two symmetry-related folded ground states,
.
- Local maxima separate the minima at
.
Why two ground states?
:
mirror-related configurations have the same energy.
Optimization with Derivatives
Connection to root finding
For an interior stationary point, we require
We already know two methods for solving equations of the form
:
- Bisection: find a sign change of
and repeatedly halve the bracket.
- Newton–Raphson: iterate
.
But beware: a stationary point could be a minimum or
maximum.
Boundary minima also need to be checked separately.
Differentiating the folding energy
Let
,
where
.
- Solving
finds stationary configurations.
- In mechanics, this is a zero-torque condition (similar to zero
forces).
Demo: python code/root_vs_min.py
What can go wrong?
- Bisection on
may converge to a maximum.
- Newton–Raphson depends on its initial guess and may also find
maxima.
- To distinguish minima from maxima, we can compute
(concave vs convex)
- We can also compare the energy
itself
- A derivative root alone does not establish the
global minimum.
In addition, in some situations the derivative
may be unavailable or expensive to compute.
Question: Could we locate a minimum using only
evaluations of
,
without any derivatives?
Derivative-Free Optimization
The idea behind golden-section search
Assume
is unimodal over an interval
:
it decreases toward a single minimum and increases afterward.
Choose two interior points
.
- If
,
a minimum remains in
.
- If
,
a minimum remains in
.
- Repeat until the remaining interval is sufficiently narrow.
Unlike bisection, we compare function values, not
signs of derivatives.
Why the golden ratio?
Choose points with the same fractional spacing at each iteration:
The choice
ensures that one interior point survives and its stored
-value
can be reused.
- Two function evaluations to initialize.
- Only one new function evaluation per
iteration.
- Bracket width shrinks by
each iteration.
Source: generated with ChatGPT
Demo:
python code/golden_section_stepper.py
How many iterations?
After
iterations, the bracket width is
To obtain
:
Example: Starting from
,
estimate the number of iterations needed for
.
(Each iteration costs one new energy evaluation after
initialization.)
Live coding — golden-section search
Task: Implement a function with the interface
def golden_section(f, a, b, tol=1e-6):
"""Find the minimum of a unimodal function on [a,b]."""
# Initialize interior points and their function values.
# Repeatedly discard the worse side, reusing one value.
# Return the midpoint of the final bracket.
Validate using
over
Reference solution and animation:
python code/golden_section.py
Bracket choice matters
|
Straight metastable state |
|
Folded state, positive angle |
|
Folded state, negative angle |
|
No guarantee: function is not unimodal |
Surprise: On our symmetric example, golden-section
search on the full interval converges near
,
which is not the global minimum.
How could we search more globally?
A simple strategy in one dimension:
- Evaluate the energy on a coarse grid.
- Identify promising intervals containing local minima.
- Run a local optimizer in each interval.
- 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
- Optimization asks us to minimize an objective
function.
- Root-finding can locate stationary points when derivatives are
available; not every stationary point is a minimum.
- Golden-section search is derivative-free,
inexpensive, and reliable for a unimodal bracket.
- Efficient local minimization is different from
finding the global minimum.
Next lecture: four- and five-bead chains, energy
landscapes in several dimensions, and gradient descent as an iterated
map.