/[MITgcm]/manual/s_ecco/text/optim.tex
ViewVC logotype

Annotation of /manual/s_ecco/text/optim.tex

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (hide annotations) (download) (as text)
Sat Oct 16 03:40:19 2004 UTC (20 years, 9 months ago) by edhill
Branch: MAIN
CVS Tags: checkpoint57l_post
Changes since 1.4: +3 -0 lines
File MIME type: application/x-tex
 o add HTML comments as a step towards "URL permanence" which will help
   solve:
   - stale links from the CMI web site
   - rotten indexing by bonniefy.pl
 o also cleanup a merge-mangle in diagnostics.tex

1 heimbach 1.1 \section{The line search optimisation algorithm
2     \label{sectionoptim}}
3 edhill 1.5 \begin{rawhtml}
4     <!-- CMIREDIR:lsearch_optim: -->
5     \end{rawhtml}
6 heimbach 1.1
7     \subsection{General features}
8    
9     The line search algorithm is based on a quasi-Newton
10     variable storage method which was implemented by
11 heimbach 1.4 \cite{gil-lem:89}.
12 heimbach 1.1
13     TO BE CONTINUED...
14    
15     \subsection{The online vs. offline version}
16    
17     \begin{itemize}
18     %
19     \item {\bf Online version} \\
20     Every call to {\it simul} refers to an execution of the
21     forward and adjoint model.
22     Several iterations of optimization may thus be performed within
23     a single run of the main program (lsopt\_top).
24     The following cases may occur:
25     %
26     \begin{itemize}
27     \item
28     cold start only (no optimization)
29     \item
30     cold start, followed by one or several iterations of optimization
31     \item
32     warm start from previous cold start with one or several iterations
33     \item
34     warm start from previous warm start with one or several iterations
35     \end{itemize}
36     %
37     \item {\bf Offline version} \\
38     Every call to simul refers to a read procedure which
39     reads the result of a forward and adjoint run
40     Therefore, only one call to simul is allowed,
41     {\tt itmax = 0}, for cold start
42     {\tt itmax = 1}, for warm start
43     Also, at the end, {\bf x(i+1)} needs to be computed and saved
44     to be available for the offline model and adjoint run
45     \end{itemize}
46    
47     In order to achieve minimum difference between the online and offline code
48     {\bf xdiff(i+1)} is stored to file at the end of an (offline) iteration,
49     but recomputed identically at the beginning of the next iteration.
50    
51     \subsection{Number of iterations vs. number of simulations}
52    
53     {\tt - itmax:} controls the max. number of iterations \\
54     {\tt - nfunc:} controls the max. number of simulations
55     within one iteration
56    
57     \paragraph{Summary} ~ \\
58     From one iteration to the next the descent direction changes.
59     Within one iteration more than one forward and adjoint
60     run may be performed.
61     The updated control used as input for these simulations uses the same
62     descent direction, but different step sizes.
63    
64     \paragraph{Description} ~ \\
65     From one iteration to the next the descent direction dd changes using
66     the result for the adjoint vector gg of the previous iteration.
67     In lsline the updated control
68     \[
69     \tt
70     xdiff(i,1) = xx(i-1) + tact(i-1,1)*dd(i-1)
71     \]
72     serves as input for
73     a forward and adjoint model run yielding a new {\tt gg(i,1)}.
74     In general, the new solution passes the 1st and 2nd Wolfe tests
75     so {\tt xdiff(i,1)} represents the solution sought:
76     \[
77     {\tt xx(i) = xdiff(i,1)}
78     \]
79     If one of the two tests fails,
80     an inter- or extrapolation is invoked to determine
81     a new step size {\tt tact(i-1,2)}.
82     If more than one function call is permitted,
83     the new step size is used together
84     with the "old" descent direction {\tt dd(i-1)}
85     (i.e. dd is not updated using the new {\tt gg(i)}),
86     to compute a new
87     \[
88     {\tt xdiff(i,2) = xx(i-1) + tact(i-1,2)*dd(i-1)}
89     \]
90     that serves as input
91     in a new forward and adjoint run, yielding {\tt gg(i,2)}.
92 cnh 1.2 If now, both Wolfe tests are successful,
93 heimbach 1.1 the updated solution is given by
94     \[
95     \tt
96     xx(i) = xdiff(i,2) = xx(i-1) + tact(i-1,2)*dd(i-1)
97     \]
98    
99     In order to save memory both the fields dd and xdiff
100     have a double usage.
101     %
102     \begin{itemize}
103     %
104     \item [{\tt xdiff}] ~\\
105     - in {\it lsopt\_top}: used as {\tt x(i) - x(i-1)} for Hessian update \\
106     - in {\it lsline}: intermediate result for control update
107     {\tt x = x + tact*dd}
108     %
109     \item [{\tt dd}] ~\\
110     - in {\it lsopt\_top, lsline}: descent vector, {\tt dd = -gg}
111     and {\tt hessupd} \\
112     - in {\it dgscale}: intermediate result to compute new preconditioner
113     %
114     \end{itemize}
115    
116     \paragraph{The parameter file lsopt.par}
117    
118     %
119     \begin{itemize}
120     %
121     \item {\bf NUPDATE}
122     max. no. of update pairs {\tt (gg(i)-gg(i-1), xx(i)-xx(i-1))}
123     to be stored in {\tt OPWARMD} to estimate Hessian
124     [pair of current iter. is stored in
125     {\tt (2*jmax+2, 2*jmax+3)}
126     jmax must be > 0 to access these entries]
127     Presently {\tt NUPDATE} must be > 0
128     (i.e. iteration without reference to previous
129     iterations through {\tt OPWARMD} has not been tested)
130     %
131     \item {\bf EPSX}
132     relative precision on xx bellow which xx should not be improved
133     %
134     \item {\bf EPSG}
135     relative precision on gg below which optimization is
136     considered successful
137     %
138     \item {\bf IPRINT}
139     controls verbose (>=1) or non-verbose output
140     %
141     \item {\bf NUMITER}
142     max. number of iterations of optimisation;
143     NUMTER = 0: cold start only, no optimization
144     %
145     \item {\bf ITER\_NUM}
146     index of new restart file to be created (not necessarily = NUMITER!)
147     %
148     \item {\bf NFUNC}
149     max. no. of simulations per iteration
150     (must be > 0);
151     is used if step size {\tt tact} is inter-/extrapolated;
152     in this case, if NFUNC > 1, a new simulation is performed with
153     same gradient but "improved" step size
154     %
155     \item {\bf FMIN}
156     first guess cost function value
157     (only used as long as first iteration not completed,
158     i.e. for jmax <= 0)
159     %
160     \end{itemize}
161    
162     \paragraph{OPWARMI, OPWARMD files}
163     Two files retain values of previous iterations which are
164     used in latest iteration to update Hessian:
165     \begin{itemize}
166     %
167     \item {\bf OPWARMI}: contains index settings and scalar variables
168    
169     {\footnotesize
170     \begin{tabular}{ll}
171     {\tt n = nn} & no. of control variables \\
172     {\tt fc = ff} & cost value of last iteration \\
173     {\tt isize} & no. of bytes per record in OPWARMD \\
174     {\tt m = nupdate} & max. no. of updates for Hessian \\
175     {\tt jmin, jmax} & pointer indices for OPWARMD file (cf. below) \\
176     {\tt gnorm0} & norm of first (cold start) gradient gg \\
177     {\tt iabsiter} & total number of iterations with respect to cold start
178     \end{tabular}
179     }
180     %
181     \item {\bf OPWARMD}: contains vectors (control and gradient)
182    
183     {\scriptsize
184     \begin{tabular}{cll}
185     entry & name & description \\
186     \hline
187     1 & {\tt xx(i)} & control vector of latest iteration \\
188     2 & {\tt gg(i)} & gradient of latest iteration \\
189     3 & {\tt xdiff(i),diag} & preconditioning vector; (1,...,1)
190     for cold start \\
191     2*jmax+2 & {\tt gold=g(i)-g(i-1)} & for last update (jmax) \\
192     2*jmax+3 & {\tt xdiff=tact*d=xx(i)-xx(i-1)} & for last update (jmax)
193     \end{tabular}
194     }
195     %
196     \end{itemize}
197     %
198     \begin{figure}[b!]
199     {\footnotesize
200     \begin{verbatim}
201    
202     Example 1: jmin = 1, jmax = 3, mupd = 5
203    
204     1 2 3 | 4 5 6 7 8 9 empty empty
205     |___|___|___| | |___|___| |___|___| |___|___| |___|___| |___|___|
206     0 | 1 2 3
207    
208     Example 2: jmin = 3, jmax = 7, mupd = 5 ---> jmax = 2
209    
210     1 2 3 |
211     |___|___|___| | |___|___| |___|___| |___|___| |___|___| |___|___|
212     | 6 7 3 4 5
213    
214     \end{verbatim}
215     }
216     \caption{Examples of OPWARM file handling}
217     \label{fig:opwarm}
218     \end{figure}
219    
220     \paragraph{Error handling}
221    
222    
223    
224     \newpage
225    
226 adcroft 1.3 \begin{figure}
227     %\input{part8/lsopt_flow_1}
228     {\scriptsize
229     \begin{verbatim}
230     lsopt_top
231     |
232     |---- check arguments
233     |---- CALL INSTORE
234     | |
235     | |---- determine whether OPWARMI available:
236     | * if no: cold start: create OPWARMI
237     | * if yes: warm start: read from OPWARMI
238     | create or open OPWARMD
239     |
240     |---- check consistency between OPWARMI and model parameters
241     |
242     |---- >>> if COLD start: <<<
243     | | first simulation with f.g. xx_0; output: first ff_0, gg_0
244     | | set first preconditioner value xdiff_0 to 1
245     | | store xx(0), gg(0), xdiff(0) to OPWARMD (first 3 entries)
246     | |
247     | >>> else: WARM start: <<<
248     | read xx(i), gg(i) from OPWARMD (first 2 entries)
249     | for first warm start after cold start, i=0
250     |
251     |
252     |
253     |---- /// if ITMAX > 0: perform optimization (increment loop index i)
254     | (
255     | )---- save current values of gg(i-1) -> gold(i-1), ff -> fold(i-1)
256     | (---- CALL LSUPDXX
257     | ) |
258     | ( |---- >>> if jmax=0 <<<
259     | ) | | first optimization after cold start:
260     | ( | | preconditioner estimated via ff_0 - ff_(first guess)
261     | ) | | dd(i-1) = -gg(i-1)*preco
262     | ( | |
263     | ) | >>> if jmax > 0 <<<
264     | ( | dd(i-1) = -gg(i-1)
265     | ) | CALL HESSUPD
266     | ( | |
267     | ) | |---- dd(i-1) modified via Hessian approx.
268     | ( |
269     | ) |---- >>> if <dd,gg> >= 0 <<<
270     | ( | ifail = 4
271     | ) |
272     | ( |---- compute step size: tact(i-1)
273     | ) |---- compute update: xdiff(i) = xx(i-1) + tact(i-1)*dd(i-1)
274     | (
275     | )---- >>> if ifail = 4 <<<
276     | ( goto 1000
277     | )
278     | (---- CALL OPTLINE / LSLINE
279     | ) |
280     ... ... ...
281     \end{verbatim}
282     }
283 heimbach 1.1 \caption{Flow chart (part 1 of 3)}
284     \label{fig:lsoptflow1}
285     \end{figure}
286    
287 adcroft 1.3 \begin{figure}
288     %\input{part8/lsopt_flow_2}
289     {\scriptsize
290     \begin{verbatim}
291     ... ...
292     | )
293     | (---- CALL OPTLINE / LSLINE
294     | ) |
295     | ( |---- /// loop over simulations
296     | ) (
297     | ( )---- CALL SIMUL
298     | ) ( |
299     | ( ) |---- input: xdiff(i)
300     | ) ( |---- output: ff(i), gg(i)
301     | ( ) |---- >>> if ONLINE <<<
302     | ) ( runs model and adjoint
303     | ( ) >>> if OFFLINE <<<
304     | ) ( reads those values from file
305     | ( )
306     | ) (---- 1st Wolfe test:
307     | ( ) ff(i) <= tact*xpara1*<gg(i-1),dd(i-1)>
308     | ) (
309     | ( )---- 2nd Wolfe test:
310     | ) ( <gg(i),dd(i-1)> >= xpara2*<gg(i-1),dd(i-1)>
311     | ( )
312     | ) (---- >>> if 1st and 2nd Wolfe tests ok <<<
313     | ( ) | 320: update xx: xx(i) = xdiff(i)
314     | ) ( |
315     | ( ) >>> else if 1st Wolfe test not ok <<<
316     | ) ( | 500: INTERpolate new tact:
317     | ( ) | barr*tact < tact < (1-barr)*tact
318     | ) ( | CALL CUBIC
319     | ( ) |
320     | ) ( >>> else if 2nd Wolfe test not ok <<<
321     | ( ) 350: EXTRApolate new tact:
322     | ) ( (1+barmin)*tact < tact < 10*tact
323     | ( ) CALL CUBIC
324     | ) (
325     | ( )---- >>> if new tact > tmax <<<
326     | ) ( | ifail = 7
327     | ( ) |
328     | ) (---- >>> if new tact < tmin OR tact*dd < machine precision <<<
329     | ( ) | ifail = 8
330     | ) ( |
331     | ( )---- >>> else <<<
332     | ) ( update xdiff for new simulation
333     | ( )
334     | ) \\\ if nfunc > 1: use inter-/extrapolated tact and xdiff
335     | ( for new simulation
336     | ) N.B.: new xx is thus not based on new gg, but
337     | ( rather on new step size tact
338     | )
339     | (---- store new values xx(i), gg(i) to OPWARMD (first 2 entries)
340     | )---- >>> if ifail = 7,8,9 <<<
341     | ( goto 1000
342     | )
343     ... ...
344     \end{verbatim}
345     }
346 heimbach 1.1 \caption{Flow chart (part 2 of 3)}
347     \label{fig:lsoptflow2}
348     \end{figure}
349    
350 adcroft 1.3 \begin{figure}
351     %\input{part8/lsopt_flow_3}
352     {\scriptsize
353     \begin{verbatim}
354     ... ...
355     | )
356     | (---- store new values xx(i), gg(i) to OPWARMD (first 2 entries)
357     | )---- >>> if ifail = 7,8,9 <<<
358     | ( goto 1000
359     | )
360     | (---- compute new pointers jmin, jmax to include latest values
361     | ) gg(i)-gg(i-1), xx(i)-xx(i-1) to Hessian matrix estimate
362     | (---- store gg(i)-gg(i-1), xx(i)-xx(i-1) to OPWARMD
363     | ) (entries 2*jmax+2, 2*jmax+3)
364     | (
365     | )---- CALL DGSCALE
366     | ( |
367     | ) |---- call dostore
368     | ( | |
369     | ) | |---- read preconditioner of previous iteration diag(i-1)
370     | ( | from OPWARMD (3rd entry)
371     | ) |
372     | ( |---- compute new preconditioner diag(i), based upon diag(i-1),
373     | ) | gg(i)-gg(i-1), xx(i)-xx(i-1)
374     | ( |
375     | ) |---- call dostore
376     | ( |
377     | ) |---- write new preconditioner diag(i) to OPWARMD (3rd entry)
378     | (
379     |---- \\\ end of optimization iteration loop
380     |
381     |
382     |
383     |---- CALL OUTSTORE
384     | |
385     | |---- store gnorm0, ff(i), current pointers jmin, jmax, iterabs to OPWARMI
386     |
387     |---- >>> if OFFLINE version <<<
388     | xx(i+1) needs to be computed as input for offline optimization
389     | |
390     | |---- CALL LSUPDXX
391     | | |
392     | | |---- compute dd(i), tact(i) -> xdiff(i+1) = x(i) + tact(i)*dd(i)
393     | |
394     | |---- CALL WRITE_CONTROL
395     | | |
396     | | |---- write xdiff(i+1) to special file for offline optim.
397     |
398     |---- print final information
399     |
400     O
401     \end{verbatim}
402     }
403 heimbach 1.1 \caption{Flow chart (part 3 of 3)}
404     \label{fig:lsoptflow3}
405     \end{figure}
406    

  ViewVC Help
Powered by ViewVC 1.1.22