

\documentclass{beamer}

% This file is a solution template for:

% - Talk at a conference/colloquium.
% - Talk length is about 20min.
% - Style is ornate.



% Copyright 2004 by Till Tantau <tantau@users.sourceforge.net>.
%
% In principle, this file can be redistributed and/or modified under
% the terms of the GNU Public License, version 2.
%
% However, this file is supposed to be a template to be modified
% for your own needs. For this reason, if you use this file as a
% template and not specifically distribute it as part of a another
% package/program, I grant the extra permission to freely copy and
% modify this file as you see fit and even to delete this copyright
% notice. 


\mode<presentation>
{
  %\usetheme{Madrid}
  %\usetheme{Warsaw}
  % or ...
  %\usetheme{Berkeley}   % left bar
  %\usetheme{Antibes} % tree header
  %\usetheme{Boadilla}  % very plain
  %\usetheme{Warsaw}
  %\usetheme{Rochester} % I like
  %\usetheme{Goettingen}  % right bar
  \usetheme{Ilmenau}

\usecolortheme{lily}

  %\usepackage{beamerouterthemeshadow}
  %\usepackage{beamerouterthemesmoothtree}
  \usepackage{beamercolorthemeorchid}
  %\usepackage{beamerinnerthemerounded}
  %\usepackage{beamerthemeshadow}
  \setbeamercovered{transparent}
  % comment out to completely hide covered material



  %\setbeamercovered{transparent}
  % or whatever (possibly just delete it)
}

\usepackage{wmff}


\usepackage[english]{babel}
% or whatever

\usepackage[latin1]{inputenc}
% or whatever

\usepackage{times}
\usepackage[T1]{fontenc}
% Or whatever. Note that the encoding and the font should match. If T1
% does not look nice, try deleting the line with the fontenc.


\title % (optional, use only with long paper titles)
{Object Oriented Simulation}

\subtitle
{Single-Server Systems}

\author%[Author, Another] % (optional, use only with lots of authors)
{Jos\'e M. Garrido C.}
% \inst{1} 
% \and S.~Another\inst{2}}
% - Give the names in the same order as the appear in the paper.
% - Use the \inst{?} command only if the authors have different
%   affiliation.

\institute[Kennesaw State University] % (optional, but mostly needed)
{
  %\inst{1}%
  Department of Computer Science\\
  Kennesaw State University
%  \and
%  \inst{2}%
%  Department of Theoretical Philosophy\\
%  University of Elsewhere
}
% - Use the \inst command only if there are several affiliations.
% - Keep it simple, no one is interested in your street address.

\date % (optional, should be abbreviation of conference name)
{Spring, 2017}
% - Either use conference name or its abbreviation.
% - Not really informative to the audience, more for people (including
%   yourself) who are reading the slides online

\subject{Applied Computer Science, Simulation}
% This is only inserted into the PDF information catalog. Can be left
% out. 



% If you have a file called "university-logo-filename.xxx", where xxx
% is a graphic format that can be processed by latex or pdflatex,
% resp., then you can add a logo as follows:

\pgfdeclareimage[height=0.17in]{university-logo}{ksu-1.png}
\logo{\pgfuseimage{university-logo}}



% Delete this, if you do not want the table of contents to pop up at
% the beginning of each subsection:
%\AtBeginSubsection[]
%{
%  \begin{frame}<beamer>{Outline}
%    \tableofcontents[currentsection,currentsubsection]
%  \end{frame}
%}


% If you wish to uncover everything in a step-wise fashion, uncomment
% the following command: 

%\beamerdefaultoverlayspecification{<+->}


\begin{document}

\begin{frame}
  \titlepage
\end{frame}

%\begin{frame}{Outline}
%  \tableofcontents
  % You might wish to add the option [pausesections]
%\end{frame}


% Structuring a talk is a difficult task and the following structure
% may not be suitable. Here are some rules that apply for this
% solution: 

% - Exactly two or three sections (other than the summary).
% - At *most* three subsections per section.
% - Talk about 30s to 2min per frame. So there should be between about
%   15 and 30 frames, all told.

% - A conference audience is likely to know very little of what you
%   are going to talk about. So *simplify*!
% - In a 20min talk, getting the main ideas across is hard
%   enough. Leave out details, even if it means being less precise than
%   you think necessary.
% - If you omit details that are vital to the proof/implementation,
%   just say so once. Everybody will be happy with that.

\section{Implementing A Simulation Model}

\begin{frame}{General Form of a Model}
 \begin{block}{General steps}
   \begin{enumerate}
\item Define all classes for the active objects (processes), these classes inherit from the library class {\em Process}.
\item Define the main class, which is also a class for an active object of the model. 
\item Include method {\em main} in the main class. 
   \end{enumerate}
  \end{block}
  \pause
  \begin{block}{Class for active objects}
 All class definitions for active objects must include a method called {\em Main\_body}. This method is the sequence of execution for the active object (process).  
  \end{block}
\end{frame}

\begin{frame}{The Main Class}
\begin{enumerate}
   \item
     Declare variable(s) for the queue size
   \item
     Declare the workload parameters and system parameters
   \item
     Declare variables for the total calculations
    \item
     Declare a reference to an object of class {\em Simulation}
    \item 
     Declare references for the active objects of model
    \item 
     Declare references to queues and other passive objects
    \item
     Declare references for the output files
    \item
     Define the {\em initializer\/} method
    \item
     Define method {\em main}
    \item
      Define the main body of the class
  \end{enumerate}    
\end{frame}


\section{}

%\subsection{Distributed Denial of Service }

\begin{frame}{Method {\em main}}

  \begin{enumerate}
    \item Create an object of the library class {\em Simulation} using a title for the model.
    \item Create all the objects used in the model.
    \item Start the simulation by invoking the {\em start\_sim} function of the simulation object.
    \item Setup the output files.
    \item
       Create the queues and other passive objects.
    \item
       Create and start an object of this class, the main object of the model.
  \end{enumerate}
\end{frame}  
%
\begin{frame}{Method {\em Main\_body}}
\begin{block}{}
  \begin{enumerate}
    \item
      Create and start  the active objects declared in this class.
    \item
      Start the simulation run using the declared simulation period.
     \item
        Calculate total results.
\end{enumerate}

 \end{block}
\end{frame}

\section{General Structure of Single-Server Models}

\begin{frame}{Illustration of a Single Server System}
\begin{figure}
\includegraphics[width=3.5in]{figs/tsserver.png}
\caption{Model of a single-server system}
\label{fig:tsserver}
%\vskip\baselineskip
\end{figure}
\end{frame}

\begin{frame}{Single Server System}
\begin{block}{}
In a model of a single-server\index{single-server} system, there is only one server process that provides service to the customer processes.
 \end{block}
\begin{block}{Components}

\begin{itemize}
  \item The arrival of customers, indicated with an arrow pointing to the tail of the queue
  \item The customers that arrive requesting service
  \item The customer queue, which is the waiting line for customers
  \item The server, which removes the next customer from the queue and services it
\end{itemize}
 \end{block}
\end{frame}

\begin{frame}{The Queue}

\begin{itemize}
  \item 
A queue\index{queue} is a data structure that represents a waiting line and has two ends, the {\em head\/} and the {\em tail}. 
\item
A queue is defined as a passive entity\index{passive entity}. 
\item
An arriving customer process  enters the queue at its tail. 
\item 
A customer can only leave the queue if it is at the head. 
\item The server removes the customer at the head of the queue then provides service to this customer.
\item
The order of arrival of customers is retained in a simple queue, which follows first-in-first-out (FIFO) ordering. 
\end{itemize}
\end{frame}

\begin{frame}{Illustration of a Queue}
\begin{figure}
\includegraphics[width=3.55in]{figs/queue.png}
\caption{Model of a queue}
\label{fig:tqueue}
%\vskip\baselineskip
\end{figure}
\end{frame}

\section{Case Study}

\begin{frame}{The Car-Wash System}
\begin{itemize}
  \item 
Arriving cars join a queue to wait for service. 
\item
The car at the head of the queue is the one that is next serviced by the Carwash machine. 
\item
After the car wash is completed, the car leaves the system. 
\item
Cars are considered the customers of the system, as they are the processes requesting service from the server.
\end{itemize}
\end{frame}

\begin{frame}{Carwash Model View}
\begin{figure}
%\centereps{3.5in}{1.22in}{carwashm.png}
\includegraphics[scale=0.4]{figs/carwashm.png}
\caption{Graphical view of the Carwash system}
\label{fig:carwashm1}
\end{figure}
\end{frame}

\begin{frame}{The Conceptual Model}
\begin{block}{Processes}
\begin{itemize}
  \item The {\em Car} processes, which represent the customers to be serviced by the Carwash machine. There are many instances of this process that are created and actually executed (each one is an object of class {\em Car\/}).
  \item The {\em Arrivals} process, which creates car arrivals according to the inter-arrival period. This process represents the environment.
  \item The {\em Machine} process, which represents the server process that services the car processes, according to the service demand of car processes.
\end{itemize}
\end{block}
\end{frame}

\begin{frame}{The UML Class Diagram of the Model}
\begin{figure}
\vspace{.1in}
\includegraphics[width=3in]{figs/inhcarwh.png}
\caption{The UML class diagram for the Carwash system}
\label{fig:inhcarwh}
%\vskip\baselineskip
\end{figure}
\end{frame}

\begin{frame}{The Events in the Model}
\begin{block}{}
\begin{enumerate}
  \item The arrivals of car processes, which have to join the queue.
  \item The start of service of a car
  \item The completion of service of the current car process. At this same instance, the server process attempts to get the next car process from the queue, and if there is none, will transition to the idle state.
\end{enumerate}
\end{block}
\end{frame}

\begin{frame}{The UML Communication Diagram}
\begin{figure}
\includegraphics[width=3in]{figs/collabcw.png}
\caption{The UML communication diagram for the Carwash system}
\label{fig:collabcw}
\end{figure}
\end{frame}

\begin{frame}{The UML State Diagram}
\begin{figure}
\includegraphics[width=2.7in]{figs/carstate.png}
\caption{A state diagram for a Car process}
\label{fig:carstate}
\end{figure}
\end{frame}

\begin{frame}{The Car-Wash Deterministic Model}
\begin{block}{}
A deterministic version of the model for the Carwash system has predetermined arrivals and
 service periods. 
\end{block}
\begin{block}{Workload}
\begin{enumerate}
  \item    Customer processes arrive at time instants: 0, 2, 5, 8, 12, 13, 17, 22, and 23
  \item    A Carwash service takes 4 time units
\end{enumerate}
\end{block}
\end{frame}

\begin{frame}{The Arrivals Process}
\begin{block}{}
The arrivals process represents the environment that generates new customers. There is a single arrivals process in this model
\end{block}
\begin{block}{Sequence of Activities}
\begin{enumerate}
 \item    Wait until the clock advances to the next arrival event, i.e., by a time interval equal to the inter-arrival period.
 \item    Create a customer (car) object with service period equal to 
           4.0 time units.
 \item    Repeat from step 1 for all arriving car processes.
\end{enumerate}
\end{block}
\end{frame}

\begin{frame}{The Server Process}
\begin{block}{}
There is only one object of the class {\em Server\/} in this model
\end{block}
\begin{block}{Sequence of Activities}
\begin{enumerate}
  \item While the arrival queue is not empty, execute the following activities: 
   \begin{enumerate}
      \item Remove the car process at the head of the queue.
      \item Carry out the service on the car process.
      \item Reactivate the car process.
   \end{enumerate}
  \item Wait (in the idle state) until the next car process arrives, then start from step 1.
\end{enumerate}
\end{block}
\end{frame}


\begin{frame}[fragile]{The Car Process}
\begin{block}{}
A car process includes the service period as one of its relevant attributes
\end{block}
\begin{block}{Sequence of Activities}
\begin{enumerate}
  \item    Join the arrival queue if it is not full. Terminate if  the queue is full (i.e., the car is rejected).
  \item    Reactivate the server if the server is idle.
  \item    Suspend self.
  \item    Continue with own activities when the server process has completed the service.
  \item    Terminate.
\end{enumerate}
\end{block}
\end{frame}

\begin{frame}{Table of Results}
\small
\begin{table}
\caption{Events in the Car-Wash Model}
\begin{center} 
\begin{tabular}{|l|l|l|l|c}  
%\multicolumn{4}{|c|}{Process Events} \\ \savehline
% \multicolumn{1}{|c|}{Time} & \multicolumn{1}{|c|}{Process} &
%   \multicolumn{1}{|c|}{Event}	& \multicolumn{1}{|c|}{Next Event}   \\ 
\hline
  &  &  & \cr
Time & Process & Event & Next Event\cr
  &  &  & \cr
\hline  
 0	& arrivals	& starts		&    \\
 0	& server	& starts		&    \\
 0	& car 1	& arrives		&    \\
 0	& server	& begins service	& 4   \\
 2	& car 2	& arrives		&    \\
 4	& server	& completes service	& 4   \\
 4	& server	& begins service	& 8   \\
 5	& car 3	& arrives		&      \\ 
 8	& car 4	& arrives 		&     \\
 8	& server	& completes service	& 8   \\
 \hline
\end{tabular}
\end{center}
\label{tevents}
\end{table} 
\end{frame}

\begin{frame}{Table of Results (2)} 
\small
\begin{table}
\caption{Events in the Car-Wash Model}
\begin{center} 
\begin{tabular}{|l|l|l|l|c}  
%\multicolumn{4}{|c|}{Process Events} \\ \savehline
% \multicolumn{1}{|c|}{Time} & \multicolumn{1}{|c|}{Process} &
%   \multicolumn{1}{|c|}{Event}	& \multicolumn{1}{|c|}{Next Event}   \\ 
\hline
  &  &  & \cr
Time & Process & Event & Next Event\cr
  &  &  & \cr
\hline   
 8	& server	& begins service	& 12  \\
 12	& car 5	& arrives 		&     \\
 12 	& server	& completes service	& 12  \\
 12	& server	& begins service	& 16  \\
 13	& car 6	& arrives		&     \\
 16	& server 	& completes service	& 16  \\
 16	& server	& begins service	& 20  \\ 
 20	& server	& completes service	& 20  \\
 20	& server	& begins service	& 24  \\
 24	& server	& completes service	& 24  \\
 24	& server	& starts waiting	&     \\ 
 \hline
\end{tabular}
\end{center}
\label{tevents}
\end{table}
\end{frame}

\begin{frame}{Number of Cars in the Queue}
\small
\begin{table}
\caption{Queue Size in the Car-Wash Model}
\begin{center}
\begin{tabular}{|l|l|c} 
%\multicolumn{4}{|c|}{Process Events} \\ \savehline
\hline
  &  \cr
 \multicolumn{1}{|c|}{Time} & \multicolumn{1}{|c|}{Q Size}  \\ 
  &  \cr
 \hline  
 0	& 0 \\
 2	& 1 \\
 4	& 0 \\
 5	& 1 \\
 8	& 1 \\
 12	& 1 \\
 13	& 2 \\
 16	& 1 \\ 
 20	& 0 \\
 \hline
\end{tabular}
\end{center}
\label{tqsize}
\end{table}
\end{frame}

\begin{frame}{Wait Intervals of Cars}
\small
\begin{table}
\caption{Processes Waiting Time}
\begin{center}
\begin{tabular}{|l|l|l|l|c} 
%\multicolumn{4}{|c|}{Process} \\ \savehline
\hline
  &  &  &  \cr
 \multicolumn{1}{|c|}{Process} & \multicolumn{1}{|c|}{Arrival} &
   \multicolumn{1}{|c|}{Start Service}	& \multicolumn{1}{|c|}{ Wait Time} 
		  \\  
  &  &  &  \cr		  
\hline  
 car 1	& 0	& 0		& 0   \\
 car 2	& 2	& 4		& 2   \\
 car 3	& 5	& 8		& 3   \\
 car 4	& 8	& 12		& 4   \\
 car 5 	& 12	& 16		& 4   \\
 car 6	& 13	& 20    	& 7   \\ 
 \hline
\end{tabular}
\end{center}
\label{twait}
\end{table}
\end{frame}

\begin{frame}{The Car-Wash Stochastic Model}
\begin{block}{Differences in deterministic and stochastic models}
\begin{itemize}
  \item The arrival events are random events\index{random events}, i.e., it is not known exactly when a car arrival event will occur.
  \item The service periods are also random, i.e., it is not known exactly how much time it will take the machine to wash a particular car.
\end{itemize}
\end{block}
\begin{block}{Random variables in the carwash model}
\begin{itemize}
    \item the inter-arrival period for each car process, and 
    \item the service period for each car process. 
\end{itemize}
\end{block}
\end{frame}

\begin{frame}{Output of Simulation Runs}
\begin{block}{}
The results of a simulation run of the stochastic Carwash model is produced on the two output files generated by the simulation run: 
\begin{itemize}
\item {\tt carwtrace.txt}
\item {\tt carwstatf.txt}
\end{itemize}
\end{block}
\begin{block}{}
 One file includes a listing of the sequence of events and the other file includes the summary statistics and performance metrics computed.
\end{block}
\end{frame}

\begin{frame}[fragile]{Partial Output of a Simulation Run}
\small \tt
\begin{verbatim}
End Simulation of Simple Model of Car-Wash System 
date: 11/16/2016 time: 12:37
Elapsed computer time: 54 millisec
 
Total number of cars serviced: 46
Car average wait period: 90.844
Average period car spends in the shop: 87.152
Machine utilization: 0.898
\end{verbatim}
\end{frame}








%\section{Our Results/Contribution}

%\subsection{Main Results}


%\subsection{Basic Ideas for Proofs/Implementation}



\section{Activity Diagrams}

\begin{frame}{Diagrams}

\begin{block}{}
These diagrams help describe the operations of the processes involved and the synchronization\index{synchronization} that is present when processes interact with each other.
\end{block}
\pause
\begin{block}{}
Car processes enter a queue and transition to the idle state. The machine process removes a car process from the queue to service it. All queues are passive objects and are different from the processes.

\end{block}
\end{frame}


\begin{frame}{Activity Symbols}
\begin{block}{}
The flow of control in the diagram is composed of a sequence of symbols that denote different type of activities and synchronization actions, all joined by lines and arrows. 
\end{block}
\begin{block}{}
A general activity is represented by a rectangular box; the label in the box is the name of the activity. This activity symbol is usually called a {\em delay} because a finite interval elapses  while the activity is carried out and before the process can proceed to the next activity.  The arrows show the direction of the flow activity sequence.
\end{block}
\end{frame}

\begin{frame}{Illustration of Activity Symbols}
\begin{figure}
\vspace{.1in}
\centereps{3.0in}{2.4in}{figs/symbactd1.png}
\caption{Activity symbols}
\label{fig:sact1}
%\vskip\baselineskip
\end{figure}
\end{frame}


\begin{frame}{Activity Symbols}

\begin{block}{}
\begin{itemize}
  \item The lower semicircle with a bar below a
process name, indicates the start of a process life cycle. 
  \item The lower semicircle symbol also indicates reactivation of  the activity sequence; this symbol can also have an arrow in a non-vertical inclination that shows synchronization with another process.
  \item
The inverted form of this symbol indicates the termination of the process. 
  \item The upper semicircle indicates that the object enters its idle state
  \item a possible arrow in a non vertical inclination denotes the synchronization with another process.
\end{itemize}
\end{block}
\end{frame}


\begin{frame}{Interaction Symbols}
\begin{block}{}
\begin{itemize}
\item 
Process interaction symbols indicate signals and direct synchronization among processes. 
\item The {\em synchronization send} denotes when a signal is sent to a condition queue. 
\item This symbol can also denote an interrupt\index{interrupt} to another process.
\item This symbol can also be used to send an item to a queue. 
\item The {\em synchronization receive} indicates an item being received from a queue.
\end{itemize}
\end{block}
\end{frame}

\begin{frame}{Interaction Symbols (2)}
\begin{block}{}
\begin{itemize}
\item
The symbols for {\em cooperate} describe the effect of the cooperation among processes. 
\item The symbol for {\em schedule}\index{schedule} describe a process that schedules itself or another process after some time interval
\item This symbol can also denote the reactivation of another process.
\end{itemize}
\end{block}
\end{frame}


\begin{frame}{Illustrations of Interaction Symbols}
\begin{figure}
\centereps{3.0in}{2.93in}{figs/symbactd2.png}
\caption{Process interaction symbols}
\label{fig:sact2}
%\vskip\baselineskip
\end{figure}
\end{frame}


\begin{frame}{Activity Diagram of the Carwash Model}
\begin{figure}
\centereps{2.0in}{2.8in}{figs/cwactd.png}
\caption{Activity diagram of the Carwash model}
\label{fig:cwactd}
%\vskip\baselineskip
\end{figure}
\end{frame}

\end{document}
