\documentclass[11pt]{article}
\topmargin -0.25in
\textheight 8.7in
\textwidth 6.5in
\oddsidemargin 0.0in      % Left margin = 1.0in

\usepackage{alltt}
%\input{../../sty/preamble}

\begin{document}
\begin{center}
{\bf
TAO - Toolkit for Advanced Optimization
        
Tutorial and Exercises

\vspace{0.25in}

Workshop on the ACTS Toolkit

August 19--22, 2008

National Energy Research Scientific Computing Center
}
\end{center}
\vspace{0.25in}

\begin{enumerate}

\item Locate the TAO and PETSc documentation at 
\begin{alltt}
http://www.mcs.anl.gov/tao
http://www.mcs.anl.gov/petsc
\end{alltt}

\item On jacquard, set the environmental variables
\texttt{TAO\_DIR}, \texttt{PETSC\_DIR}, \texttt{PETSC\_ARCH} 
using the command:
\begin{alltt}
% module load tao/1.9_g_c++
\end{alltt}

\item Create a subdirectory such as \texttt{taoexamples}, enter it, and copy several example problems to the new directory using the commands:
\begin{alltt}
% mkdir taoexamples
% cd taoexamples
% cp -R \$TAO_DIR/src/unconstrained/examples/tutorials/* .
% ls
\end{alltt}
There should be a \texttt{makefile} and several examples ending in \texttt{.c} and \texttt{.F}.

\item Run an example with TAO.
We are going to use TAO to minimize the function 
\[
    f(x_1,x_2) = 99*(x_2-{x_1}^2)^2 + (1-x_1)^2 
\]
on a single processor.
\begin{itemize}

 \item Compile the program using \\
  \quad \texttt{ \% make rosenbrock1} 
  (or \texttt{ \% make rosenbrock1f} for Fortran users)

 \item Execute the program with \\
  \quad \texttt{ \% mpiexec -n 1 ./rosenbrock1 -tao\_monitor -tao\_view} \\
  (or \texttt{ \% mpiexec -n 1 ./rosenbrock1f -tao\_monitor -tao\_view}) \\

  What method was used to solve the problem?
  What is the function value at the final iterate? 
  How many iterates were used to reach the solution?  
  How many function evaluations?

 \newpage

\end{itemize}

\item
Another TAO example finds the minimum surface area of an object over a
two-dimensional domain in accordance with some boundary conditions.

\begin{itemize}

\item
Compile and execute the \texttt{minsurf2} example using
    
\texttt{\% make minsurf2}

\texttt{\% mpiexec -n 2 ./minsurf2 -tao\_monitor -tao\_view}

\item
This problem uses the variables {\tt mx} and {\tt my} to determine
the discretization of the grid.  By default, these values are set to
$4$ ($4 \times 4 = 16$ variables). Increase the discretization of the 
domain by using the command 

\texttt{\% mpiexec -n 2 ./minsurf2 -tao\_monitor -tao\_view -mx 20 -my 20}

How does this affect the solution?
Try different solvers using the option \texttt{-tao\_method} followed by
\texttt{tao\_cg},
\texttt{tao\_lmvm}, \texttt{tao\_ntr}, or \texttt{tao\_nls}.
How many iterations do the different solvers require to solve the problem?


\item
Execute the programs from the last step again, but this time use the command line option 
\texttt{-log\_summary} to get detailed performance information.

Look under the PETSc Performance Summary section and determine how long
each algorithm takes to solve the problem. How many floating point operations (flops) are required? 


\item
Run the problem \texttt{minsurf2.c} on four processors and view the output.

\texttt{\% mpiexec -n 4 ./minsurf2 -tao\_monitor -mx 20 -my 20 -log\_summary}

\end{itemize}

\item 
  Locate \texttt{minsurf2.c} in the TAO documentation on its web site.  Browse through
  the online version this example and follow the links for
  \texttt{TaoCreate()} and other routines.  Read the online documentation for these routines.

\begin{itemize}
  \item 
  Run \texttt{minsurf2} again using other unconstrained minimization 
  methods.    You can change the solver by modifying the arguments of 
  \texttt{TaoCreate()} or using the runtime option \texttt{-tao\_method <solver>}.
 
  What is the function value at the final iterate?
  How many iterates were used to reach
  the solution?  What was the final residual value? What does the residual represent?

 \item 
  Change the starting vector \texttt{x} by editing the file \texttt{minsurf2.c}.  
  Use the PETSc method {\tt VecSet()}
  to set the vector components to a constant, or {\tt VecSetValue()} to set 
  an individual element (remember to follow any {\tt VecSetValue()} calls
  with {\tt VecAssemblyBegin()} and {\tt VecAssemblyEnd()}).  Compile the program again and run it.
  How did the starting point affect the convergence?

 \item Print the solution after the solve is complete using the PETSc command {\tt VecView()}.
\end{itemize}

\end{enumerate}
\end{document}


