Re: Make 'Genetic Algorithm' a real figure

Jürgen Purtz <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.documentation
Message-ID <[email protected]>
This is an adoption of the genetic-algorithm.gv file to the style of the 
gin.gv file: same font, similar header, use of TAB instead of SPACE.

Kind regards

Jürgen Purtz
genetic-algorithm-v1.patch (text/x-patch, 4.5 KB)
diff --git a/doc/src/sgml/geqo.sgml b/doc/src/sgml/geqo.sgml
index 5120dfbb42..5a52fb46db 100644
--- a/doc/src/sgml/geqo.sgml
+++ b/doc/src/sgml/geqo.sgml
@@ -84,7 +84,8 @@
     Through simulation of the evolutionary operations <firstterm>recombination</firstterm>,
     <firstterm>mutation</firstterm>, and
     <firstterm>selection</firstterm> new generations of search points are found
-    that show a higher average fitness than their ancestors.
+    that show a higher average fitness than their ancestors. <xref linkend="geqo-figure"/>
+    illustrates in which order and how long the three steps are processed.
    </para>
 
    <para>
@@ -94,48 +95,13 @@
     non-random (better than random).
    </para>
 
-   <figure id="geqo-diagram">
-    <title>Structured Diagram of a Genetic Algorithm</title>
-
-    <informaltable frame="none">
-     <tgroup cols="2">
-      <tbody>
-       <row>
-        <entry>P(t)</entry>
-        <entry>generation of ancestors at a time t</entry>
-       </row>
-
-       <row>
-        <entry>P''(t)</entry>
-        <entry>generation of descendants at a time t</entry>
-       </row>
-      </tbody>
-     </tgroup>
-    </informaltable>
-
-<literallayout class="monospaced">
-+=========================================+
-|&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;  Algorithm GA  &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;|
-+=========================================+
-| INITIALIZE t := 0                       |
-+=========================================+
-| INITIALIZE P(t)                         |
-+=========================================+
-| evaluate FITNESS of P(t)                |
-+=========================================+
-| while not STOPPING CRITERION do         |
-|   +-------------------------------------+
-|   | P'(t)  := RECOMBINATION{P(t)}       |
-|   +-------------------------------------+
-|   | P''(t) := MUTATION{P'(t)}           |
-|   +-------------------------------------+
-|   | P(t+1) := SELECTION{P''(t) + P(t)}  |
-|   +-------------------------------------+
-|   | evaluate FITNESS of P''(t)          |
-|   +-------------------------------------+
-|   | t := t + 1                          |
-+===+=====================================+
-</literallayout>
+   <figure id="geqo-figure">
+    <title>Structure of a Genetic Algorithm</title>
+    <mediaobject>
+     <imageobject>
+      <imagedata fileref="images/genetic-algorithm.svg" format="SVG" width="100%"/>
+     </imageobject>
+    </mediaobject>
    </figure>
   </sect1>
 
diff --git a/doc/src/sgml/images/Makefile b/doc/src/sgml/images/Makefile
index 1e7993020b..f9e356348b 100644
--- a/doc/src/sgml/images/Makefile
+++ b/doc/src/sgml/images/Makefile
@@ -3,6 +3,7 @@
 # see README in this directory about image handling
 
 ALL_IMAGES = \
+	genetic-algorithm.svg \
 	gin.svg \
 	pagelayout.svg
 
diff --git a/doc/src/sgml/images/genetic-algorithm.gv b/doc/src/sgml/images/genetic-algorithm.gv
index e69de29bb2..520c44bc65 100644
--- a/doc/src/sgml/images/genetic-algorithm.gv
+++ b/doc/src/sgml/images/genetic-algorithm.gv
@@ -0,0 +1,51 @@
+digraph {
+
+	layout=dot;
+
+	// default values
+	node  [shape=box, label="", fontname="sans-serif", style=filled, fillcolor=white, width=2.2, fontsize=8];
+	graph [fontname="sans-serif"]; // must be specified separately
+	edge  [fontname="sans-serif"]; // must be specified separately
+
+	// an unobtrusive background color
+	pad="1.0, 0.5";
+	bgcolor=whitesmoke;
+
+	// layout of edges and nodes
+	splines=ortho;
+	nodesep=0.3;
+	ranksep=0.3;
+
+	// label="Structure of a Genetic Algorithm" fontsize=26;
+
+	// nodes 
+	a1[label="INITIALIZE t := 0"];
+	a2[label="INITIALIZE P(t)"];
+	a3[label="evaluate FITNESS of P(t)"];
+	a4[shape="diamond", label="STOPPING CRITERION"; width=4];
+
+	// connect 'end' node with 'a9' node (bottom of figure)
+	{
+	  rank=same;
+	  a9[label="t := t + 1"];
+	  // end-symbol similar to UML notation
+	  end[shape=doublecircle, label="end", width=0.5];
+	}
+
+	a5[label="P'(t) := RECOMBINATION{P(t)}"];
+	a6[label="P''(t) := MUTATION{P'(t)}"];
+	a7[label="P(t+1) := SELECTION{P''(t) + P(t)}"];
+	a8[label="evaluate FITNESS of P''(t)"];
+
+	// edges
+	a1 -> a2 -> a3 -> a4;
+	a4 -> a5[xlabel="false   ", fontsize=10];
+	a4 -> end[xlabel="true  ",  fontsize=10];
+	a5 -> a6 -> a7 -> a8 -> a9;
+	a4 -> a9 [dir=back]; // forces 'true'-edge to right side of figure
+
+	// explain the notation
+	expl [shape=plaintext, fontsize=10, width=3.2, fillcolor=whitesmoke,
+	      label="P(t) generation of ancestors at a time t\nP''(t) generation of descendants at a time t"];
+
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.