[Tex/LaTex] Draw a multi-chain structure

tikz-pgf

I'm trying to draw the a structure that has multiple chains from the start, based on this example http://www.texample.net/tikz/examples/assignment-structure/

What I have so far is:

\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,%
    decorations.pathreplacing,decorations.pathmorphing,shapes,%
    matrix,shapes.symbols}
\tikzset{
>=stealth',
  punktchain/.style={
    rectangle, 
    rounded corners, 
    % fill=black!10,
    draw=black, very thick,
    text width=10em, 
    minimum height=3em, 
    text centered, 
    on chain},
  line/.style={draw, thick, <-},
  element/.style={
    tape,
    top color=white,
    bottom color=blue!50!black!60!,
    minimum width=8em,
    draw=blue!40!black!90, very thick,
    text width=10em, 
    minimum height=3.5em, 
    text centered, 
    on chain},
  every join/.style={->, thick,shorten >=1pt},
  decoration={brace},
  tuborg/.style={decorate},
  tubnode/.style={midway, right=2pt},
}

\begin{document}

\begin{figure}[h]
\centering
\begin{tikzpicture}[node distance=.8cm,
  start chain=1 going below, start chain=2 going below]
     \node[punktchain, join] (start) {Static MC};

     \node[punktchain, join] (probf)      {Uniform Generator};
     \node[punktchain, join] (u) {U};
     \node[punktchain, join] (rules) {Transformation Rules};
     \node[punktchain, join, ] (simrv) {Simulated r.v. X};
      \node (loop) [punktchain ]  {Simulation algorithm (loop)};
        %Left Branch 
        \begin{scope}[start branch=left,
                every join/.style={->, thick, shorten <=1pt}, ]
                \node[punktchain, on chain=going left, join=by {<-}] (var) {Variance Reduction};
        \end{scope}

        %Lower branch
        \node[punktchain, join] (paths) {Sample paths};
        \node[punktchain, join] (law) {Law of large numbers};
         \node[punktchain, join] (estim) {Monte Carlo Estimation}; 
    \draw[tuborg] let
    \p1=(loop.west), \p2=(loop.east) in
    ($(\x1,\y1+2.5em)$) -- ($(\x2,\y2+2.5em)$) node[below, midway]  {};
\end{tikzpicture}
\caption{}
\label{fig:6forces}
\end{figure}
\end{document}

Which looks like this so far Partial diagram

What I'd like to do from here on, is what I've sketched above in black color. That is, I want another chain to the right of the existing that links up at the (loop) node and has a fork in it as well.

Can somebody give me some help? I've been going over the tikz manual but I'm not getting very far.

Cheers,
Christos

Best Answer

This is a first trial since I didn't understood well how you would like to connect the two chains near the loop node.

My solution leads to:

enter image description here

Here is the code:

\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,%
    decorations.pathreplacing,decorations.pathmorphing,shapes,%
    matrix,shapes.symbols}
\tikzset{
>=stealth',
  punktchain/.style={
    rectangle, 
    rounded corners, 
    % fill=black!10,
    draw=black, very thick,
    text width=10em, 
    minimum height=3em, 
    text centered, 
    on chain},
   small punktchain/.style={
    rectangle, 
    rounded corners, 
    % fill=black!10,
    draw=black, very thick,
    text width=5em, 
    minimum height=3em, 
    text centered, 
    on chain},
  line/.style={draw, thick, <-},
  element/.style={
    tape,
    top color=white,
    bottom color=blue!50!black!60!,
    minimum width=8em,
    draw=blue!40!black!90, very thick,
    text width=10em, 
    minimum height=3.5em, 
    text centered, 
    on chain},
  every join/.style={->, thick,shorten >=1pt},
  decoration={brace},
  tuborg/.style={decorate},
  tubnode/.style={midway, right=2pt},
}

\begin{document}

\begin{figure}[h]
\centering
\begin{tikzpicture}[node distance=.8cm,
  start chain=1 going below, start chain=2 going below]
     \node[punktchain, join] (start) {Static MC};

     \node[punktchain, join] (probf)      {Uniform Generator};
     \node[punktchain, join] (u) {U};
     \node[punktchain, join] (rules) {Transformation Rules};
     \node[punktchain, join, ] (simrv) {Simulated r.v. X};
      \node (loop) [punktchain ]  {Simulation algorithm (loop)};
        %Left Branch 
        \begin{scope}[start branch=left,
                every join/.style={->, thick, shorten <=1pt}, ]
                \node[punktchain, on chain=going left, join=by {<-}] (var) {Variance Reduction};
        \end{scope}

        %Lower branch
        \node[punktchain, join] (paths) {Sample paths};
        \node[punktchain, join] (law) {Law of large numbers};
         \node[punktchain, join] (estim) {Monte Carlo Estimation}; 
    \draw[tuborg] let
    \p1=(loop.west), \p2=(loop.east) in
    ($(\x1,\y1+2.5em)$) -- ($(\x2,\y2+2.5em)$) node[below, midway]  {};

    % SECOND CHAIN
    \node[punktchain, right=2cm of start] (x) {...};
    \node[punktchain,join] (y) {...};
    \node[punktchain, join] (z) {...}
    child{node[small punktchain, join, right=1cm of rules] (wa) {...}
    child{node[small punktchain, join] (wc) {...}}
     }
    child[->,thick]{node[small punktchain,right=2cm of wa] (wb) {...}
    child{node[small punktchain, join] (wd) {...}}}
    ;

    % connections with the first one
    \draw[thick,->](simrv.south)--($(simrv.south)+(0,-1em)$);

    \draw[thick] (wd.south)--($(wd.south)+(0,-1em)$);
    \draw[thick] (wc.south)--($(wc.south)+(0,-1em)$);
    \draw[thick,->] ($(wd.south)+(0,-1em)$)--($(simrv.south)+(0,-1em)$);
    \draw[thick,->]($(simrv.south)+(0,-1em)$)--(loop.north);


\end{tikzpicture}
\caption{}
\label{fig:6forces}
\end{figure}
\end{document}

The key points in my solution are:

  1. the definition of the starting node of the second chain (called x) placed with in position right=2cm of start;
  2. use the syntax of trees to separate the chain in two sub-chains from node z;
  3. use a new kind of element, small punktchain, to represent nodes in the sub-chains; it basically is a replica of the style punktchain just a bit small;
  4. use the calc library to connect the two sub-chains with the initial chain (this part could be improved as soon as more details will be provided).