\documentclass[11pt]{article}
\topmargin -0.25in
\textheight 8.5in
\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 5--8, 2003

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/docs/
http://www.mcs.anl.gov/petsc/docs/
\end{alltt}

\item Set the environmental variables\\
\begin{tabular}{ccc}
\texttt{TAO\_DIR} & \texttt{PETSC\_DIR} & \texttt{PETSC\_ARCH} 
\end{tabular}
using the commands:
\quad \texttt{module load tao/1.5}
\quad \texttt{module load petsc/2.1.5}


\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 
\]

\begin{itemize}
 \item Copy into your directory the programs
  \begin{alltt}
    \$TAO_DIR/src/unconstrained/examples/tutorials/rosenbrock1.c
    \$TAO_DIR/src/unconstrained/examples/tutorials/makefile
  \end{alltt}
  or for those who prefer Fortran,
  \begin{alltt}
    \$TAO_DIR/src/unconstrained/examples/tutorials/rosenbrock1f.F
    \$TAO_DIR/src/unconstrained/examples/tutorials/makefile
  \end{alltt}

 \item Compile the program using \\
  \quad \texttt{ make BOPT=O\_c++ rosenbrock1} 
  (or \texttt{make BOPT=O\_c++ rosenbrock1f})

 \item Execute the program with \\
  \quad \texttt{mpirun -np 1 rosenbrock1 -tao\_monitor -tao\_view} (or
  \texttt{mpirun -np 1 rosenbrock1f -tao\_monitor -tao\_view})

  What algorithm 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?

 \item 
  This exercise is based on the \textit{Example Programs} listed
  in the TAO web page under Tutorials.  Locate these programs and note that
  these examples are linked with the TAO documentation.  Read the documentation
  for \texttt{TaoCreate()}.

  Run \texttt{rosenbrock1} again but 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}.  Use the PETSc method {\tt VecSet()}
  to set the vector components to a constant, or {\tt VecSetValue()} to set 
  an individual elements (remember to follow any {\tt VecSetValue()} calls
  with {\tt VecAssemblyBegin()} and {\tt VecAssemblyEnd()})
  How did the starting point affect the convergence?

 \item
  Add bounds to your problem. You need to create two vectors, with the
  same dimension and structure as the variable vector, to store the
  lower and upper bounds of the variable.  Set the vector of upper
  bounds equal to $0.5$ and the vector of lower bounds to $0.0$.  Use
  {\tt TaoAppSetVariablesBounds()} to set the bounds on the problem.  Be
  sure to destroy these vectors after you are finished using them.

  Solve this bound-constrained problem using  \texttt{tao\_blmvm} or 
  \texttt{tao\_tron}. Did these bounds affect the solution? 
   
\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
Copy into your directory the programs
\begin{alltt}
\$TAO_DIR/src/unconstrained/examples/tutorials/minsurf1.c
\$TAO_DIR/src/unconstrained/examples/tutorials/minsurf2.c

\end{alltt}
    
Compile and execute the \texttt{minsurf1} example using
    
\quad \texttt{make BOPT=O\_c++ minsurf1}

\quad \texttt{mpirun -np 1 minsurf1 -tao\_monitor}

\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 

\quad \texttt{mpirun -np 1 minsurf1 -tao\_monitor -tao\_view -mx 20 -my 20}

How does this affect the solution?
How many iterations do the following solvers take: \texttt{tao\_cg\_fr},
\texttt{tao\_lmvm}, \texttt{tao\_ntr}, \texttt{tao\_nls}?

\item
Set the tolerances to increase the precision of the solution by adding the
command line options \texttt{-tao\_frtol 0 -tao\_fatol 1e-8}

Now how many iterations does each solver take?

\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 two processors and view the output.

\quad \texttt{make BOPT=O\_c++ minsurf2}

\quad \texttt{mpirun -np 2 minsurf2 -tao\_monitor -mx 20 -my 20 -log\_summary}

\end{itemize}

\end{enumerate}
\end{document}


