\documentclass{article}
\usepackage{algcompatible}
\usepackage{algorithm}
\usepackage{amsmath}
\usepackage{algpseudocode}

\newcounter{myAlgorithm}%[section]
\setcounter{myAlgorithm}{0}
\newenvironment{myAlgorithm}[1]{
	\refstepcounter{myAlgorithm}
	{\bigskip\par}\hrule\vspace*{1mm}\noindent\textbf{Algorithm \themyAlgorithm{.}}\textrm{#1}
	\vspace*{1mm}\hrule\vspace*{3mm}
}{\par\hrule\bigskip}
%\NoIndentAfterEnv{qd}
\begin{document}
% New definitions
\algnewcommand\algorithmicswitch{\textbf{switch}}
\algnewcommand\algorithmiccase{\textbf{case}}
%\algnewcommand\algorithmicassert{\texttt{assert}}
\algnewcommand\Assert[1]{\State \algorithmicassert(#1)}%
% New "environments"
\algdef{SE}[SWITCH]{Switch}{EndSwitch}[1]{\algorithmicswitch\ #1\ \algorithmicdo}   {\algorithmicend\ \algorithmicswitch}%
\algdef{SE}[CASE]{Case}{EndCase}[1]{\algorithmiccase\ #1}{\algorithmicend\     \algorithmiccase}%
\algtext*{EndSwitch}%
\algtext*{EndCase}%
 




\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}


%	\listofalgorithms
\begin{myAlgorithm}{ SW }
	\label{algo-sw}
	\addcontentsline{loa}{algorithm}{{\bf Algorithm \ref{alg-sw}.} {\rm  Algorithm for aggregation fffees using social choice}}
	
	
	\begin{algorithmic}[1]
		\Require   $C: \text{a set of fffees of the group members}, s: \text{the  method}, threshold: \text{a constant } $
		\Ensure  $R\texttt{: the set of  choice for the group}$  
		
		
		
		\State $ Sum  \leftarrow 0;$
		\State $ y  \leftarrow 0;$
		\State $ R  \leftarrow 0;$
		\If {s=="ggg"}  
		\State$  R \leftarrow -Maximum\_number $;   					
		\ElsIf {s=="L"}
		\State$  R \leftarrow Maximum\_number $;
		
		\EndIf
		\For {$i= 0,...,|X.Domain|$}
		\For {$j= 0,...,|X.Domain|$}
		\State $ D_{i\times j} \leftarrow \emptyset $ 
		
		\EndFor	
		\EndFor	
		\Repeat
		
		\While { $ c \in C$ }
		\State $P_{ji} \leftarrow P$
		
		\If {$ s=ggg|| s = \text{bb} $}
		$ 	R[x] = R[x]/j $;
		\EndIf
		\Switch{$s$}
		\Case{$ee$}
		
		{			\If {$P_{ji}[x] > threshold $}
			\State $ ++ R[x] $
			\EndIf
		}
		\EndCase
		\Case{$ee$}
		{\State  $R[x] += P_{ij}[x]$}
		\EndCase
		\Case{$jj$}
		{				\State $ out: $
			\ForAll {$ x \in X.Domain $}
			\If {$  P_{ij}[x] < threshold $}
			\State go to out;
			\EndIf
			\State  $R[x] += P_{ij}[x]$	
			\EndFor
		}
		\EndCase
		\Case{$a$}
		{
			\State $ R \leftarrow P{ij}[x].index $
		}	
		\EndCase
		\Case{$nnnn $}
		{				\State $ x,y\leftarrow \emptyset $
			\While  {$x<|X.Domain|-1$}
			\For {$y= \emptyset,...,|X.Domain|-1$}
			\If{$x\neq y$}
			\If {$  P_{ij}(x)>P_{ij}(y)$ }
			\State $ D[x][y] \leftarrow +1 $
			\Else
			\State $ D[x][y] \leftarrow -1 $
			\EndIf
			\EndIf
			\EndFor
			\EndWhile
		}
		\EndCase
		\Case{$eeeeeeeeeefff$}
		{\If {$ P_{ji}[x] $ $ < R[x] $}
			\State  $R[x] \leftarrow  P_{ji}[x]$
			\EndIf}
		\EndCase
		\Case{$eeeeeeeeee$}
		{			\State  $R[x] \leftarrow Max(P_{ji}[x] , R[x])$
		}
		\EndCase
		\Case{$dddddddddddd$}
		{\State  $R[x] *=P_{ij}[x]$	
		}
		\EndCase
		\EndSwitch
		\If {s=lklk || s= \text{n}}
		\For {$j= \emptyset,...,|X_i|-1$}
		\State $ Sum  \leftarrow  \emptyset; $
		\For {$i= \emptyset,...,|X_i|-1$}
		\State $ Sum[i] += D[i][j] $
		\EndFor
		\State$ R\leftarrow Sum[i] $ 
		\EndFor 
		\EndIf
		\EndWhile
		\State $R\leftarrow Sort(R, Desc)$;
		\State $Assign (X_{i}[x],First(R))$					\State $ c.Root \leftarrow c.Root.children; $
		\Until{$ c.Root $}
		\Return $R$ 
	\end{algorithmic}
	
\end{myAlgorithm}


\end{document}