Improving fitting technique for global optics correction

Automatic tuning for machine control
Presentation at Advanced Optics Control Workshop, CERN
Xiaobiao Huang
SSRL/SLAC
2/5/2015
Outline
• Motivation and general considerations of online optimization.
• The robust conjugate direction search (RCDS) method.
- Algorithm
- Simulation
• Examples of RCDS application.
- Coupling correction.
- Kicker bump matching.
- Dynamic aperture optimization.
• Stochastic algorithms for online optimization
- MOPSO vs. MOGA
X. Huang, Advanced Optics Control, CERN, Feb. 2015
2
The general need of online optimization
Machine performance tuning is a multi-variable (usually nonlinear)
optimization problem. Often times online optimization is needed (for
accelerators and beyond) .
• Lack of diagnostics (that monitor the sub-systems)
- Injection steering and transport line optics.
• Target values of monitors not established (or drifting)
- Initial commissioning.
• Lack of deterministic procedure to go to target values.
- Nonlinear beam dynamics in storage rings (may also meet the other two
conditions).
• Manual tuning works only for small scale problems (a few, <=4 knobs?)
and is slow. Automated tuning is needed.
-
Early automated experimental optimization of accelerators: L. Emery et al, PAC’03.
X. Huang, Advanced Optics Control, CERN, Feb. 2015
3
Algorithms for online optimization
• Requirements
- High efficiency – get to the optimum fast
• Online evaluation of the objective is usually slow.
• Machine study time is usually limited (and expensive).
• Efficiency may be measured by the number of function evaluations.
- Robustness – surviving noise, outliers and machine failures
- (Live status reporting during optimization.)
• Candidates:
-
Gradient based method are not considered because of noise.
Iterative 1D scan (that automates manual tuning procedure)
Powell’s conjugate direction method
Nelder-Mead (downhill) simplex method
MOGA?
MOPSO
Robust conjugate direction method (RCDS*) – A combination of conjugate
direction method and a new noise resistant line optimizer.
*X. Huang, et al, Nucl. Instr. Methods, A 726 (2013) 77-83.
X. Huang, Advanced Optics Control, CERN, Feb. 2015
4
The RCDS algorithm for noisy function optimization
• Powell’s conjugate direction method
Powell’s method* has two components:
1. A procedure to update the direction set
to make it a conjugate set.
2. A line optimizer that looks for the
minimum along each direction.
Directions u, v are conjugate if:
𝐮 ∙ 𝐇 ∙ 𝐯 = 0 where the Hessian matrix
is defined
𝜕2𝑓
𝐻𝑖𝑗 =
𝜕𝑥𝑖 𝜕𝑥𝑗
Iterative parameter scan can be very inefficient.
*W.H. Press, at al, Numerical Recipes
*M.J.D. Powell, Computer Journal 7 (2) 1965 155
X. Huang, Advanced Optics Control, CERN, Feb. 2015
5
The robust line optimizer
-0.5
-0.6
objective
Replaced by
bracketing
fill-in
fitted
new minimum
-0.7
-0.8
Inverse parabolic interpolation (figure from
Numeric.Recipe.)
-0.9
-0.06
Initial solution
-0.04
-0.02

0
0.02
Step 1: bracketing the minimum with noise considered.
Step 2: Fill in empty space in the bracket with solutions and perform quadratic
fitting. Remove any outlier and fit again. Find the minimum from the fitted curve.
Global sampling within the bracket helps reducing the noise effect.
RCDS is Powell’s conjugate method* + the new robust line optimizer.
*however, since the online run time is usually short, it is important to provide good an
initial conjugate direction set which may be calculated with a model.
X. Huang, Advanced Optics Control, CERN, Feb. 2015
6
Simulation – SPEAR3 storage ring coupling correction
• Using calculated beam loss rate as the objective function.
• Noise is generated in the objective function by adding random
noise to beam current values (used for loss rate calculation).
• There are 13 coupling correction skew quads in SPEAR3.
• Initial conjugate direction set is from SVD of the Jacobian matrix of
orbit response matrix w.r.t. skew quads
• With
- 500 mA beam current with 1% random variation. On top of that a DCCT noise with
sigma = 0.003 mA. The beam loss rate noise evaluated from 6-s duration is 0.06
mA/min.
- 40 hour gas lifetime; 10 hour Touschek lifetime with 0.2% coupling.
- The coupling ratio with all 13 skew quads off is 0.9% (with simulated error),
corresponding to a loss rate of 0.6 mA/min.
X. Huang, Advanced Optics Control, CERN, Feb. 2015
7
Comparison of algorithms in simulation: coupling
correction
-0.5
10
-2
RCDS
simplex
Powell
IMAT
MOGA
coupling ratio
objective (mA/min)
-1
-1.5
RCDS
simplex
Powell
IMAT
MOGA
-2
-2.5
-3
0
500
1000
count
1500
2000
10
-3
10
-4
0
500
1000
count
1500
2000
The IMAT method uses the same RCDS line optimizer, but keep the direction set of unit
vectors (not conjugate).
Clearly,
(1) The line optimizer is robust against noise.
(2) Searching with a conjugate direction set is much more efficient.
(3) Original Powell’s method, downhill simplex and MOGA are not effective for
noisy problems.
Note that the direction set has been updated only about 8 times after 500 evaluations (out
of 13 directions). So the high efficiency of RCDS is mostly from the original direction set.
X. Huang, Advanced Optics Control, CERN, Feb. 2015
8
Simulation: injection into SPEAR3
BTS transport line optics matching:
Varying 6 quads in BTS for optics matching between transport line and storage ring.
Noise is generated from the finiteness of the number of particles.
With 1000 particles in a distribution, the noise sigma of injection efficiency is 1.6%.
Initial conjugate direction set is from SVD of beam moments (elements of the -matrix) w.r.t. quads.
Dynamic aperture of the ring is intentionally shrunk to 12.5 mm in the simulation.
injection efficiency
0.85
0.8
0.75
RCDS
simplex
Powell
IMAT
MOGA
0.7
0.65
0.6
0
200
400
count
600
800
1000
Performance similar to the coupling study is observed.
X. Huang, Advanced Optics Control, CERN, Feb. 2015
9
Solutions for injection optimization
Initial solution: 61.7%
2
1
0.5
yp (mrad)
xp (mrad)
1
0
-1
-2
-20
-0.5
-10
0
x (mm)
10
-1
-4
20
0
y (mm)
2
4
2
4
0.5
yp (mrad)
1
xp (mrad)
-2
Best RCDS solution:
85.0%
1
2
0
-1
-2
-20
0
0
-0.5
-10
0
x (mm)
10
X. Huang, Advanced Optics Control, CERN, Feb. 2015
20
-1
-4
-2
0
y (mm)
10
Application of RCDS in experiments
• Application to SPEAR3
- Coupling correction
• w/ loss rate
• w/ vertical beam size
-
Kicker bump matching
Injected beam steering
Transport line optics matching
Gun-to-Linac steering and optics
Dynamic aperture (injection efficiency)
• Application elsewhere
- LCLS undulator taper profile (J. Wu, et al)
- BEPC-II luminosity (H. Ji, Y. Jiao, et al)
- ALS injection (C. Sun)
X. Huang, Advanced Optics Control, CERN, Feb. 2015
11
Coupling correction w/ loss rate
2-27-2013
0
-loss rate (mA/min)
all
best
-0.5
-1
-1.5
-2
0
50
100
count
150
200
250
Beam loss rate is measured by monitoring the beam current change on 6-second interval (no
fitting). Noise sigma 0.04 mA/min.
Data were taken at 500 mA with 5-min top-off.
Initially setting all 13 skew quads off. Loss rate at about 0.4 mA/min.
Final loss rate at about 1.75 mA/min.
At 500 mA, the best solution had a lifetime of 4.6 hrs. This was better than the LOCO correction
(5.2 hrs)
On a later shift (5/6/2013), with 6-s DCCT data fit for loss rate, loss rate reached >2.0 mA/min at 500 mA
and lifetime was 4.2 hrs.
X. Huang, Advanced Optics Control, CERN, Feb. 2015
12
Kicker bump matching
SPEAR3 has three injection kickers (horizontal) located in three neighboring straight
sections. The transient residual oscillation of the stored beam after injection needs
to be minimized.
Parameters: Adjusting pulse amplitude, pulse width and timing delay of K1 and K3
(with K2 fixed) and two skew quads for vertical plane, 8 parameters total.
Objective: sum of rms(x) and rms(y) of turn-by-turn orbit (for 30~300 turns).
3-25-2013, LE lattice
250
all
best
400
150
100
50
1000
objective (micron)
objective (micron)
objective (micron)
6-3-2013, LA20 lattice, 2nd attempt
500
1200
200
0
0
3-26-2013, LA20 lattice
1400
800
600
300
200
100
0
0
400
50
100
150
count
200
250
300
200
20
40
60
count
80
100
120
0
0
50
100
150
200
count
250
300
350
400
First time of getting kicker bump
for low alpha lattice matched.
X. Huang, Advanced Optics Control, CERN, Feb. 2015
13
BTS optics
For injection optics matching, ideally we need to decouple the steering effect of
quadrupole changes (when beam trajectory is off-center). But we haven’t done
that yet.
To test the algorithm, we changed the 9 BTS quads setpoints randomly to mess
up injection and use the code to bring injection back.
3-12-2013, BTS quads
0
Knobs: 9 BTS quads.
Objective: injection efficiency.
-20
inj eff (%)
-40
all
best
-60
-80
-100
0
X. Huang, Advanced Optics Control, CERN, Feb. 2015
10
20
count
30
40
50
14
SPEAR3 nonlinear dynamics optimization*
• 10 independently powered sextupole groups
• reduced the kicker bump by 34% to have a low initial injection efficiency
• Injector is detuned to lower total beam loss during experiment.
• Knobs: 8 variables in the subspace of the 10-dim parameter space that keep
chromaticities fixed (basis of the null space of the chromaticity response matrix).
• Objective: Injection efficiency calculated as beam current change over 10 seconds
normalized by average Booster beam current within the period.
* The SPEAR3 DA optimization
study is an ongoing collaboration
with James Safranek.
X. Huang, Advanced Optics Control, CERN, Feb. 2015
15
Objective function for all evaluated solutions
0
The code RCDS completed
a little more than 2
iterations in total.
-1
-1.5
-2
-2.5
-3
Kicker bump 66%
Kicker bump 78%
-3.5
0
50
100
solution
150
200
200
160
140
120
ISD (Amp)
ISF (Amp)
objective (arb. unit)
-0.5
100
80
nominal
optimized
60
40
0
50
100
150
200
s (m)
X. Huang, Advanced Optics Control, CERN, Feb. 2015
150
100
nominal
optimized
250
50
0
50
100
s (m)
150
200
250
16
Measurement of dynamic aperture
1
2
2.3 mm
0.8
1
I/I0
xp (mrad)
0.6
0.4
0.2
0
0
2.3 mm
nominal
optimzed
0.5
1.5
Actual DA = bump limit + 5𝜎 (stored
beam)
Nominal: 15.9 mm
Optimized: 18.4 mm.
X. Huang, Advanced Optics Control, CERN, Feb. 2015
0
-1
2.5 mm
1
K1 voltage (kV)
nominal, K1=1.25 kV
optimized, K1=1.47 kV
2
-2
-20
-15
-10
-5
0
x (mm)
5
10
15
Phase space at septum exit by tracking
with calculated kick.
Difference on the negative side: 2.3 mm.
17
Stochastic algorithms for online optimization
• Stochastic algorithms give more assurance in finding the global optimum,
but are less efficient.
• Particle swarm optimization (PSO) algorithm or genetic algorithms (GA)?
- There are studies that show particle swarm method is much more efficient
than a typical genetic algorithm (NSGA-II)[1-2], due to high diversity of solutions
in the former.
- Results of genetic algorithms are twisted by noise-introduced bias[3].
6s loss rate evaluation time
Diversity of PSO solutions is
significantly better than GA
solutions. [2]
average error (mA/min)
0.02
-0.02
-0.04
-0.06
-0.08
-0.1
0
X. Huang, Advanced Optics Control, CERN, Feb. 2015
Solutions luckier than the
average by nearly two sigma
dominate the population in this
example. [3]
0
10
20
30
generation
40
50
[1] X. Pang, et al, NIMA 741 (2014) 124
[2] X. Huang, et al, NIMA 757 (2014) 48
[3] X. Huang, et al, NIMA 726 (2013) 77-83.
60
18
Comparison of GA and PSO performance: an example
SPEAR3 coupling correction with loss monitor data.
K. Tian, et al, PRSTAB 17, 020703 (2014)
GA (NSGA-II)
PSO
Note: (1) loss monitor data noise is considerably lower than DCCT loss over 6
seconds (as was used for RCDS test). With the latter GA may not work (see
backup slide).
(2) To reach the same level of coupling, GA requires ~20000 evaluations, PSO
~3000 evaluations, RCDS ~300 evaluations.
X. Huang, Advanced Optics Control, CERN, Feb. 2015
19
Summary
• There is a need of online optimization algorithm in the era of
computerized control. Biggest challenge to conventional algorithms is
noise in function evaluation.
• The RCDS method is demonstrated to be robust against noise and
efficient when conjugate direction set is supplied.
• The RCDS method has been successfully applied to many accelerator
optimization problems.
• When stochastic algorithms are desired, the particle swarm method
(PSO) is preferred.
Matlab code of RCDS is available from X. Huang
X. Huang, Advanced Optics Control, CERN, Feb. 2015
20
Backup plots
15
Skew quad solutions found by RCDS are
similar to that of LOCO.
10
current (A)
5
0
-5
run 2-27-2013
run 3-26-2013
run 4-23-2013
LOCO 2-13-2013
LOCO 4-23-2013
-10
-15
-20
0
2
4
6
8
skew quad index
10
12
14
Basis of the null space of the
chromaticity response matrix,
which are used as independent
knobs in DA optimization.
X. Huang, Advanced Optics Control, CERN, Feb. 2015
current (normalized)
1
0.5
0
-0.5
0
2
4
6
sextupole family
8
10
21
Momentum aperture measurement
Lifetime [hr], current/10[mA]
15
nominal
optimized
10
5
0
1400
1600
1800
2000 2200 2400 2600
RF gap voltage [MV]
2800
3000
3200
Lifetime vs. RF gap voltage (100 mA in 80 bunches,Touschek lifetime dominated)
The optimized sextupole setting may have a smaller minimum MA, corresponding
to 3100 kV (bucket height 2.55%). SPEAR is operated at 2850 kV for 500 mA.
X. Huang, Advanced Optics Control, CERN, Feb. 2015
22
Comparison of DA by tracking simulation
nominal sextupole setting
5
y (mm)
4
2% error: -13.9
on energy: -16.5
16.2
15.7
lat lelt wIDs, 5000 turns
3
on energy best/worst
on energy mean
2% best/worst
2% mean
2
1
0
-20
5
y (mm)
4
-15
2% error: -8.54
on energy: -16.8
-10
-5
0
5
x (mm)
optimized sextupole setting
10
11.2
14.1
15
20
lat lelt wIDs, 5000 turns
3
on energy best/worst
on energy mean
2% best/worst
2% mean
2
1
0
-20
-15
-10
-5
0
x (mm)
5
10
15
20
Chromaticities are [3, 3], with 20 seeds of linear and multipole errors, 1% beta beating, 0.2%
coupling. With radiation damping. With effects of IDs.
X. Huang, Advanced Optics Control, CERN, Feb. 2015
23
GA with noise in objective function
NSGA-II
10
run1 6s
run2 10s
run3 no noise
-0.6
-0.8
-1
-1.2
0
1000
2000
3000
cnt
NSGA-II
-2
coupling ratio
objective (mA/min)
-0.4
4000
5000
6000
-3
10
run1 6s
run2 10s
run3 no noise
-4
10
0
1000
2000
3000
cnt
4000
5000
6000
Objective function (beam loss) for the 6-second case is noisier.
(1) The objective function may appear to be better (before cnt=5000), the actual
coupling is not.
(2) With larger noise in data, GA (NSGA-II) fails to make further improvement.
X. Huang, et al, NIMA 726 (2013) 77-83.
X. Huang, Advanced Optics Control, CERN, Feb. 2015
24