1

My code is below I checked similar questions but can't find the answer.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[]{algorithm2e}
\begin{document}

\begin{algorithm}
\SetAlgoLined
\KwData{Haftalık satışlar}
\KwResult{ $p$, $q$ ve $m$ parametrelerinin tahmini}
Başlangıç\;
Rastgele $N$ adet $(p,q,m)$ üçlüsü (başlangıç noktası) oluştur.\\ 
\ForAll{Başlangıç noktaları}
{
 \vspace{1mm}\\
  deneme $\leftarrow 1$\;
  uygunluk\textsubscript{1}  $\leftarrow$ calcFitness(p,q,m)\;
 \vspace{1mm}\\
 \While{$n$ $<$ iterasyonSınırı \hspace{1mm}\&\hspace{1mm}$deneme$ $<$ $k$}{
     \While{p $!=$ ChangeP(p,uygunluk\textsubscript{1})}{
          $p^\prime \leftarrow$ ChangeP(p,uygunluk\textsubscript{1})\;
          $p \leftarrow p^\prime$\;
          $uygunluk_1  \leftarrow calcFitness(p,q,m)$\;
     }
     \While{q $!=$ ChangeQ(q,uygunluk\textsubscript{1})}{
          $q^\prime \leftarrow$ ChangeQ(q,uygunluk\textsubscript{1})\;
          $q \leftarrow q^\prime$\;
          $uygunluk_1  \leftarrow calcFitness(p,q,m)$\;
     }
     \While{m != ChangeM(m,uygunluk\textsubscript{1})}{
          $m^\prime \leftarrow$ ChangeM(m,uygunluk\textsubscript{1})\;
          $m \leftarrow m^\prime$\;
          uygunluk\textsubscript{1} \leftarrow $calcFitness(p,q,m)$\;
     }
  $n \leftarrow n+1$\;
  uygunluk\textsubscript{2} $\leftarrow$ $calcFitness(p,q,m)$\;
  uygunluk\textsubscript{2} çözüm havuzuna ekle \\
 \If{uygunluk\textsubscript{1} = uygunluk\textsubscript{2}}{
      deneme $\leftarrow$ deneme$+1$\;
 }
 }
 \If{ uygunluk\textsubscript{2} $\leq$ havuzda mevcut en küçük uygunluk değeri}{
      $p^\star \leftarrow p$\;
      $q^\star \leftarrow q$\;
      $m^\star \leftarrow m$\;
 }
}


\textbf{return} p\textsuperscript{$\star$}, q\textsuperscript{$\star$} ve m\textsuperscript{$\star$}
\end{algorithm}


\end{document}
6
  • Hi, welcome. Please add fully compilable code.
    – AndréC
    Dec 21, 2019 at 10:09
  • I edited, thank you for your interest. Dec 21, 2019 at 10:15
  • 1
    How is \State defined?
    – leandriis
    Dec 21, 2019 at 10:18
  • 1
    uygunluk_1 in text mode will result in an error message. If uygunluk is a word, you might want to use uygunluk\textsubscript{1} inestad.
    – leandriis
    Dec 21, 2019 at 10:29
  • According to feedbacks I edited code once again. Thank you. I have an improvement on while loop but forall is still problematic. Dec 21, 2019 at 10:46

1 Answer 1

1

Thanks a lot for all the feedbacks, I managed to solve the problem considering instructions you gave me. Bests,

\begin{algorithm}
    \SetAlgoLined
     \KwData{Haftalık satışlar}
     \KwResult{$p$, $q$ ve $m$ parametrelerinin tahmini}
     Başlangıç\;
      Rastgele $N$ adet $(p,q,m)$ üçlüsü (başlangıç noktası) oluştur.\\ 
    \BlankLine
    \ForAll{Başlangıç noktaları}{
        $deneme \leftarrow 1$\;
         uygunluk\textsubscript{1}  $\leftarrow$ calcFitness(p,q,m)\;
        \While{$n$ $<$ iterasyonSınırı \hspace{1mm}\&\hspace{1mm}$deneme$ $<$ $k$}{
            \While{p $!=$ ChangeP(p,uygunluk\textsubscript{1})}{
                 $p^\prime \leftarrow$ ChangeP(p,uygunluk\textsubscript{1})\;
                 $p \leftarrow p^\prime$\;
                 $uygunluk_1  \leftarrow calcFitness(p,q,m)$\;
            }
            \While{q $!=$ ChangeQ(q,uygunluk\textsubscript{1})}{
                 $q^\prime \leftarrow$ ChangeQ(q,uygunluk\textsubscript{1})\;
                 $q \leftarrow q^\prime$\;
                 $uygunluk_1  \leftarrow calcFitness(p,q,m)$\;
            }
            \While{m != ChangeM(m,uygunluk\textsubscript{1})}{
                 $m^\prime \leftarrow$ ChangeM(m,uygunluk\textsubscript{1})\;
                 $m \leftarrow m^\prime$\;
                 uygunluk\textsubscript{1} $\leftarrow calcFitness(p,q,m)$\;
            }
         $n \leftarrow n+1$\;
         uygunluk\textsubscript{2} $\leftarrow$ $calcFitness(p,q,m)$\;
         uygunluk\textsubscript{2} çözüm havuzuna ekle \\
        \If{uygunluk\textsubscript{1} = uygunluk\textsubscript{2}}{
             $deneme \leftarrow deneme+1$\;
        }
        }
        \If{ uygunluk\textsubscript{2} $\leq$ havuzda mevcut en küçük uygunluk değeri}{
             $p^\star \leftarrow p$\;
             $q^\star \leftarrow q$\;
             $m^\star \leftarrow m$\;
        }
    }

    \textbf{return} p\textsuperscript{$\star$}, q\textsuperscript{$\star$} ve m\textsuperscript{$\star$}\;


    \end{algorithm}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .