 \begin{table}[!ht]
  \begin{tabular}{|l|l|}
    \hline
    author  & O.Bonnefon, V. Acary\\
    \hline
    date    & Sept, 07, 2007 \\ 
    last update        & Feb, 2011 \\
                       & April, 2014 \\
    \hline
    version &  \\
    \hline
  \end{tabular}
\end{table}



This section is devoted to the implementation and the study  of the algorithm. The interval of integration is $[0,T]$, $T>0$, and a grid $t_{0}=0$, $t_{k+1}=t_{k}+h$, $k \geq 0$, $t_{N}=T$ is constructed. The approximation of a function $f(\cdot)$ on $[0,T]$ is denoted as $f^{N}(\cdot)$, and is a piecewise constant function, constant on the intervals $[t_{k},t_{k+1})$. We denote $f^{N}(t_{k})$ as $f_{k}$. The time-step is $h>0$. 


\section{Various first order dynamical systems with input/output relations}

\paragraph{FirstOrderR. Fully nonlinear case}
Let us introduce the following system, 
\begin{equation}
\begin{array}{l}
M \dot{x}(t) = f(x(t),t) + r(t)  \\[2mm]
y(t) = h(t,x(t),\lambda (t)) \\[2mm]
r(t) = g(t,x(t),\lambda (t) ) \\[2mm]
\end{array}
\label{first-DS}
\end{equation}
where $\lambda(t) \in \RR^m$  and $y(t) \in \RR^m$ are  complementary variables related through a multi-valued mapping.   According to the class of systems, we are studying, the function $f$ and $g$ are defined by a fully nonlinear framework or by affine functions. We have decided to present the time-discretization in its full generality and specialize the algorithms for each cases in Section~\ref{Sec:Spec}. This fully nonlinear case is not  implemented in Siconos yet. This fully general case is not yet implemented in Siconos.

This case is implemented in Siconos with the relation {\tt FirstOrderR} using the subtype {NonLinearR}

\paragraph{FirstOrderType1R}
Let us introduce a new notation,
\begin{equation}
\begin{array}{l}
M \dot{x}(t) = f(x(t),t) + r(t)  \\[2mm]
y(t) = h(t,x(t)) \\[2mm]
r(t) = g(t,\lambda (t) ) \\[2mm]
\end{array}
\label{first-DS1}
\end{equation}
This case is implemented in Siconos with the relation {\tt FirstOrderType1R}.



\paragraph{FirstOrderType2R}
Let us introduce a new notation, 
\begin{equation}
\begin{array}{l}
M \dot{x}(t) = f(x(t),t) + r(t)  \\[2mm]
y(t) = h(t,x(t),\lambda (t)) \\[2mm]
r(t) = g(t,\lambda (t) ) \\[2mm]
\end{array}
\label{first-DS2}
\end{equation}
This case is implemented in Siconos with the relation {\tt FirstOrderType2R}.




\paragraph{Linear case }Let us introduce a new notation, 
\begin{equation}
\begin{array}{l}
M \dot{x}(t) = Ax(t) + r(t)  +b(t)\\[2mm]
y(t) = h(x(t),\lambda (t),z) = Cx + Fz + D \lambda  \\[2mm]
r(t) = g(t,\lambda (t) ) = B \lambda \\[2mm]
\end{array}
\label{first-DS3}
\end{equation}


\section{Time--discretizations}



\subsection{Standard $\theta-\gamma$ scheme.}
Let us now proceed with the time discretization of (\ref{first-DS3}) by a fully implicit scheme : 
\begin{equation}
  \begin{array}{l}
    \label{eq:toto1}
     M x_{k+1} = M x_{k} +h\theta f(x_{k+1},t_{k+1})+h(1-\theta) f(x_k,t_k) + h \gamma r(t_{k+1})
     + h(1-\gamma)r(t_k)  \\[2mm]
     y_{k+1} =  h(t_{k+1},x_{k+1},\lambda_{k+1}) \\[2mm]
     r_{k+1} =  g(t_{k+1},x_{k+1},\lambda_{k+1})\\[2mm]
     \mbox{NsLaw} ( y_{k+1} , \lambda_{k+1})
  \end{array}
\end{equation}
where $\theta = [0,1]$ and $\gamma \in [0,1]$. As in \cite{acary2008}, we call the problem \eqref{eq:toto1} the ``one--step nonsmooth problem''.

In the Siconos/Kernel module, the use of $\gamma$  is activated in the class {\tt EulerMoreauOSI} by the boolean {\tt \_useGamma}.



 This time-discretization is slightly more general than a standard implicit Euler scheme. The main discrepancy lies in the choice of a $\theta$-method to integrate the nonlinear term. For $\theta=0$, we retrieve the explicit integration of the smooth and  single valued term $f$. Moreover for $\gamma =0$, the term $g$ is explicitly evaluated. The flexibility in the choice of $\theta$ and $\gamma$ allows the user to improve and control the accuracy, the stability and the numerical damping of the proposed method. For instance, if the smooth dynamics given by $f$ is stiff, or if we have to use big step sizes for practical reasons, the choice of $\theta > 1/2$ offers better stability with the respect to $h$.

\subsection{Full $\theta-\gamma$ scheme}

Another possible time--discretization is as follows.
\begin{equation}
  \begin{array}{l}
    \label{eq:toto1-ter}
    M x_{k+1} = M x_{k} + h\theta f(x_{k+1},t_{k+1})+h(1-\theta) f(x_k,t_k) + h r(t_{k+\gamma}) \\[2mm]
    y_{k+\gamma} = h(t_{k+\gamma},x_{k+\gamma},\lambda _{k+\gamma}) \\[2mm]
    r_{k+\gamma} = g(t_{k+\gamma},x_{k+\gamma},\lambda _{k+\gamma})\\[2mm]
    \mbox{NsLaw} ( y_{k+\gamma} , \lambda_{k+\gamma})
  \end{array}
\end{equation}
We call the scheme~(\ref{eq:toto1-ter}) the full $\theta-\gamma$ scheme since it uses also the evaluation at $t_{k+\gamma}$ for the relation.

In the Siconos/Kernel module, the time--stepping scheme is activated in the class {\tt EulerMoreauOSI} by the boolean {\tt \_useGammaForRelation}.


Another possibility for the time discretization in the nonlinear case would be
\begin{equation}
  \begin{array}{l}
    \label{eq:toto1-quat}
    M x_{k+1} = M x_{k} +h f(x_{k+\theta},t_{k+\theta}) + h r(t_{k+\gamma}) \\[2mm]
    y_{k+\gamma} =  h(t_{k+\gamma},x_{k+\gamma},\lambda _{k+\gamma}) \\[2mm]
    r_{k+\gamma} = g(t_{k+\gamma},x_{k+\gamma},\lambda _{k+\gamma})\\[2mm]
    \mbox{NsLaw} ( y_{k+\gamma} , \lambda_{k+\gamma})
  \end{array}
\end{equation}
This scheme has not been yet implemented in Siconos/Kernel.

\clearpage
\section{Newton's linearization of~(\ref{eq:toto1})} 

\input{MCP_linearized.tex}
%\input{MCP_linearized_old.tex}



\input{MCP_linearized_2.tex}
\input{MCP_linearized_linear.tex}



\section{Newton's linearization of~ (\ref{eq:toto1-ter}) }

\input{MCP-FullThetaGamma.tex}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "DevNotes"
%%% End: 
