~simon-funke/+junk/FEniCS12

« back to all changes in this revision

Viewing changes to libadjoint.tex

  • Committer: Simon Funke
  • Date: 2012-06-05 16:27:08 UTC
  • Revision ID: simon.funke@gmail.com-20120605162708-8p7zz6eblgfdgalt
...

Show diffs side-by-side

added added

removed removed

Lines of Context:
181
181
 
182
182
}
183
183
 
184
 
\frame{
185
 
\frametitle{The functional gradient of Example problem}
186
 
\begin{figure}[h!]
187
 
\includegraphics[width=0.45\textwidth]{pics/turbine_optimisation_forward}
188
 
\caption{The predicted velocity field. The velocity in the two turbine areas is clearly reduced.}
189
 
\end{figure}
190
 
 
191
 
 
192
 
\begin{figure}
193
 
\includegraphics[width=0.45\textwidth]{pics/turbine_optimisation_gradient}
194
 
\caption{The sensitivity solution of the power output. More (Less) drag in the dark red  (blue) areas leads to more power.}
195
 
\end{figure}
196
 
}
197
 
 
198
 
\frame
199
 
{
200
 
\frametitle{Adjoint vs. finite differences for gradient computation}
201
 
\begin{block}{Adjoint \hspace{2cm}  \hspace{2.5cm} Finite differences}
202
 
  \vspace{-0.5cm}
203
 
  \begin{columns}
204
 
    % TODO: Make a table out of it
205
 
    \column[t]{.5\textwidth}
206
 
      \begin{itemize}
207
 
        \item Computational expense \textbf{independent} of the number of controls. 
208
 
        \item Does \textbf{not} suffer from truncation error. 
209
 
        \item DOLFIN (Python) can \textbf{automatically} derive and solve the adjoint equation.
210
 
      \end{itemize}
211
 
    \column[t]{.5\textwidth}
212
 
      \begin{itemize}
213
 
        \item Computational expense increases linearly with the number of controls. 
214
 
        \item Suffers from truncation error. 
215
 
        \item Easy to implement.
216
 
      \end{itemize}
217
 
  \end{columns}
218
 
\end{block}
219
 
}
220
 
\note{
221
 
\begin{itemize}
222
 
  \item For 1: We saw that the computational expense using the adjoint is independent of the choice of $m$. The finite difference approach requires a functional evaluation for each control, hence its expense increases linearly with the number of controls.
223
 
  \item For 2: Even for the optimal choice of h in [f(x+h) - f(x)] / h only about 1/2 to 2/3 of the digits are correct. 
224
 
  \item For 3: Finite difference has the advantage of its ease implementation. However, there are powerful tools available to facilitate the development of an adjoint model.
225
 
\end{itemize}
226
 
}
 
184
%\frame
 
185
%{
 
186
%\frametitle{Adjoint vs. finite differences for gradient computation}
 
187
%\begin{block}{Adjoint \hspace{2cm}  \hspace{2.5cm} Finite differences}
 
188
%  \vspace{-0.5cm}
 
189
%  \begin{columns}
 
190
%    % TODO: Make a table out of it
 
191
%    \column[t]{.5\textwidth}
 
192
%      \begin{itemize}
 
193
%        \item Computational expense \textbf{independent} of the number of controls. 
 
194
%        \item Does \textbf{not} suffer from truncation error. 
 
195
%        \item DOLFIN (Python) can \textbf{automatically} derive and solve the adjoint equation.
 
196
%      \end{itemize}
 
197
%    \column[t]{.5\textwidth}
 
198
%      \begin{itemize}
 
199
%        \item Computational expense increases linearly with the number of controls. 
 
200
%        \item Suffers from truncation error. 
 
201
%        \item Easy to implement.
 
202
%      \end{itemize}
 
203
%  \end{columns}
 
204
%\end{block}
 
205
%}
 
206
%\note{
 
207
%\begin{itemize}
 
208
%  \item For 1: We saw that the computational expense using the adjoint is independent of the choice of $m$. The finite difference approach requires a functional evaluation for each control, hence its expense increases linearly with the number of controls.
 
209
%  \item For 2: Even for the optimal choice of h in [f(x+h) - f(x)] / h only about 1/2 to 2/3 of the digits are correct. 
 
210
%  \item For 3: Finite difference has the advantage of its ease implementation. However, there are powerful tools available to facilitate the development of an adjoint model.
 
211
%\end{itemize}
 
212
%%}
227
213
 
228
214
\section{Applications}
229
215
\frame{
255
241
\end{itemize}
256
242
}
257
243
 
258
 
%\frame
259
 
%{
260
 
%\frametitle{Cheap functional evaluation for linear problems}
261
 
%
262
 
%Consider a linear problem (i.e. $F$ and $J$ are linear in $u$) of the form:
263
 
%\begin{align*}
264
 
%  J(u) & = (j, u), & j \in \mathbb{R}^n, \\
265
 
%  F(u, m) & = Au - b(m) = 0, & A \in \mathbb{R}^{n \times n}, b\in \mathbb{R}^n.
266
 
%\end{align*}
267
 
%The associated adjoint equation is $A^*\lambda = j$.
268
 
%
269
 
%Then:
270
 
%\begin{equation*}
271
 
%  J(u) = (A^*\lambda, u) = (\lambda, Au ) = (\lambda, b(m) ).
272
 
%\end{equation*}
273
 
274
 
%$\to$ With the adjoint, the functional evaluation for \textbf{any} $m$ requires only an inner product! %TOO: Check if inner product is the right word ere
275
 
%}
 
244
\frame{
 
245
\frametitle{The turbine optimisation problem}
 
246
\begin{figure}[h!]
 
247
\includegraphics[width=0.4\textwidth]{50turbines/initial_turbines.png}
 
248
\includegraphics[width=0.4\textwidth]{50turbines/final_turbines.png}\\
 
249
\includegraphics[width=0.4\textwidth]{50turbines/functional_plot.png}
 
250
\caption{Initial and optimised turbine positions and the power increase.}
 
251
\end{figure}
 
252
 
 
253
}
 
254
 
276
255
 
277
256
 
278
257
\frame
370
349
%}
371
350
 
372
351
 
373
 
\section{Three ways to adjoint a model}
374
352
\frame{
375
353
\frametitle{Outline}
376
354
\tableofcontents[currentsection]
429
407
\begin{center}
430
408
\includegraphics[width=0.8\textwidth]{pics/adjoint_types_continuous}
431
409
\end{center}
432
 
\onslide<2->
433
 
\begin{block}{The continuous adjoint is ...}
434
 
...  a system of linear equations that can be discretised and solved in a similar manner to the forward model.
435
 
\begin{itemize}
436
 
\item \color{darkgreen} No problems with non-differentiable numerical schemes in the forward discretisation.
437
 
\item \color{red} Specific to one problem.
438
 
\end{itemize}
439
 
\end{block}
 
410
%\onslide<2->
 
411
%\begin{block}{The continuous adjoint is ...}
 
412
%...  a system of linear equations that can be discretised and solved in a similar manner to the forward model.
 
413
%\begin{itemize}
 
414
%\item \color{darkgreen} No problems with non-differentiable numerical schemes in the forward discretisation.
 
415
%\item \color{red} Specific to one problem.
 
416
%\end{itemize}
 
417
%\end{block}
440
418
}
441
419
 
442
420
%\subsection{Automatic differentiation}
446
424
\begin{center}
447
425
\includegraphics[width=0.8\textwidth]{pics/adjoint_types_AD}
448
426
\end{center}
449
 
\onslide<2->
450
 
\begin{block}{The adjoint of the source code...} 
451
 
... is usually obtained by applying an AD tool.
452
 
\begin{itemize}
453
 
\item \color{darkgreen} Can sometimes be obtained automatically from the source code
454
 
\item \color{red} Does not work for some models 
455
 
\end{itemize}
456
 
\end{block}
 
427
%\onslide<2->
 
428
%\begin{block}{The adjoint of the source code...} 
 
429
%... is usually obtained by applying an AD tool.
 
430
%\begin{itemize}
 
431
%\item \color{darkgreen} Can sometimes be obtained automatically from the source code
 
432
%\item \color{red} Does not work for some models 
 
433
%\end{itemize}
 
434
%\end{block}
457
435
}
458
436
\note{
459
437
The model is considered as a sequence of primitive instructions, each of which can be differentiated.
475
453
\begin{center}
476
454
\includegraphics[width=0.8\textwidth]{pics/adjoint_types_libadjoint}
477
455
\end{center}
478
 
\onslide<2->
479
 
\begin{block}{Adjoint of the discretised equations}
480
 
\begin{itemize}
481
 
\item \color{darkgreen} Consistent gradient
482
 
%\item \color{darkgreen} Circumvents many problems with the AD approach. 
483
 
\item \color{red}{Complicated to develop by hand}
484
 
\item \color{darkgreen}{\texttt{Libadjoint} facilitates the development}
485
 
\end{itemize}
486
 
\end{block}
 
456
%\onslide<2->
 
457
%\begin{block}{Adjoint of the discretised equations}
 
458
%\begin{itemize}
 
459
%\item \color{darkgreen} Consistent gradient
 
460
%%\item \color{darkgreen} Circumvents many problems with the AD approach. 
 
461
%\item \color{red}{Complicated to develop by hand}
 
462
%\item \color{darkgreen}{\texttt{Libadjoint} facilitates the development}
 
463
%\end{itemize}
 
464
%\end{block}
487
465
}
488
466
\note{
489
467
similar to the "continuous adjoint" approach, but uses the discretised equations instead of the continuous equations.
792
770
\item DOLFIN
793
771
\end{itemize}
794
772
\vspace{1cm}
795
 
\onslide<2->
796
773
\begin{center}
797
774
    \huge{Thank you} 
798
775
\end{center}