Latex로 알고리즘 작성

Latex로 알고리즘 작성

\begin{algorithm}및 를 사용하여 다음 알고리즘을 작성하는 라텍스 코드를 원합니다 \begin{algorithmic}. 나는 이것을했다

\floatname{algorithm}{Procedure}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}

하지만 초기화 같은 다른 사람을 얻는 방법을 모르겠어요..

입력:

f: the function to optimize
ps: the swarm size
d: the problem dimension

산출:

x*: the best fitness value found

초기화:

x_i = (x$_{i1}$,$\cdots$, x_{id}) and v_{i} = (v_{i1}, $\cdots$, $v_{id}$), for all particles in problem space
evaluate f(x_i) in d variables and get pbest_i, (i = 1, $\cdots$, ps) 
gbest $\gets$ best of pbest_i 

방정식 (7)을 사용하여 V_max를 계산합니다.

**While** stopping criteria is false do

     Begin Loop for ps times
        Begin Loop for d times
            **update v_i for particle using equation (4)**
            validate for velocity boundaries using V_max
        End
        **generate \tau**
        **update x_i for particle using equation (5) or equation (6)** 
        validate for position boundaries
End

If f(x_i) < f(pbest_i) then 

      pbest_i $\gets$  x_i 
end if

If f(x_i) < f(gbest_i) then 

gbest_i $\gets$ x_i 

end if

**End while**

x* $\gets$ gbest 

Return x*

PSO 알고리즘 종료

관련 정보