Skip to content

Commit

Permalink
pseudocodice
Browse files Browse the repository at this point in the history
  • Loading branch information
cardagna committed May 27, 2024
1 parent f879d67 commit 24c4600
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions metrics.tex
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ \subsection{Heuristic}\label{subsec:heuristics}
We design and implement a heuristic algorithm built on a \emph{sliding window} for computing the pipeline instance maximizing quality \q.
%Our heuristic is built on a \emph{sliding window} and aims to maximize information \quality \emph{\q} according to quality metrics.
%At each step, a set of vertices in the pipeline template $\tChartFunction$ is selected according to a window of size \windowsize, which select a subset of the pipeline template starting at depth $i$ and ending at depth \windowsize+i-1.
At each step, a window of size \windowsize\ selects a subset of vertices in the pipeline template $\tChartFunction$ starting at depth $i$ and ending at depth \windowsize+i-1.
Service filtering and selection in \cref{sec:instance} are then executed to maximize quality $Q_w$ in window $w$. The heuristic returns as output the list of services instantiating all vertices at depth $i$. The sliding window $w$ is then shifted by 1 (i.e., $i$=$i$+1) and the filtering and selection process executed until \windowsize+i-1 is equal to length $l$ (max depth) of $\tChartFunction$, that is, the sliding window reaches the end of the template.
At each iteration $i$, a window of size \windowsize\ selects a subset of vertices in the pipeline template $\tChartFunction$, from vertices at depth $i$ to vertices at depth \windowsize$+$$i$$-$1.
Service filtering and selection in \cref{sec:instance} are then executed to maximize quality $Q_w$ in window $w$. The heuristic returns as output the list of services instantiating all vertices at depth $i$. The sliding window $w$ is then shifted by 1 (i.e., $i$$=$$i$+1) and the filtering and selection process executed until \windowsize$+$$i$$-$1 is equal to length $l$ (max depth) of $\tChartFunction$, that is, the sliding window reaches the end of the template. In the latter case, the heuristic instantiates all remaining vertices and returns the pipeline instance.
%For example, in our service selection problem where the quantity of information lost needs to be minimized, the sliding window algorithm can be used to select services composition that have the lowest information loss within a fixed-size window.
This strategy ensures that only services with low information loss are selected at each step, maximizing the pipeline quality \q. The pseudocode of the heuristic algorithm is presented in \cref{lst:slidingwindowfirstservice}.

\definecolor{commentsColor}{rgb}{0.497495, 0.497587, 0.497464}
\definecolor{keywordsColor}{rgb}{0.000000, 0.000000, 0.0}
\definecolor{stringColor}{rgb}{0.558215, 0.000000, 0.135316}
Expand Down Expand Up @@ -183,19 +184,22 @@ \subsection{Heuristic}\label{subsec:heuristics}
if isLastWindowFrame(){
return %\bestcombination%
}else{
return %\bestcombination%[0]
return %\bestcombination%[j]
}
}
\end{lstlisting}

\end{minipage}

The function SlidingWindowHeuristic processes a list of vertices, each associated with a list of services, to identify optimal service combinations using a sliding window approach, given the constraints set by parameters verticesList and w (window size).
Function \textbf{SlidingWindowHeuristic} implements our heuristic; it takes the pipeline template $\tChartFunction$ and the window size \windowsize\ as input and returns the pipeline instance $G'$ and corresponding metric $M$ as output. Its goal is to identify the optimal service combination using a sliding window approach, given the candidate services associated with each vertex in $\tChartFunction$ and the constraints (policies) in \emph{verticesList}.

%Initially, the function initializes $G'$ to store the pipeline instance (line 1).
It iterates all sliding windows $w$ step 1 until the end of the pipeline template is reached (\textbf{for cycle} in line 5). For each window, the function iterates through all vertices in the window according to its length \windowsize\ (\textbf{for cycle} in line 6), adding the service(s) selected at step $j$ to $G'$ by function \textbf{SelectService} (line 7).

Function \textbf{SelectService} takes as input index $j$ representing the starting depth of the window and corresponding window size \windowsize. It initializes the best combination of services to [] (line 18). It iterates through all possible combinations of services in the window using the Cartesian product of the service lists (\textbf{for cycle} in lines 19-21). If the current combination has quality metric M($G'_w$) higher than the best quality metric M($G^*_w$), current combination $G'_w$ updates the best combination $G^*_w$ (lines 20-21).

Initially, the function establishes $G'$ to store the optimal services or combinations identified during the process (line 1). It iterates from the start to the feasible end of the vertex list to ensure each possible window of services is evaluated (line 5). For each window, the function iterates through the vertices (line 6), adding the selected service(s) to $G'$ (line 7).
Function \textbf{SelectService} checks whether it is processing the last window (line 25). If yes, it returns the best combination $G^*_w$ (line 26). Otherwise, it returns the (set of) service at depth $j$ of $G^*_w$ (line 28).

Within each window, the function iterates through the selected services to calculate the total quality metric $M$ (line 11). This metric is updated by summing the quality metrics of the selected services. The function concludes by returning the selected services $G'$ and the total quality metric $M$ (line 14).
Within each window, function \textbf{SlidingWindowHeuristic} iterates through the selected services to calculate the total quality metric $M$ (\textbf{for cycle} in lines 10-11).\hl{il ciclo non mi è chiarissimo secondo me manca qualcosa o è sbagliato l'indice} This metric is updated by summing the quality metrics of the selected services. The function concludes by returning the best pipeline instance $G'$ and the corresponding quality metric $M$ (line 14).

The function \textit{SelectService(j, w)} initializes the best combination of services (line 18). It iterates through all possible combinations of services in the current window using the Cartesian product of the service lists (line 19). If the current combination has a lower quality metric than the previously best combination, it updates the best combination (lines 20-21).

Finally, the function checks if it is processing the last window frame (line 25). If true, it returns the best combination of services (line 26). Otherwise, it returns only the first service of the best combination (line 28).

0 comments on commit 24c4600

Please sign in to comment.