% Optimal Lot-Size with the Andler Formula
% Author: Felix Lindemann
% Source: Beamer by Till Tantau <--- Great!
% GNUPLOT required
\RequirePackage{atbegshi}
\documentclass{beamer}



\usepackage{animate}
\usepackage{calc}
\usepackage{fp}
\usepackage{times}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{arrows,automata,shapes,calc}


\title{Optimal Lot-Size with the Andler Formula}
\subtitle{Sensitivity Analysis}

\author[Dipl. Kfm Felix Lindemann]{Dipl. Kfm Felix Lindemann\inst{1}}
\institute[Fachhochschule Neu-Ulm]{
    \inst{1}Kompetenzzentrum Logistik\\
    University of Applied Science Neu-Ulm
}
 
\subject{Sensitivity Analysis of Andlers-Lot-Size by Felix Lindemann. } 
\keywords{Andler, optimal Lot size, ...}

\newcounter{cnt}
\setcounter{cnt}{0}
\newcommand{\ANDLER}[4]
{   
    \draw[-latex] (0,0) -- (8.5,0) node[right]{\tiny $b$};
    \draw[-latex] (0,0) -- (0,5.5) node[left]{\tiny $K_G K_L K_B$};
    \pgfmathsetmacro\vkl{#1}
    \pgfmathsetmacro\vkb{#3}
    \pgfmathsetmacro\vP{#2}
    \pgfmathsetmacro\vM{#4}
    \pgfmathsetmacro\bOpt{10* sqrt( (2 * \vkb * \vM) / (\vkl) / ( \vP) )}
    \pgfmathsetmacro\bOpta{ \bOpt /10}
    \pgfmathsetmacro\Kmin{ sqrt( 2 * \vkl * \vP * \vkb)  * sqrt(  \vM * 0.01)}
    \pgfmathsetmacro\Kmina{ \Kmin/20}   
    \FPround{\Kmin}{\Kmin}{2}
    \FPround{\bOpt}{\bOpt}{2}
    
    \draw[dotted] (\bOpta,4.5) -- (\bOpta,-0.5) node[below]
        {\tiny $b_{opt}=\sqrt{\frac{2\cdot #3 \cdot #4 \cdot100}{#1 \cdot #2}} = \bOpt$};
    \draw[dotted]   (-0.5,\Kmina) -- (5.5,\Kmina) node[right]
        {\tiny $K_G(b_{opt})=
        \sqrt{\frac{2\cdot #1 \cdot #2 \cdot #3 \cdot #4}{100}}=\Kmin$};
    \foreach \x  in {1,...,8}{
        \pgfmathsetmacro\xtext{ \x * 10}
        \draw (\x cm,1pt) -- (\x cm,-1pt) node[below] {\tiny $\xtext$};
    }
    \foreach \y  in {1,...,5}{
        \pgfmathsetmacro\ytext{ \y * 20}
        \draw (1pt,\y cm) -- (-1pt,\y cm) node[left]  {\tiny $\ytext$};}%                    
        \foreach \kl/\P/\kb/\M in {#1/#2/#3/#4}{
            \draw[color=black, ultra thick] plot[id=#1#2#3#4a]
                function{(0.5*\kl*0.01*\P*(x*10)+\kb*\M/(x*10))/20};
            \node[color=black, very thick] at (4.5,5)
                {\scriptsize$K_G(b)=\textcolor{red}{\frac{1}{2}\cdot\frac{k_l\cdot P}{100} \cdot b}
                +\textcolor{blue}{\frac{M\cdot k_b}{b}}=
                \textcolor{red}{\frac{1}{2}\cdot\frac{\kl\cdot\P}{100} \cdot b}
                +\textcolor{blue}{\frac{\M\cdot\kb}{b}}$};                           
            \draw[color=red,thick  ] plot[id=#1#2#3#4b] function{(0.5*\kl*0.01*\P*(x*10))/20};                      
            \draw[color=blue,thick  ] plot[id=#1#2#3#4c] function{(\kb*\M/(x*10))/20};
        }

 }

\begin{document}
\pagestyle{empty}
 \frame{
    \titlepage
}
\section{Analysis for Parameter $k_l$}
\begin{frame}{Animationen}{Optimal Lot Size Calculation with \textsc{Andler}\\Influence of $k_l$}
 %  Development of total cost function by varying the storing cost parameter
\vspace*{-1em}
  \begin{flushleft}%
  \begin{animateinline}[autoplay,palindrome,
    begin={\begin{tikzpicture}[domain=0.3:8.4]},
    end={\end{tikzpicture}}]{3}
    \ANDLER{5}{20}{5}{50}; \newframe
    \ANDLER{6}{20}{5}{50}; \newframe
    \ANDLER{7}{20}{5}{50}; \newframe
    \ANDLER{8}{20}{5}{50}; \newframe
    \ANDLER{9}{20}{5}{50}; \newframe
    \ANDLER{10}{20}{5}{50}; \newframe
    \ANDLER{11}{20}{5}{50}; \newframe
    \ANDLER{12}{20}{5}{50}; 
    \end{animateinline}
  \end{flushleft}
\end{frame}
 \section{Analysis for Parameter $k_b$} 
 
\begin{frame}{Animationen}
    {Optimal Lot Size Calculation with \textsc{Andler}\\Influence of $k_b$}
 %  Development of total cost function by varying the storing cost parameter

 \vspace*{-1em}
  \begin{flushleft}%
  \begin{animateinline}[autoplay,palindrome,
    begin={\begin{tikzpicture}[domain=0.3:8.4]},
    end={\end{tikzpicture}}]{3}
    \ANDLER{5}{20}{3.5}{50};\newframe
    \ANDLER{5}{20}{4.0}{50};\newframe
    \ANDLER{5}{20}{4.5}{50};\newframe
    \ANDLER{5}{20}{5.0}{50};\newframe
    \ANDLER{5}{20}{5.5}{50};\newframe
    \ANDLER{5}{20}{6.0}{50};\newframe
    \ANDLER{5}{20}{6.5}{50}  ;
  \end{animateinline}
  \end{flushleft}
\end{frame}
  
\end{document}