I need the traditional form with the lines and the caption on the upper side.
You've given exactly zero information about your document setup, such as which algorithm-related packages you load. Moreover, you haven't mentioned if you encounter error and/or warning messages when you try compile your code snippet. Given your write-up, though, I'm assuming that what you should be doing is to employ the algorithm and algpseudocode packages.
I would also employ inline-fraction notation instead of \frac notation in four of the lines of code. And you should definitely (a) replace $u$ < 0.5 with $u < 0.5$ and (b) render i=1:L in math mode. (If you don't want whitespace padding around the : symbol, just encase it in a pair of curly braces.) Finally, the SBX subscripts should be typeset in a Roman (upright) font instead of in italics.

\documentclass{article}
\usepackage{algorithm,algpseudocode}
\usepackage{mathtools} % for '\DeclarePairedDelimiter' macro
\DeclarePairedDelimiter\abs\lvert\rvert
\newcommand\etaSBX{\eta^{}_{\mathrm{SBX}}}
\begin{document}
\begin{algorithm}
\caption{SBX Operator}\label{alg:sbx}
\begin{algorithmic}
\State $\etaSBX \gets 5$
\For {$i=1:L$}
\State sample $u \in [0,1]$
\If{$u < 0.5$}
\State $\beta = 2u^{1/(\etaSBX+1)}$
\Else
\State $\beta = (2-2u)^{-1/(\etaSBX+1)}$
\EndIf
\State $o_i^1 = (p_i^1+p_i^2-\beta\abs{p_i^1-p_i^2})/2$
\State $o_i^2 = (p_i^1+p_i^2+\beta\abs{p_i^1-p_i^2})/2$
\EndFor
\end{algorithmic}
\end{algorithm}
\end{document}
floatpackage? Please advise.