\documentclass[a4paper,10pt]{article}

\usepackage[left=2cm,right=2cm,top=2.5cm, bottom=2cm]{geometry}
\usepackage{hyperref}
\usepackage{amssymb}
\usepackage{url}
\usepackage{float}
\usepackage{longtable}
\usepackage{graphicx}

\pagestyle{headings}

\newcommand{\secondo}{\textsc{Secondo}}
\newcommand{\op}[1]{\textbf{#1}}
\newcommand{\var}[1]{\textsl{#1}}
\newcommand{\dt}[1]{\textsl{\underline{#1}}}
\newcommand{\file}[1]{\texttt{#1}}
%opening
\title{TrafficAlgebra: Short Introduction in Testing with Scripts}
\author{Simone Jandt}
\date{Last Update: \today}
\begin{document}

\maketitle

\section{Existing operators of Traffic Algebra}

\begin{enumerate}
\item \op{trafficflow}: \dt{rel}(\dt{tuple}(\dt{mgpsecunit})) $\rightarrow$ \dt{rel}(\dt{tuple}(\dt{int}, \dt{int}, \dt{int},\dt{mint}))

Computes the number of cars in the defined section part and direction of the network as \dt{mint}.

\item \op{trafficflow2}: \dt{stream}(\dt{mgpsecunit}) $\rightarrow$ \dt{rel}(\dt{tuple}(\dt{int}, \dt{int}, \dt{int},\dt{mint}))

Computes the number of cars in the defined section part and direction of the network as \dt{mint}.

\item \op{traffic} : \dt{stream}(\dt{mgpsecunit}) $\rightarrow$ \dt{rel}(\dt{tuple}(\dt{int}, \dt{int}, \dt{int},\dt{mreal},\dt{mint}))

Computes the number of cars in the defined section part and direction of the network as \dt{mint} and the average speed of the cars in the defined section part as \dt{mreal}.

\item \op{traffic2}:  \dt{stream}(\dt{mgpoint}) $\rightarrow$ \dt{rel}(\dt{tuple}(\dt{int}, \dt{int}, \dt{int},\dt{mreal},\dt{mint}))

Computes the number of cars in the defined section part and direction of the network as \dt{mint} and the average speed of the cars in the defined section part as \dt{mreal}.

\item \op{heavytraffic}:  \dt{rel}(\dt{tuple}(\dt{int}, \dt{int}, \dt{int},\dt{mreal},\dt{mint})) $\times$ \dt{real} $\times$ \dt{int} $\rightarrow$ \dt{rel}(\dt{tuple}(\dt{int}, \dt{int}, \dt{int},\dt{mreal},\dt{mint}))
 
Shrinks the traffic relation to the times and places where the average speed is lower than the parameter \dt{real} and the number of cars is higher than the parameter \dt{int}.
\end{enumerate}

Example queries for all operators can be seen in the files:
\begin{itemize}
  \item \file{/secondo/Algebras/Traffic.examples}
  \item \file{/secondo/Algebras/Traffic/SecondoScripts/Test\_Queries.SEC}
\end{itemize}

\section{Test Scripts for Traffic Operators}
In \file{/secondo/Algebras/Traffic/SecondoScripts} you can find 3 \secondo{}-Scriptfiles. You should move them into \file{/secondo/bin}-directory to use them without problems.

The \file{Traffic\_DataGenerator.SEC} is a adaption of the \file{BerlinMOD\_DataGenerator.SEC}. You need the files  \file{streets.data}, \file{workRegion.data} and \file{homeRegion.data} in your \file{/secondo/bin} - directory to use this script\footnote{You can find the files in \file{/secondo/Algebras/Network/DataSourceBerlinMOD}.}. You can edit the script to set the amount of cars observed and the length of the observeation period by the parameters: SCALEFCARS and SCALEFDAYS in lines 143 and 144 of the script. The number of observed cars is 2000*SCALEFCARS and the number of observation days is 28*SCALEFDAYS. The script generates a new database \file{berlinmod} with the histories of cars moving in German capital Berlin for the observation time. The interesting generated data is stored in relation \file{dataScar}.

The second script \file{Traffic\_CreateNetworkObjects.SEC} uses the output of the first script as input. It creates a network object of the streets data and translates the generated \dt{mpoint} values into \dt{mgpoint} values of this new network in a relation called \file{dataSNcar}.

The last script \file{Traffic\_TestQueries.SEC} contains some queries using the TrafficAlgebra-Operators measuring the different execution times in \file{rttraffic}. If you want to run the test several times you have to remove the results from your database before you start the new test run. The resulting objects may be saved on disk by uncommenting the lines starting with \file{save} in the script. 

\end{document}
