\section{Discussion}\label{discussion}

In this section we discuss limitations of our work, and its scope of application.
We first discuss the supported contracts in the subtyping relation of model typing (Section \ref{sec:discussion:oclcontracts}), and the corresponding model substitutability provided by our approach (Section \ref{sec:discussion:substitutability}).

\subsection{On the Support of Contracts in Model Typing}
\label{sec:discussion:oclcontracts}
%% ==> FIRST PART OF THE TITLE

%Contracts > 1st order logic > OCL > subset supported by the translation to Alloy
%But... we know that!

% IN OUR PAPER, we consider CONTRACTS in addition to object oriented metamodels
In this paper we consider contracts in addition to the object oriented structure described in a metamodel. The object-oriented structure is usually defined using Ecore, an implementation aligned with OMG MOF. Contracts can then be invariants expressed in the context of the concepts (i.e., classes) defined in the MOF metamodel, and pre-/post-conditions expressed in the context of operations specified in concepts. While invariants restrict the structure of conforming models and their possible structural substitutability, pre- and post-conditions specify the behavior of the conforming models (i.e. manipulation by model operations) and their possible behavioral substitutability.

% IN OUR APPROACH, we consider OCL CONTRACTS
In our approach, we assume that the first order logic is used to express contracts in metamodels, and we have chosen OCL to express them. We rely on the provided binding between MOF and OCL as defined by OMG to link OCL expressions to a given MOF metamodel.

% IN OUR TOOL, we consider the SUBSET OF THE OCL CONTRACTS supported by the translation to alloy
To test the feasibility of our approach, we implemented a prototype tool that is integrated into the Kermeta workbench. The tool checks OCL-based contract-aware subtyping relations between model types. While the substitutability related to the MOF structure is computed directly using Kermeta, the one related to the contracts is computed using Alloy through a translation from OCL expressions to Alloy specifications, and then an analysis of the output provided by the Alloy Analyzer. The tool only provides support for translating a subset of OCL to Alloy.

% IN OUR TOOL -> SUPPORTED part
Most of the OCL operators have corresponding Alloy constructs. For example, OCL operator $forAll$ corresponds to Alloy construct $all$, $exists$ corresponds to $some$, $includes$ corresponds to $in$, $excludes$ corresponds to $!in$, $sum$ corresponds to $sum$, and $closure$ corresponds to $*$. OCL contracts that involves such operators can be directly transformed into Alloy specifications.

% IN OUR TOOL -> NOT (or PARTIALLY) SUPPORTED part
However, as pointed out by Anastasakis et al. \cite{anastasakis2010challenges}, the translation from OCL to Alloy is not seamless. There are some OCL operators that do not have corresponding Alloy constructs, and thus OCL contracts including such operators cannot be easily transformed into Alloy specifications.
%
Some of them can be partially supported by the tool using the Alloy libraries. For instance, OCL operators like $select$ and $collect$ are translated by the tool described in the paper using Alloy functions that implement their semantics. Consequently, the operator $iterate$ is partially supported by the transformation tool. The tool provides support for OCL contracts including $iterate$ expressions that can be rewritten as $forall$ with $select/collect$ operators. However, the tool cannot be used to deal with $iterate$ expressions that involve arithmetic accumulation since Alloy is a purely declarative language that does not provide support for imperative accumulators. Finally, the translation cannot deal with OCL casting operators like $oclAsType$ since Alloy has a very simple type system that has little support for type casting.

%SMT solvers address this problem. At some point we should look at tools such as Z3 from Microsoft in addition to Alloy.

\subsection{On the Support of Modeling Language Substitutability}
\label{sec:discussion:substitutability}
%% ==> SECOND PART OF THE TITLE

%% we support CONTRACTS FOR SUBSTITUTABILITY...
The research work described in the paper builds upon our previous work in \cite{ecmfa12}, and paves the way for reasoning about the subtyping relation between two model types that include contracts.
Specifically it can be used to reason about the contract-aware subtyping relation that involves structural subtyping (including not only MOF-based Object-Oriented structure but also OCL-based first order invariants) and behavioral subtyping (including a behavioral semantics in an axiomatic way using pre-/post-conditions on operations).

%% ... in a practical way IN KERMETA
%The Kermeta workbench we use to develop the tool described in the paper is a language workbench that allows modelers to design languages using dedicated meta-languages: Ecore (for the abstract syntax), OCL (for the static semantics, i.e. invariants in the abstract syntax + pre-/post-conditions on operations to provide an axiomatic semantics), and the Kermeta language (for the operational semantics).
We implement our approach in a (Kermeta-based) tool included in the Kermeta language workbench to check advanced (i.e., including contracts) subtyping relations between modeling languages based on Ecore and OCL. These two meta-languages are supported by the Kermeta language workbench and are used for describing the abstract syntax and the static semantics respectively.

%% => scope of STRUCTURAL substitutability
This approach and its corresponding implementation addresses the need illustrated by the motivating examples from the high-performance embedded system community used throughout the paper. The scope of the structural substitutability we offer is bounded by OCL and its translation to Alloy, and its applicability is well founded, e.g., in model transformation reuse in model-driven development \cite{ecmfa12}.

%% => scope of BEHAVIORAL substitutability
The actual scope of behavioral substitutability is more difficult to define. The difficulty is twofold: while we support the motivating examples described in the paper, complex situations of OCL based typing could be considered, such as type propagation in model transformation chains. Such challenges will be addressed in future work. % and will be detailed in the concluding remarks of the paper.
Moreover, the scope itself of behavioral substitutability is more difficult to delimit.
%While it leverages an axiomatic semantics to specify behavioral properties that must be ensured for a safe model transformation reuse, such properties must be reflected into structural information of the input and output models (conforming to the same metamodel) to be expressed. Beyond that, other advanced application of behavioral substitutability should be explored in the future, and the tool-supported approach we provide in this paper is a well-fitted contribution for that.


\section{Group based Behavior Modeling}
\label{sec:gm}

%clear points
%road map
%detail of each step, with motivation

\par Recall the central problem of \sys{}, where the \retg{} behaviors of users are modeled.
Specifically, such model is built by the Group Modeling module for each user group and thus named as group model.
To avoid ambiguity, we shall use the term of \textit{items} to denote the data for training the group model.
A given \textit{item} is either positive or negative.

\begin{definition}
\label{def:gm-it}
An item $E$ involves a microblog $b$ and a user $f$ such that $f\ \in R_{b.O}$, i.e., $f$ is a follower of  the owner of microblog $b$.
\begin{equation}
\label{eq:gm-it}
E \in
  \begin{cases}
    \text{positive items}       & \quad \text{if } f \text{ \retd{} } b\\
    \text{negative items}  		& \quad \text{if } f \text{ did not \ret{} } b
  \end{cases}
\end{equation}
\end{definition}

And the data of item $E$ consists of three parts.
%\begin{itemize}

	\stab(1) \stitle{User Info} contains a list of aforementioned metrics \{$G_u$, $P_u$,\#$R_u$, \#$E_u$, $R_{ee,u}$\}.

%	\stab(2) \stitle{Microblog Info} refers to metrics related to the microblog $b$. The number of times the $b$ be retweeted, be %commented, be liked and the length of the microblog contents are considered. What's more, we also considers the correlation between %microblog contents and recent events, where the latter is returned by Ring \cite{IEEEexample:ring}. The correlation metric $C_h$ is in %the form of a normalized vector with each dimension represents one event (similar as $P_{f,u}$ in formula \ref{eq:inte}). Each event %could be viewed as a topic $t$, over which the correlation of a microblog $b$ could be obtained by formula \ref{eq:sim-tw1}.

\stab(2) \stitle{Microblog Info} refers to metrics related to the microblog $b$.
%The number of times the $b$ has been retweeted, commented, liked and the length of the microblog contents are considered.
The number that $b$ has been retweeted, commented, liked and the length of $b.M$ (microblog message) are considered.
What is more, we consider the correlation between $b$ and recent event, where the latter is expressed as several core words returned by Ring \cite{IEEEexample:ring}.
Here we compute \textit{TF-IDF weight} $W_f$ of $b.M$, and get correlation metric $C_h$ of $b$ and event by formula \ref{eq:sim-tf1}.

%	\stab(3) \stitle{Interaction Info} includes seven correlation metrics. They are of \#$B_u$, $R_{oc,u}$, \#$W_{r,u}$, \#$W_{t,u}$, %microblog $b$ versus the user $u$'s \textit{Interest Feature} $P_f(u)$ (a.k.a. long-term/stable interest in this work), $b$ versus %$u$'s short-term interest $P_s(u)$ that is mined from $u$'s recent microblogs (e.g., within 30 days) in the same manner of $P_f(u)$, %and $b$'s timestamp versus the time distribution of $u$'s \retg{} behavior $P_{rt,u}$.
%\end{itemize}
	\stab(3) \stitle{Interaction Info} includes seven correlation metrics: \#$B_u$, $R_{oc,u}$, \#$W_{r,u}$, \#$W_{t,u}$, microblog $b$ versus the user $u$'s \textit{Interest Feature} $P_u$ (a.k.a. long-term/stable interest in this work), and $b$'s timestamp versus the time distribution of $u$'s \retg{} behavior $P_{rt,u}$.
%In addition, the correlation between microblog contents and $u$'s short-term interest mined from $u$'s recent microblogs (e.g., within 30 days) is also taken in consideration.
%In addition, the correlation between microblog contents and $u$'s short-term interest is also taken in consideration. The short-term %interest is expressed as
In addition, we consider $u$'s short-term interest, which is mined from $u$'s recent microblogs (e.g., within 30 days) and calculated by \textit{TF-IDF}, namely $W_s$.
The correlation between microblog $b$ and $u$'s short-term interest is computed by $W_f$ and $W_s$ (using formula \ref{eq:sim-tf1}).
%%

The modeling of retweeting behavior of groups is treated as a classification problem, and we utilize the random forest classifier to address it. Details for random forest \cite{IEEEexample:conf/icdar/Ho1995} are omitted here for space reason.
The advantage of this classification model lies in that it could integrate different features conveniently, and
%The advantage of using classification model is that we can integrate different combinations of the features into the model conveniently.
the obtained group behavior model could learn what a positive/negative item looks like over each metric mentioned above. \par
Here we use accuracy to evaluate our model. To define accuracy, we set four variables: $E_{tp}$,$E_{fp}$,$E_{tn}$ and $E_{fn}$. For a given item $E$, if $E$ is a positive item and our model also determines it a positive item, then we set $E_{tp}$ to 1, else we set $E_{tp}$ to 0. If $E$ is a negative item and our model determines it a positive item, then we set $E_{fp}$ to 1, else we set $E_{fp}$ to 0. If $E$ is a negative item and our model determines it a negative item, then we set $E_{tn}$ to 1, else we set $E_{tn}$ to 0. If $E$ is a positive item and our model determines it a negative item, then we set $E_{fn}$ to 1, else we set $E_{fn}$ to 0. So the accuracy can be defined as:

\begin{equation}
\label{eq:def-precision1}
accuracy = \frac{\sum_{\substack{E}} (E_{tp} + E_{tn} )}{ \sum_{\substack{E}} (E_{tp} + E_{tn} + E_{fp} + E_{fn}) }
\end{equation}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright (c) 2003-2018 by The University of Queensland
% http://www.uq.edu.au
%
% Primary Business: Queensland, Australia
% Licensed under the Apache License, version 2.0
% http://www.apache.org/licenses/LICENSE-2.0
%
% Development until 2012 by Earth Systems Science Computational Center (ESSCC)
% Development 2012-2013 by School of Earth Sciences
% Development from 2014 by Centre for Geoscience Computing (GeoComp)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Level Set Method}

The Level Set Method is used for tracking interfaces between two different types of fluids, which may have different physical parameter values for density or viscosity. The interface is represented by a signed distance function, $\phi(x)$, where the isocontour at $\phi(x)=0$ is used to defined the interface. A point in the domain can then be determined on which side of the interface it resides, based on the local sign of $\phi(x)$; for example positive $\phi(x)$ on one side of the interface and negative $\phi(x)$ on the other. Parameters values such as density and viscosity can then be defined for the two different mediums. The Level Set Method consists of two procedures, the advection and reinitialization of the signed distance function, $\phi$. The LevelSet class can be used in conjunction with the StokesProblemCartesian class for solving computational fluid dynamics problems involving the tracking of the interface. The advantage of the Level Set Method is that it can be used to track surfaces that break apart or intersect. Also, the Level Set Method avoids the need for remeshing, which is required by the Lagrangian-Eulerian (ALE) method.

% An example of using the Level Set Method is described in the tutorial Chapter, Section %\ref{LEVELSET CHAP}.

\subsection{Solution Method}

The displacement of the interface at the zero isocontour of $\phi(x)$ is calculated each time-step by using the velocity field. This is achieved my solving the advection equation:
%
\begin{equation}
\frac{\partial \phi}{\partial t} + \vec{v} \cdot \nabla \phi = 0,
\label{ADVECTION MODELS}
\end{equation}
%
where $\vec{v}$ is the velocity field. The advection equation is solved using a Taylor-Galerkin scheme with the presence of diffusion; by expanding $\phi$ into a Taylor series:
%
\begin{equation}
\phi^{+} \simeq \phi^{-} + dt\frac{\partial \phi^{-}}{\partial t} + \frac{dt^2}{2}\frac{\partial^{2}\phi^{-}}{\partial t^{2}},
\label{TAYLOR EXPANSION MODELS}
\end{equation}
%
then by inserting
%
\begin{equation}
\frac{\partial \phi^{-}}{\partial t} = - \vec{v} \cdot \nabla \phi^{-},
\label{INSERT ADVECTION MODELS}
\end{equation}
%
and
%
\begin{equation}
\frac{\partial^{2} \phi^{-}}{\partial t^{2}} = \frac{\partial}{\partial t}(-\vec{v} \cdot \nabla \phi^{-}) = \vec{v}\cdot \nabla (\vec{v}\cdot \nabla \phi^{-}),
\label{SECOND ORDER MODELS}
\end{equation}
%
into Equation (\ref{TAYLOR EXPANSION MODELS}), the calculation of the level set function is given by:
%
\begin{equation}
\phi^{+} = \phi^{-} - dt\vec{v}\cdot \nabla \phi^{-} + \frac{dt^2}{2}\vec{v}\cdot \nabla (\vec{v}\cdot \nabla \phi^{-}).
\label{TAYLOR GALERKIN MODELS}
\end{equation}

If $\nabla \cdot \vec{v}=0$ is assumed, then the calculation of the second order derivatives in Equation (\ref{TAYLOR GALERKIN MODELS}) can be avoided.

As the computation of the distance function progresses, it becomes distorted, and so it needs to be updated in order to stay regular \cite{SUSSMAN1994}. This process is known as the reinitialization procedure. The aim is to iteratively find a solution to the reinitialization equation:
%
\begin{equation}
\frac{\partial \psi}{\partial \tau} + sign(\phi)(1 - \nabla \psi) = 0.
\label{REINITIALISATION MODELS}
\end{equation}
%
where $\psi$ shares the same level set with $\phi$, $\tau$ is pseudo time, and $sign(\phi)$ is the smoothed sign function. This equation is solved to meet the definition of the level set function, $\lvert \nabla \psi \rvert = 1$; the normalization condition. Equation (\ref{REINITIALISATION MODELS}) can be rewritten in a similar form to the advection equation:
%
\begin{equation}
\frac{\partial \psi}{\partial \tau} + \vec{w} \cdot \nabla \psi = sign(\phi),
\label{REINITIALISATION2 MODELS}
\end{equation}
%
where
%
\begin{equation}
\vec{w} = sign(\phi)\frac{\nabla \psi}{|\nabla \psi|}.
\label{REINITIALISATION3 MODELS}
\end{equation}
%
$\vec{w}$ is the characteristic velocity pointing outward from the free surface. Equation (\ref{REINITIALISATION2 MODELS}) can be solved by a similar technique to what was used in the advection step, using the Taylor-Galerkin procedure.
When the distance function, $\phi$, is calculated, the physical parameters, density and viscosity, are updated using the sign of $\phi$. The region along the interface is assumed to be of finite thickness of $\alpha h$, where $h$ is the size of the elements in the computational mesh and $\alpha$ is a smoothing parameter. The parameters are updated by the following expression:
%
\begin{equation}
P =
\left \{ \begin{array}{l}
P_{1} \hspace{5cm}  where \ \ \psi < - \alpha h \\
P_{2} \hspace{5cm}  where \ \ \psi > \alpha h \\
(P_{2} - P_{1}) \psi/2\alpha h + (P_{1} + P_{2})/2 \ \ \ \ \ \ where \ \ |\psi| < \alpha h.
\end{array}
\right.
\label{UPDATE PARAMETERS MODELS}
\end{equation}
%
where the subscripts $1$ and $2$ denote the different fluids.

\subsection{Functions}

\begin{classdesc}{LevelSet}{domain, func, reinit\_max, reinit\_each, tolerance, smooth}
opens the LevelSet \index{Level Set} on the \Domain domain. \var{func} defines the initial Level Set function representing the interface between two fluids. \var{reinit\_max} sets the maximum number of iterations to satisfy the normal condition, $|\nabla \phi|=1$, during the reinitialization of the Level Set function. \var{reinit\_each} sets the frequency of reinitialization for a number of time-steps. \var{tolerance} sets the convergence tolerance to satisfy the normal condition during the reinitialization of the Level Set function. \var{smooth} sets the bandwidth of size 2$\alpha h$ along the interface to smooth the physical parameters of density and viscosity; $h$ is the size of the elements in the mesh and $\alpha$ is the smoothing parameter, usually set to 1.
\end{classdesc}

\begin{methoddesc}[LevelSet]{update\_parameter}{par1, par2}
updates the physical parameters using the sign of $\phi$. \var{par1} and \var{par2} are the physical parameter values for fluid1 and fluid2 respectively. Usually this method is called twice during each time-step to update the density and viscosity of the two fluids.
\end{methoddesc}

\begin{methoddesc}[LevelSet]{update\_phi}{vel,  dt, t\_step}
updates the Level Set function. It performs the advection and reinitialization procedures. \var{vel} is the velocity field of the fluid domain, \var{dt} is the time-step size, and \var{t\_step} is the current time-step to determine when to reinitialize.
\end{methoddesc}


%! Author = tstreule

\section{Fluorescent Probes}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Fluorescence Statistics}
%
\textbf{Photobleaching}: A fluorescent molecule can emit a limited \#photons by excitation before it irreversibly converts to a non-fluorescent molecule.

\begin{minipage}{.3\columnwidth}
    \includegraphics[width=.9\columnwidth]{Fluorescence_Statistics}
\end{minipage}%
\begin{minipage}{.7\columnwidth}
    \formula{\textbf{Quant. Yield}}{Q = \frac{\Gamma}{\Gamma+k+K_b} \sim 0-98\%}
    \hfill (Efficiency)
    \formbox{Fluorescence \textbf{Lifetime}}{\tau = \frac{1}{\Gamma+k+K_b} \sim \unit[1]{ns}}
    \vspace{1mm}

    Fluorescence emission is a statistical process that is characterized by exponential decays.
    \formula{Molecules in \textit{excited} state}{\deriv{N_e}{t} = -\left(\frac{1}{\tau_1}+\ldots+\frac{1}{\tau_n}\right) N_e}
\end{minipage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\columnbreak
\subsection{FRET \textnormal{-- Fluorescence Resonance Energy Transfer}}
%
\begin{minipage}{.25\columnwidth}
    \includegraphics[width=.9\columnwidth]{Fluorescence_FRET}
\end{minipage}%
\begin{minipage}{.75\columnwidth}
    Seeing a different $\lambda\ped{emission}$ tells us that two molecules are close.
    \formbox{Efficiency}{E = \frac{R_0^2}{R_0^2+r^6} = 1\!-\!\frac{\tau\ped{DA}}{\tau\ped{D}} = 1\!-\!\frac{I\ped{DA}}{I\ped{D}}}
    where
    \formtex{$\tau\ped{D(A)}$, $I\ped{D(A)}$}{Lifetime/Intensity of donor emission}

    \formtex{~}{in the absence/presence of acceptor.}
\end{minipage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Calcium Imaging \textnormal{\hfill $\to$ too slow for $t$ dependency meas.}}
%
Calcium ion cannot be visualized/tagged directly:
$\to$
Design molecules with optical properties that change upon calcium binding.

\begin{minipage}{.23\columnwidth}
    \includegraphics[width=\columnwidth]{Fluorescence_Calcium_Imaging}
\end{minipage}%
\hspace{\columnsep}%
\begin{minipage}{.77\columnwidth-\columnsep}
    \textbf{Single \& dual wavelength measurements}:
    \formbox{Concentration}{[\ce{Ca^{2+}}]_i = K\ped{d,eff} \frac{R-R\ped{min}}{R\ped{max}-R}}
    where
    \formula{for single}{\scriptstyle R\equiv F \text{ and } K\ped{d,eff} = \frac{[\ce{Ca^{2+}}]_i \times(F\ped{max}-F)}{F-F\ped{min}}}
    \formula{for dual.}{R=F_1/F_2}
    \qquad ($F$: fluorescence)
%
%		where $R=F_1/F_2$ for dual wavelength and $R\equiv F$ and $K\ped{d,eff} = \frac{[\ce{Ca^{2+}}]_i \times(F\ped{max}-F)}{F-F\ped{min}}$ for single wavelength
\end{minipage}

The binding of \ce{Ca^{2+}} leads to\ldots
\begin{itemize}
    \item change in fluorescence \textbf{intensity} but not wavelength change
    \item a \textbf{shift} in excitation (and/or emission) peaks (``dual wavelength'')
    \item changes in fluor. resonance energy transfer (\textbf{FRET}) \& life time
\end{itemize}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Delivery of Calcium Indicators}
%
\formtex{\textbf{Loading cells}}{Once the molecule got cleaved (spalten), it}
\formtex{~}{cannot go out and gets fluorescent.}

\formtex{Introduce \textbf{fluoresc.}}{Proteins change emission rate when \ce{Ca} binds.}
\formtex{\textbf{proteins} or (natural)}{Relative change ($\Delta F/F$) in fluorescence}
\formtex{\textbf{FRET proteins}}{emission of EGFP can then be meas. directly.}

\underline{Note}: The dye responds \textit{fast}, but it is \textit{slow} to recover. \ce{Ca} dissociation\\
\phantom{\underline{Note}:} rate (i.e. recovery) depends on dye’s affinity for \ce{Ca}.