I am trying to write down my algorithm and faked I wrote Foreach loop. Otherwise there is no command \Foreach
. The followingmy program could not be executed. Also I use package \usepackage{algpseudocode}
and \usepackage{algorithm}
.
\begin{algorithm}
\caption{Algorithm for generating atn.json file}
\begin{algorithmic}
\Statex \Comment { \textbf{Input:} ListofOrderedSelectedJobs, testDuration, beginDate, endDate, MapDeviceTranmissionTime, \textbf{Output:} atn.json
\For{\textbf{each} selectJob \textit{in} ListofOrderedSelectedJobs \textit{do}}
\If {selectJob \textit{contains} Adevice \textit{then} \textit{addAll} Adevices}
\Statex\Comment{ \%comment: Do the same process for group B, C and D devices\%}
\EndIf
\If {$selectJob == 'U'$ \textit{then}}
\For{\textbf{each} device \in choosenDevice \textit{do}}
\State MapDeviceTranmissionTime.put(device,beginDate)
\Statex\Comment{ \%comment: Put begin test date for each device and store that value in the map\%}
\If {$selectJobType == 'Z'$ \textit{then}}
\If { randomTransmissionDate \textit{exists} \textit{then} readRandomExecutionDate() }
\Else { addRandomExecutionDate()}
\EndIf
\EndIf
\EndFor
\If { $selectJobInterval \leq testDuration$ \textit{then}}
\State $times = testDuration / selectJobInterval$
\Else
\State $times = (testDuration / selectJobInterval) + 1$
\EndIf
\For{$i = 1$ to times \textit{do}}
\If {$selectJob == 'U'$ \textit{then}}
\For{\textbf{each} device \in choosenDevice \textit{do}}
\State timesDate = timesDate + Interval
\State MapDeviceTranmissionTime.put(device,timesDate)
\Statex\Comment{ \%comment: Create URL string and encode it by using timesDate date\%}
\If {$selectJobType == 'Z'$ \textit{then}}
\If { randomTransmissionDate \textit{exists} \textit{then} readRandomExecutionDate() }
\Else { addRandomExecutionDate()}
\EndIf
\EndFor
\EndIf
\EndFor
\EndFor
\end{algorithmic}
\end{algorithm}
Could someone please help me what I made wrong.