pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Make 'Genetic Algorithm' a real figure
3+ messages / 2 participants
[nested] [flat]

Commits from this thread:
  2019-08-19 28b6ec1df6  Replace genetic algorithm ASCII-art with a real figure
* Make 'Genetic Algorithm' a real figure
@ 2019-07-08 10:59  Jürgen Purtz <juergen@purtz.de>
  0 siblings, 1 reply; 3+ messages in thread

From: Jürgen Purtz @ 2019-07-08 10:59 UTC (permalink / raw)
  To: Pg Docs <pgsql-docs@lists.postgresql.org>

Currently the 'figure' of a genetic algorithm is created with some kind 
of 'ascii art'. The patch makes it a real figure.

Kind regards

Jürgen Purtz

Attachments:

Screenshot from 2019-07-08 12-52-59.png (image/png, 49.1K) download view image
genetic-algorithm.patch (text/x-patch, 11.7K) download 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..170cc9ee28 100644 --- a/doc/src/sgml/images/genetic-algorithm.gv +++ b/doc/src/sgml/images/genetic-algorithm.gv @@ -0,0 +1,44 @@ +digraph { + layout=dot; + splines=ortho; + nodesep=0.3; + ranksep=0.3; + node [shape=box; width=2.2; fontsize=8]; + pad="1.0, 0.5"; + bgcolor=grey95; + + // title + // 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; + label="P(t) generation of ancestors at a time t\nP''(t) generation of descendants at a time t"]; + +} diff --git a/doc/src/sgml/images/genetic-algorithm.svg b/doc/src/sgml/images/genetic-algorithm.svg index e69de29bb2..2db8bef230 100644 --- a/doc/src/sgml/images/genetic-algorithm.svg +++ b/doc/src/sgml/images/genetic-algorithm.svg @@ -0,0 +1,139 @@ +<?xml version="1.0"?> +<!-- Generated by graphviz version 2.40.1 (20161225.0304) + --> +<!-- Title: %3 Pages: 1 --> +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="619pt" height="580pt" viewBox="0.00 0.00 619.00 580.00"> +<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(72 544)"> +<title>%3</title> +<polygon fill="#f2f2f2" stroke="none" points="-72,36 -72,-544 547,-544 547,36 -72,36"/> +<!-- a1 --> +<g id="node1" class="node"> +<title>a1</title> +<polygon fill="none" stroke="#000000" points="223,-508 65,-508 65,-472 223,-472 223,-508"/> +<text text-anchor="middle" x="144" y="-487.6" font-family="Times,serif" font-size="8.00" fill="#000000">INITIALIZE t := 0</text> +</g> +<!-- a2 --> +<g id="node2" class="node"> +<title>a2</title> +<polygon fill="none" stroke="#000000" points="223,-450 65,-450 65,-414 223,-414 223,-450"/> +<text text-anchor="middle" x="144" y="-429.6" font-family="Times,serif" font-size="8.00" fill="#000000">INITIALIZE P(t)</text> +</g> +<!-- a1&#45;&gt;a2 --> +<g id="edge1" class="edge"> +<title>a1-&gt;a2</title> +<path fill="none" stroke="#000000" d="M144,-471.9664C144,-471.9664 144,-460.2222 144,-460.2222"/> +<polygon fill="#000000" stroke="#000000" points="147.5001,-460.2222 144,-450.2222 140.5001,-460.2223 147.5001,-460.2222"/> +</g> +<!-- a3 --> +<g id="node3" class="node"> +<title>a3</title> +<polygon fill="none" stroke="#000000" points="223,-392 65,-392 65,-356 223,-356 223,-392"/> +<text text-anchor="middle" x="144" y="-371.6" font-family="Times,serif" font-size="8.00" fill="#000000">evaluate FITNESS of P(t)</text> +</g> +<!-- a2&#45;&gt;a3 --> +<g id="edge2" class="edge"> +<title>a2-&gt;a3</title> +<path fill="none" stroke="#000000" d="M144,-413.9664C144,-413.9664 144,-402.2222 144,-402.2222"/> +<polygon fill="#000000" stroke="#000000" points="147.5001,-402.2222 144,-392.2222 140.5001,-402.2223 147.5001,-402.2222"/> +</g> +<!-- a4 --> +<g id="node4" class="node"> +<title>a4</title> +<polygon fill="none" stroke="#000000" points="144,-334 0,-316 144,-298 288,-316 144,-334"/> +<text text-anchor="middle" x="144" y="-313.6" font-family="Times,serif" font-size="8.00" fill="#000000">STOPPING CRITERION</text> +</g> +<!-- a3&#45;&gt;a4 --> +<g id="edge3" class="edge"> +<title>a3-&gt;a4</title> +<path fill="none" stroke="#000000" d="M144,-355.9664C144,-355.9664 144,-344.2222 144,-344.2222"/> +<polygon fill="#000000" stroke="#000000" points="147.5001,-344.2222 144,-334.2222 140.5001,-344.2223 147.5001,-344.2222"/> +</g> +<!-- a9 --> +<g id="node5" class="node"> +<title>a9</title> +<polygon fill="none" stroke="#000000" points="162,-40 4,-40 4,-4 162,-4 162,-40"/> +<text text-anchor="middle" x="83" y="-19.6" font-family="Times,serif" font-size="8.00" fill="#000000">t := t + 1</text> +</g> +<!-- a4&#45;&gt;a9 --> +<g id="edge10" class="edge"> +<title>a4-&gt;a9</title> +<path fill="none" stroke="#000000" d="M34.5,-301.382C34.5,-301.382 34.5,-40.2869 34.5,-40.2869"/> +<polygon fill="#000000" stroke="#000000" points="31.0001,-301.3819 34.5,-311.382 38.0001,-301.382 31.0001,-301.3819"/> +</g> +<!-- end --> +<g id="node6" class="node"> +<title>end</title> +<ellipse fill="none" stroke="#000000" cx="257" cy="-22" rx="18" ry="18"/> +<ellipse fill="none" stroke="#000000" cx="257" cy="-22" rx="22" ry="22"/> +<text text-anchor="middle" x="257" y="-19.6" font-family="Times,serif" font-size="8.00" fill="#000000">end</text> +</g> +<!-- a4&#45;&gt;end --> +<g id="edge5" class="edge"> +<title>a4-&gt;end</title> +<path fill="none" stroke="#000000" d="M257,-311.8439C257,-311.8439 257,-54.3202 257,-54.3202"/> +<polygon fill="#000000" stroke="#000000" points="260.5001,-54.3202 257,-44.3202 253.5001,-54.3202 260.5001,-54.3202"/> +<text text-anchor="middle" x="246.7265" y="-186.0821" font-family="Times,serif" font-size="10.00" fill="#000000">true  </text> +</g> +<!-- a5 --> +<g id="node7" class="node"> +<title>a5</title> +<polygon fill="none" stroke="#000000" points="223,-276 65,-276 65,-240 223,-240 223,-276"/> +<text text-anchor="middle" x="144" y="-255.6" font-family="Times,serif" font-size="8.00" fill="#000000">P'(t) := RECOMBINATION{P(t)}</text> +</g> +<!-- a4&#45;&gt;a5 --> +<g id="edge4" class="edge"> +<title>a4-&gt;a5</title> +<path fill="none" stroke="#000000" d="M144,-297.9664C144,-297.9664 144,-286.2222 144,-286.2222"/> +<polygon fill="#000000" stroke="#000000" points="147.5001,-286.2222 144,-276.2222 140.5001,-286.2223 147.5001,-286.2222"/> +<text text-anchor="middle" x="130.8125" y="-283.0943" font-family="Times,serif" font-size="10.00" fill="#000000">false   </text> +</g> +<!-- a6 --> +<g id="node8" class="node"> +<title>a6</title> +<polygon fill="none" stroke="#000000" points="223,-218 65,-218 65,-182 223,-182 223,-218"/> +<text text-anchor="middle" x="144" y="-197.6" font-family="Times,serif" font-size="8.00" fill="#000000">P''(t) := MUTATION{P'(t)}</text> +</g> +<!-- a5&#45;&gt;a6 --> +<g id="edge6" class="edge"> +<title>a5-&gt;a6</title> +<path fill="none" stroke="#000000" d="M144,-239.9664C144,-239.9664 144,-228.2222 144,-228.2222"/> +<polygon fill="#000000" stroke="#000000" points="147.5001,-228.2222 144,-218.2222 140.5001,-228.2223 147.5001,-228.2222"/> +</g> +<!-- a7 --> +<g id="node9" class="node"> +<title>a7</title> +<polygon fill="none" stroke="#000000" points="223,-160 65,-160 65,-124 223,-124 223,-160"/> +<text text-anchor="middle" x="144" y="-139.6" font-family="Times,serif" font-size="8.00" fill="#000000">P(t+1) := SELECTION{P''(t) + P(t)}</text> +</g> +<!-- a6&#45;&gt;a7 --> +<g id="edge7" class="edge"> +<title>a6-&gt;a7</title> +<path fill="none" stroke="#000000" d="M144,-181.9664C144,-181.9664 144,-170.2222 144,-170.2222"/> +<polygon fill="#000000" stroke="#000000" points="147.5001,-170.2222 144,-160.2222 140.5001,-170.2223 147.5001,-170.2222"/> +</g> +<!-- a8 --> +<g id="node10" class="node"> +<title>a8</title> +<polygon fill="none" stroke="#000000" points="223,-102 65,-102 65,-66 223,-66 223,-102"/> +<text text-anchor="middle" x="144" y="-81.6" font-family="Times,serif" font-size="8.00" fill="#000000">evaluate FITNESS of P''(t)</text> +</g> +<!-- a7&#45;&gt;a8 --> +<g id="edge8" class="edge"> +<title>a7-&gt;a8</title> +<path fill="none" stroke="#000000" d="M144,-123.9664C144,-123.9664 144,-112.2222 144,-112.2222"/> +<polygon fill="#000000" stroke="#000000" points="147.5001,-112.2222 144,-102.2222 140.5001,-112.2223 147.5001,-112.2222"/> +</g> +<!-- a8&#45;&gt;a9 --> +<g id="edge9" class="edge"> +<title>a8-&gt;a9</title> +<path fill="none" stroke="#000000" d="M113.5,-65.7333C113.5,-65.7333 113.5,-50.3504 113.5,-50.3504"/> +<polygon fill="#000000" stroke="#000000" points="117.0001,-50.3504 113.5,-40.3504 110.0001,-50.3504 117.0001,-50.3504"/> +</g> +<!-- expl --> +<g id="node11" class="node"> +<title>expl</title> +<text text-anchor="middle" x="360" y="-493" font-family="Times,serif" font-size="10.00" fill="#000000">P(t) generation of ancestors at a time t</text> +<text text-anchor="middle" x="360" y="-481" font-family="Times,serif" font-size="10.00" fill="#000000">P''(t) generation of descendants at a time t</text> +</g> +</g> +</svg>
^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: Make 'Genetic Algorithm' a real figure
@ 2019-07-19 18:57  Jürgen Purtz <juergen@purtz.de>
  parent: Jürgen Purtz <juergen@purtz.de>
  0 siblings, 1 reply; 3+ messages in thread

From: Jürgen Purtz @ 2019-07-19 18:57 UTC (permalink / raw)
  To: Pg Docs <pgsql-docs@lists.postgresql.org>

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

Attachments:

genetic-algorithm-v1.patch (text/x-patch, 4.5K) download 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"]; + +}
^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: Make 'Genetic Algorithm' a real figure
@ 2019-08-19 16:08  Alvaro Herrera <alvherre@2ndquadrant.com>
  parent: Jürgen Purtz <juergen@purtz.de>
  0 siblings, 0 replies; 3+ messages in thread

From: Alvaro Herrera @ 2019-08-19 16:08 UTC (permalink / raw)
  To: Jürgen Purtz <juergen@purtz.de>; +Cc: Pg Docs <pgsql-docs@lists.postgresql.org>

On 2019-Jul-19, Jürgen Purtz wrote:

> 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.

I pushed this with trivial changes, thanks.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2019-08-19 16:08 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-07-08 10:59 Make 'Genetic Algorithm' a real figure Jürgen Purtz <juergen@purtz.de>
2019-07-19 18:57 ` Jürgen Purtz <juergen@purtz.de>
2019-08-19 16:08   ` Alvaro Herrera <alvherre@2ndquadrant.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox