CompAnn -- Evolutionsprojekte

Table of Contents


Next: , Up: (dir)

CompAnn — Evolutionsprojekte

Zu CompAnn gehören neben den Neuroevolutionswerkzeugen selbst auch beispielhafte Evolutionsprojekte, die einerseits die Nützlichkeit und Wirksamkeit von CompAnn demonstrieren sollen, und andererseits als Vorlage für eigene Projekte dienen können.


Next: , Previous: Top, Up: Top

1 Neuroevolution mit EvAnn

Neben dem Compiler cann stellt EvAnn als Bibliothek die Werkzeuge zur Neuroevolution selbst zur Verfügung. Genauere Informationen zu EvAnn finden sich in der technischen Dokumentation.

Die Vorgehensweise bei den Beispiel-Projekten war stets dieselbe, und ich schlage dieses Schema generell für EvAnn-Projekte vor:

  1. Formulieren der Aufgabenstellung bzw. der Ziele, welche Aufgabe soll das ANN möglichst optimal erfüllen?
  2. Implementierung eines Evaluators, der die ANNs nach ihrer Eignung für die gestellte Aufgabe bewertet; dies ist der Code, der verschiedene EvAnn-Projekte voneinander unterscheidet.
  3. Dieser Evaluator wird mit dem allgemeinen EvAnn-Code selbst zum Evolutionsprogramm kombiniert.
  4. Programmieren einer einfachen Lösung für das Problem in Anne, die dann als Ausgangspunkt der Evolution dient.
  5. Dem Computer viel Rechenzeit gönnen, die Evolution durchführen und die Ergebnisse auswerten.


Next: , Previous: Allgemein, Up: Top

2 sum — Summe zweier Binärzahlen

sum war das erste Testprojekt, und als solches geht es um eine eher bescheidene bzw. auch nicht wirklich “nützliche” Aufgabe.


Next: , Up: sum

2.1 Aufgabenstellung

Die Aufgabenstellung bei sum war es, ein ANN zu finden, das zwei 4-Bit-Binärzahlen richtig addiert, wobei die Addition “mit Überlauf” gefragt ist, also nur die 4 niederwertigen Bits des Ergebnisses.

Ein ANN, das die erlaubte Laufzeit von 10 Iterationen überschreitet (da es höchstwahrscheinlich nicht mehr ein gültiges “Programm” ist), wird mit einer negativen Fitness disqualifiziert.

Die Bewertung eines Ergebnisses kann hierbei auf zwei Arten erfolgen:

2.1.1 Bit-Modus

Im Bit-Modus wird die Anzahl der richtigen Bits des Ergebnisses gezählt; die Gesamtfitness ist der Durchschnitt an richtigen Bits über alle 256 möglichen Inputs.

2.1.2 Differenz-Modus

Der Differenz-Modus bewertet die Differenz zwischen ausgegebenem und richtigem Ergebnis. Die Fitness ergibt sich als 16-d, wobei d der Mittelwert der Ergebnis-Differenz bei allen möglichen Eingaben ist.


Next: , Previous: sum Aufgabe, Up: sum

2.2 Ausgangspunkt

Als Ausgangspunkt für die Addition habe ich die binäre XOR-Funktion der beiden Summanden gewählt, da es auf Bitebene durchaus einige Gemeinsamkeiten zwischen XOR-Funktion und der gewünschten Summe gibt.

Das Ausgangsprogamm in Anne war somit:

     input uint4 a;
     input uint4 b;
     
     output uint4 out;
     
     out=a^b;


Next: , Previous: sum Ausgangspunkt, Up: sum

2.3 Ergebnisse

Mit einer verwendeten Populationsgröße von 100 Individuen stieg die Fitness der ANNs schon in den ersten Generationen sehr stark an, so dass die Wirksamkeit von Neuroevolution auf ein ANN dieser Größenordnung (wenige Neuronen, kurze Laufzeit, nicht sehr komplex) sehr schön ersichtlich ist.

Bei den verwendeten Einstellungen und auf dem verwendeten System entsprechen in etwa 3 Generationen einer Laufzeitsekunde.

2.3.1 Differenz-Modus

12.4375
Fitness des Ausgangspunktes.
13.85
Nach 100 Generationen.
14.39
Nach 500 Generationen.
14.58
Nach 1000 Generationen.
15.06
Nach knapp 3900 Generationen.
15.38
Nach 10000 Generationen.
15.9375
Nach 50000 Generationen.

Es wurde somit bereits nach einer Laufzeit von rund 21 Minuten, was für Neuroevolution noch leicht in den Bereich sehr kurz fällt, eine Fitness erreicht, die einer durchschnittlichen Abweichung von nur mehr einer Einheit entspricht; und das, obwohl die Summe zweier Binärzahlen, noch dazu mit einer so kurzen Laufzeit und Neuronenanzahl, sicherlich keine triviale Aufgabe für ein ANN darstellt!

Der Fitnesswert von 15.9375 wurde später in meinen Tests nicht mehr übertroffen — jedoch ist dieser Wert für rund 4.5 Stunden Laufzeit bereits sehr nahe an den perfekten 16, immerhin bedeutet er ein richtiges Ergebnis in 15 von 16 Fällen, und in dem einen Fall auch nur eine Abweichung um eine Einheit!

2.3.2 Bit-Modus

2.875
Fitness des Ausgangspunktes.
3.19
Nach 100 Generationen.
3.38
Nach 500 Generationen.
3.5
Nach rund 900 Generationen.

Somit wurde schon sehr bald die Fitness 3.5 erreicht, die bedeutet, dass das Ergebnis in der Hälfte aller Fälle richtig war, und in der anderen Hälfte nur ein Bit davon nicht stimmte.

Ein besseres Ergebnis erzielten meine Testläufe jedoch nicht einmal mehr nach bedeutend längerer Zeit; der Differenz-Modus scheint somit die bessere Art der Fitness-Bemessung für diese Aufgabe zu sein (wobei natürlich auch die Anforderungen ans ANN unterschiedlich sind).


Previous: sum Ergebnis, Up: sum

2.4 sum ohne Vorgabe

Um den Vorteil einer vorgegebenen Strategie als Ausgangspunkt einschätzen zu können, habe ich dieselbe Evolution unter gleichen Bedingungen mit einer rein zufälligen Ausganspopulation gestartet.

Obwohl eine Aufgabe dieser Einfachheit sehr wohl auch schon teilweise erfolgreich von zufälligen ANNs gelöst werden kann (die Fitness 12 wurde erstaunlicherweise auch ohne Vorgabe schon innerhalb der ersten 10 Generationen erreicht!), und somit die Evolution auch ohne Vorgabe funktioniert, stagnierte der Evolutionsprozess deutlich früher — so war die Fitness nach 50000 Generationen erst bei 14.20 angelangt!


Next: , Previous: sum, Up: Top

3 poker — Ein intelligenter Spieler

poker soll die Evolutionsfähigkeit eines kompilierten ANNs beweisen, wenn sowohl die Aufgabe wie auch das Programm komplexer werden.


Next: , Up: poker

3.1 Aufgabenstellung

Das Ziel von poker ist es, einen möglichst intelligenten Spieler für das im nächsten Abschnitt beschriebene Spiel (von Poker abgeleitet) zu finden. Es geht dabei um die Herausforderung, seine Strategie beim Wetten auf das aktuelle Spiel an seine Gewinnchancen wie auch das Verhalten seiner Gegenspieler anzupassen.

Die Interaktion erfolgt über einfache Programmaufrufe mit Parameterübergabe (für jede Wette), da die Spielsituation noch recht gut mit wenigen Parametern übergeben werden kann, und eine Interaktion mittels Callbacks das ANN nur zusätzlich unnötig mit der Speicherung des Spielverlaufs belasten würde.


Next: , Previous: poker Aufgabe, Up: poker

3.2 Regeln

Ich verwende keine echte Poker-Variante mit Kartenkombinationen sondern eine Kombination aus zwei Würfeln, damit die Einschätzung der Gewinnchance für die ANNs einfacher wird; denn wäre ein echter Poker-Spieler gesucht, läge die Hauptschwierigkeit ja auch nicht in dieser Wahrscheinlichkeitsberechnung sondern im Element des Wettens auf gewisse Kombinationen gegen andere Spieler, das auch in meiner Poker-Variante vorkommt.

3.2.1 Spielprinzip

Bei diesem Spiel geht es darum, sein Startkapital (256 Einheiten) möglichst zu vermehren; je Spiel zahlen die Spieler in einen gemeinsamen Pot, der am Ende einem Sieger zugeteilt wird. Ein Spieler darf auch Schulden machen, jedoch nur mit gewissen Einschränkungen (wird später genauer erklärt).

Zu Beginn jedes Spiels zahlt jeder Spieler 1 Einheit Ante in den Pot, sozusagen als “Spielgebühr”. Danach würfelt er mit einem Würfel, das Ergebnis des Wurfs ist bis zum Spielende nur ihm bekannt.

Es folgt die erste Wettrunde, die ganz gleich wie beim herkömmlichen Poker gespielt wird: Der Reihe nach zahlen die Spieler ihre Einsätze in den Pot, jeweils mindestens so viel wie der vorhergehende Spieler oder gar nichts, wenn man dieses Spiel aufgeben möchte. Die Wettrunde endet, wenn wieder derjenige Spieler an die Reihe kommt, der zuletzt erhöht hat (also eine Runde lang jeder andere nur gleichgezogen ist), oder wenn nur mehr ein Spieler übrig bleibt, der sofort der Sieger dieses Spiels ist.

Nach der ersten Wettrunde wird mit einem zweiten Würfel wieder geheim gewürfelt, und es folgt die zweite Wettrunde ganz gleich wie die erste; danach kommt es zum Showdown: Wer von den verbleibenden Spielern die beste Kombination hat, gewinnt den gesamten Pot; haben zwei Spieler dieselbe Kombination, wird der Gewinn gleichmäßig auf alle Gewinner aufgeteilt.

Der Wert der Kombination aus zwei Würfeln ergibt sich folgendermaßen:

Somit reichen die “normalen Kombinationen” im Wert von 21 bis 65, danach kommt der Einser-Pasch, und die höchste mögliche Kombination ist ein Sechser-Pasch.

3.2.2 ANN-Aufruf und Disqualifikation

Vom ANN wird erwartet, dass es je nach Spielsituation seinen neuen Einsatz (den Betrag, den der Spieler in den Pot zahlen möchte), berechnet und zurück liefert; diese Eingabewerte werden dazu zur Beschreibung des aktuellen Spiels übergeben:

pot
Der aktuelle Potinhalt.
curBet
Das aktuelle Gesamtgebot, auf das gleichgezogen werden muss.
minBet
Der Betrag, der zum Gleichziehen gewettet werden muss; niedriger darf der Rückgabewert nur dann sein, wenn das ANN aufgibt (und nichts zahlt).
maxBet
Der maximal hinzu wettbare Betrag; das obere Limit für die Gesamtwette beträgt 256 Einheiten. Der Rückgabewert darf nicht größer als maxBet sein.
myMoney
Aktueller Selbst-Kontostand bzw. 0, wenn man bereits Schulden hat.
die1
Wert des ersten eigenen Würfels.
die2
Wert des zweiten eigenen Würfels oder 0, wenn dieser noch unbekannt ist.
round
Gibt die aktuelle Wettrunde an (0 oder 1).

Ungültige Züge, die zur Disqualifikation führen, sind:


Next: , Previous: poker Regeln, Up: poker

3.3 Bewertung der Fitness

Zur Fitnessbewertung wird bei poker nicht jedes ANN einzeln getestet, sondern die ANNs spielen dabei gegeneinander, das erzielte Ergebnis wird als Fitness verwendet. Wird ein ANN disqualifiziert oder überschreitet es die zuerkannte Laufzeit von 100 Iterationen, so gilt die Fitness für diese Runde als -65536. Im genauen Ablauf unterscheiden sich zwei mögliche Modi:

3.3.1 Geld-Modus

Jede Runde besteht aus 50 Spielen, die in Folge gespielt werden; nach jeder Runde erhalten die Spieler wieder ein gleiches Startkapital und werden wieder in zufälliger Reihenfolge zu anderen Mitspielern an die Tische verteilt.

Es werden 10 Runden gespielt, die Gesamt-Fitness eines ANNs ist die Summe der jeweiligen Endkontostände.

3.3.2 KO-Modus

Ein Spieler, der ins Minus rutscht, scheidet aus; die Runde geht so lange, bis nur mehr einer übrig ist. Nach der ersten Runde werden Spieler, die an ihren jeweiligen Tischen den gleichen “Rang” erzielt haben, zusammen an einen neuen Tisch gesetzt, und in dieser zweiten Runde wird ihr Rang untereinander ausgespielt.

Durch dieses “Turnier” wird die Gruppe in eine ranggeordnete Reihenfolge gebracht, die der nach diesem Modus ermittelten Fitness entspricht.

Hier werden nur zwei Runden gespielt, und die Anzahl der Spiele je Runde ist unbegrenzt (sie hängt davon ab, wann alle bis auf einen Spieler ausgeschieden sind).


Next: , Previous: poker Bewertung, Up: poker

3.4 Schwierigkeiten

Der Ansatz, dass die Fitness der ANNs nicht mehr absolut sondern im Wettstreit mit den anderen Populationsmitgliedern ermittelt wird, ist nicht nur “interessant” bzw. für die gegebene Aufgabenstellung der einzige praktikable Weg, sondern führt leider auch zu ein paar Schwierigkeiten:


Next: , Previous: poker Probleme, Up: poker

3.5 Vorgegebene Strategien

Um natürlich auch bei poker das “CompAnn-System” zu benutzen, habe ich auch hier vier Strategien vorprogrammiert und sowohl als konstante Gegenspieler zur Bewertung der anderen ANNs wie auch als Ausgangspunkte der Evolution verwendet:

Folder
Gibt schlicht und einfach jedes Mal sofort auf.
Caller
Geht immer mit, solange der Caller noch nicht verschuldet ist.
Pascher
Geht in der ersten Runde immer mit und erhöht aggressiv in der zweiten, wenn ein Pasch gewürfelt wurde; wenn nicht, gibt der Pascher auf.
Poker
Die “beste” vordefinierte Strategie, die nicht so speziell wie die anderen drei ist; sie wettet nach einer mehrstufigen Fallunterscheidung von mir (intuitiv) vorgegebene Beträge.

Es wird somit eigentlich ein breites Spektrum an Spielweisen, wie sie auch in echten Pokerspielen von Menschen zu finden sind, abgedeckt: Der Folder wartet (bis ins Unendliche) auf einen Royal Flush, der Caller gibt im Vertrauen auf sein Glück niemals auf und der Pascher spielt sehr aggressiv, wenn er ein gutes Blatt zu haben glaubt.

Die “Poker”-Strategie selbst stellt einen Versuch dar, diese Eigenschaften möglichst gut zu vereinen, und kann damit sicher schon als “brauchbare” Strategie gelten, wenn sie auch trotzdem sehr einfach gehalten ist.


Next: , Previous: poker Ausgang, Up: poker

3.6 Ergebnisse

Da ich bei poker keine absolute Fitness der besten ANNs mehr angeben kann, werde ich hier Ergebnislisten von gespielten Poker-Turnieren als Beschreibung des jeweilig erzielten Stands einfügen; die Turnier-Spieler sind jeweils die vorgegebenen ANNs sowie die 10 aktuell besten Populationsmitglieder, die mit ANN bezeichnet werden.

Da es sich wie oben schon erwähnt um ein Glücksspiel handelt, ist es nicht auszuschließen bzw. sogar in einen gewissen Maße wahrscheinlich, dass die Turnierergebnisse mit gleichen Spielern vom einen zum anderen Mal variieren. Um diese Abweichungen ein wenig auszugleichen, werden jeweils 100 Wiederholungen des Systems gespielt, nach dem die ANNs während der Evolution bewertet wurden (siehe poker Bewertung); die Summe der dabei erzielten Fitness-Werte ist für das Gesamtranking ausschlaggebend und wird ebenso in der Ergebnisliste mitangegeben.

3.6.1 Geld-Modus

In diesem Modus dauert eine Generation in etwa 20 Laufzeitsekunden, das Ranking der Vorgabe-Strategien ist:

# Strategie Summe
1. Poker 1222213
2. Folder 110640
3. Pascher -141514
4. Caller -168326

Nach 100 Generationen hat sich die Population mit einigen Derivaten des Poker-Algorithmus gefüllt, die aber nur schwächer geworden sind:

# Strategie Summe
1. Poker 190453
2. ANN 188108
3. ANN 176691
4. ANN 170738
5. ANN 166903
6. ANN 155067
7. ANN 149122
8. ANN 146524
9. ANN 139291
10. ANN 138804
11. ANN 137725
12. Folder -24176
13. Caller -54789
14. Pascher -1324438

Nach 500 Generationen sind bereits Populationsmitglieder vorhanden, die (ob Zufall oder nicht) die Ausgangsstrategie schlagen:

# Strategie Summe
1. ANN 1154292
2. ANN 1092472
3. ANN 1049130
4. ANN 1032012
5. Poker 1015129
6. ANN 956468
7. ANN 920816
8. ANN 915469
9. ANN 877949
10. ANN 866393
11. ANN 718109
12. Folder -18298
13. Caller -320374
14. Pascher -6696442

Dieser Vorsprung vergrößert sich bei 1000 Generationen:

# Strategie Summe
1. ANN 1082217
2. ANN 1054668
3. ANN 1040945
4. ANN 1035375
5. ANN 1029182
6. ANN 990754
7. Poker 942640
8. ANN 918367
9. ANN 912709
10. ANN 895273
11. ANN 820239
12. Folder -17621
13. Caller -321276
14. Pascher -6821189

Nach 5000 Generationen wurde die Ausgangsstrategie sogar von allen Populationsmitgliedern geschlagen:

# Strategie Summe
1. ANN 1169660
2. ANN 1047099
3. ANN 1007357
4. ANN 997625
5. ANN 960176
6. ANN 945422
7. ANN 906975
8. ANN 906300
9. ANN 905736
10. ANN 902529
11. Poker 891429
12. Folder -17803
13. Caller -317799
14. Pascher -6741184

Bei Generation 10000 kam die große Überraschung: Wie aus dem Verlauf der Endkontostände des jeweils besten ANNs einer Generation deutlich zu ersehen ist (Sprung von 20000 auf 50000 und mehr in wenigen Generationen!), fand ein ANN zwischen den Generationen 7775 und 7800 eine deutlich bessere Strategie, bzw. vermutlich eine Strategie, die die Schwächen der vordefinierten Verfahren, vor allem auch des “Poker”-Spielers, viel besser ausnützt, als es zuvor geschehen war!

Damit war zu diesem Zeitpunkt und nach gut 40 Stunden Laufzeit das Zeitalter meiner handprogrammierten Strategie(n) vorüber:

# Strategie Summe
1. ANN 2804921
2. ANN 2603740
3. ANN 2481769
4. ANN 2326535
5. ANN 2248559
6. ANN 2027041
7. ANN 1579749
8. ANN 1424550
9. ANN 1204667
10. ANN 1181381
11. Folder -12588
12. Poker -300900
13. Caller -328007
14. Pascher -15666747

Dieses beste ANN, das die Gegenstrategie zu meinen vordefinierten “Intelligenzen” darstellt, habe ich für die weitere Evolution als festes Populationsmitglied, wie eben die vier vordefinierten Strategien, aufgenommen und kennzeichne es in den folgenden Ranglisten mit Antipoker.

Nach 15000 Generationen hat sich schon lange wieder eine Gegenstrategie zu Antipoker entwickelt:

# Strategie Summe
1. ANN 2808233
2. ANN 2548897
3. ANN 2497800
4. ANN 2424534
5. ANN 2277031
6. ANN 1947973
7. ANN 1727092
8. Antipoker 1636369
9. ANN 1352735
10. ANN 1342082
11. ANN 1208307
12. Folder -14669
13. Caller -335523
14. Poker -858017
15. Pascher -16739984

Ich habe mich entschlossen, das Evolutionsexperiment an diesem Punkt abzubrechen; ich habe den Sieger dieses obigen Turniers als Evolution ausgewählt und abschließend noch ein paar Turniere mit unterschiedlichen Spielermengen durchgeführt. Die endgültige Rangliste ist:

# Strategie Summe
1. Evolution 4824897
2. Antipoker 3844896
3. Poker 474211
4. Folder 49337
5. Caller 288229
6. Pascher 7371716

Dieses Ergebnis entspricht somit voll und ganz den Erwartungen; die Poker-Strategie schneidet wohl deshalb hier deutlich besser ab als in den Zwischenständen, da hier nur 2 und nicht 10 Evolutionsspieler vorhanden sind, die vermutlich alle eine Strategie auf Antipoker basierend verwenden. Das schlechte Ergebnis des Paschers (hier wie auch schon weiter oben) ist dadurch zu erklären, dass diese Strategie oft doch recht gewagt sehr aggressiv erhöht.

Es mag sich nun die Frage stellen, ob die Evolutionsstrategien auf einen gewissen anderen Spieler als “Geldlieferanten” angewiesen sind, gegen den sie besonders effektiv spielen; doch auch wenn je einer der obigen Gegner weggelassen wird, bleibt bzw. bleiben die Evolutionsstrategie(n) absolut ungeschlagen.

Ebenso ungeschlagen bleibt der Evolutionssieger im Einzelduell mit jeder dieser anderen Strategien. Die Evolution dieses doch sicherlich komplizierten, kompilierten ANNs ist somit offensichtlich sehr erfolgreich und alles andere als unmöglich oder ineffizient abgelaufen!

3.6.2 KO-Modus

In diesem Modus ist das Ranking der Ausgangsstrategien gleich:

# Strategie Summe
1. Poker 1366
2. Folder 803
3. Pascher 614
4. Caller 217

Allerdings gab ich ernsthafte Evolutionsversuche mit dieser Art der Bewertung sehr bald auf, da die Laufzeit einer Generation bei mehr als 2 Minuten liegt, also 6 Mal höher als im Geld-Modus, der ja schon je Generation für jedes Populationsmitglied 500 Spiele simuliert.

Dies liegt daran, dass Spiele zwischen Spielern mit sehr ähnlicher oder sogar gleicher Strategie ziemlich lange hingezogen werden, da ja so lange gespielt wird, bis einer dieser pleite geht — was durch die zufallsbedingten “Unfairheiten” zwar früher oder später passiert, aber meistens eine sehr große Zahl an Spielen dauert.

Es ist jedoch anzunehmen, dass in diesem Modus ähnliche oder wahrscheinlich sogar schlechtere Ergebnisse zu erwarten wären, wie es im Geld-Modus der Fall ist — denn dort wird die Fitness besser (bzw. fairer) abgestuft, und es sind (beinahe) gleiche Fitnesswerte für gleiche Strategien möglich, was der evolutionsbedingten Selektion sicher eher zu Gute kommt.


Previous: poker Ergebnis, Up: poker

3.7 Vergleich ohne Vorgabe

Um auch hier den Vergleich zur Evolution ohne Vorgabe zu haben, habe ich unter gleichen Bedingungen (nur im Geld-Modus) eine Evolution von zufälligen ANNs ausgehend simuliert.

Nach 50000 Generationen (gut 4 Stunden Laufzeit) habe ich den Versuch wieder abgebrochen, denn wie fast zu erwarten war, konnte kein einziges ANN über die Fitness von -65536 hinauskommen, also von der Strategie einmal abgesehen überhaupt richtig spielen.

Man muss natürlich zugeben, dass es hier ja auch quasi darum ging, solange zufällig zu probieren, bis wenigstens ein ANN einmal nicht disqualifiziert wird; denn solange alle dieselbe Fitness haben, wirken auch noch keine Prinzipien von Evolution! Mit einem ausgefeilteren Bewertungsschema und einer für diesen Fall optimierten Evolutionssimulation hätte man sicherlich bessere Ergebnisse erzielen können, jedoch bestimmt in keiner Weise so einfach und erfolgreich wie mittels vorgegebener Strategien unter Verwendung von CompAnn!


Previous: poker, Up: Top

Appendix A GNU Free Documentation License

		GNU Free Documentation License
		  Version 1.2, November 2002


 Copyright (C) 2000,2001,2002  Free Software Foundation, Inc.
     51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.


0. PREAMBLE

The purpose of this License is to make a manual, textbook, or other
functional and useful document "free" in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.

This License is a kind of "copyleft", which means that derivative
works of the document must themselves be free in the same sense.  It
complements the GNU General Public License, which is a copyleft
license designed for free software.

We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does.  But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book.  We recommend this License
principally for works whose purpose is instruction or reference.


1. APPLICABILITY AND DEFINITIONS

This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License.  Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein.  The "Document", below,
refers to any such manual or work.  Any member of the public is a
licensee, and is addressed as "you".  You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.

A "Modified Version" of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.

A "Secondary Section" is a named appendix or a front-matter section of
the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall subject
(or to related matters) and contains nothing that could fall directly
within that overall subject.  (Thus, if the Document is in part a
textbook of mathematics, a Secondary Section may not explain any
mathematics.)  The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.

The "Invariant Sections" are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License.  If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant.  The Document may contain zero
Invariant Sections.  If the Document does not identify any Invariant
Sections then there are none.

The "Cover Texts" are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License.  A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.

A "Transparent" copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters.  A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text.  A copy that is not "Transparent" is called "Opaque".

Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, LaTeX input format, SGML
or XML using a publicly available DTD, and standard-conforming simple
HTML, PostScript or PDF designed for human modification.  Examples of
transparent image formats include PNG, XCF and JPG.  Opaque formats
include proprietary formats that can be read and edited only by
proprietary word processors, SGML or XML for which the DTD and/or
processing tools are not generally available, and the
machine-generated HTML, PostScript or PDF produced by some word
processors for output purposes only.

The "Title Page" means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page.  For works in
formats which do not have any title page as such, "Title Page" means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.

A section "Entitled XYZ" means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language.  (Here XYZ stands for a
specific section name mentioned below, such as "Acknowledgements",
"Dedications", "Endorsements", or "History".)  To "Preserve the Title"
of such a section when you modify the Document means that it remains a
section "Entitled XYZ" according to this definition.

The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document.  These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.


2. VERBATIM COPYING

You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License.  You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute.  However, you may accept
compensation in exchange for copies.  If you distribute a large enough
number of copies you must also follow the conditions in section 3.

You may also lend copies, under the same conditions stated above, and
you may publicly display copies.


3. COPYING IN QUANTITY

If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover.  Both covers must also clearly and legibly identify
you as the publisher of these copies.  The front cover must present
the full title with all words of the title equally prominent and
visible.  You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.

If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.

If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.

It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.


4. MODIFICATIONS

You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it.  In addition, you must do these things in the Modified Version:

A. Use in the Title Page (and on the covers, if any) a title distinct
   from that of the Document, and from those of previous versions
   (which should, if there were any, be listed in the History section
   of the Document).  You may use the same title as a previous version
   if the original publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities
   responsible for authorship of the modifications in the Modified
   Version, together with at least five of the principal authors of the
   Document (all of its principal authors, if it has fewer than five),
   unless they release you from this requirement.
C. State on the Title page the name of the publisher of the
   Modified Version, as the publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications
   adjacent to the other copyright notices.
F. Include, immediately after the copyright notices, a license notice
   giving the public permission to use the Modified Version under the
   terms of this License, in the form shown in the Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections
   and required Cover Texts given in the Document's license notice.
H. Include an unaltered copy of this License.
I. Preserve the section Entitled "History", Preserve its Title, and add
   to it an item stating at least the title, year, new authors, and
   publisher of the Modified Version as given on the Title Page.  If
   there is no section Entitled "History" in the Document, create one
   stating the title, year, authors, and publisher of the Document as
   given on its Title Page, then add an item describing the Modified
   Version as stated in the previous sentence.
J. Preserve the network location, if any, given in the Document for
   public access to a Transparent copy of the Document, and likewise
   the network locations given in the Document for previous versions
   it was based on.  These may be placed in the "History" section.
   You may omit a network location for a work that was published at
   least four years before the Document itself, or if the original
   publisher of the version it refers to gives permission.
K. For any section Entitled "Acknowledgements" or "Dedications",
   Preserve the Title of the section, and preserve in the section all
   the substance and tone of each of the contributor acknowledgements
   and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document,
   unaltered in their text and in their titles.  Section numbers
   or the equivalent are not considered part of the section titles.
M. Delete any section Entitled "Endorsements".  Such a section
   may not be included in the Modified Version.
N. Do not retitle any existing section to be Entitled "Endorsements"
   or to conflict in title with any Invariant Section.
O. Preserve any Warranty Disclaimers.

If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant.  To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.

You may add a section Entitled "Endorsements", provided it contains
nothing but endorsements of your Modified Version by various
parties--for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.

You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version.  Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity.  If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.

The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.


5. COMBINING DOCUMENTS

You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.

The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy.  If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.

In the combination, you must combine any sections Entitled "History"
in the various original documents, forming one section Entitled
"History"; likewise combine any sections Entitled "Acknowledgements",
and any sections Entitled "Dedications".  You must delete all sections
Entitled "Endorsements".


6. COLLECTIONS OF DOCUMENTS

You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.

You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.


7. AGGREGATION WITH INDEPENDENT WORKS

A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an "aggregate" if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.

If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.


8. TRANSLATION

Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections.  You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers.  In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.

If a section in the Document is Entitled "Acknowledgements",
"Dedications", or "History", the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.


9. TERMINATION

You may not copy, modify, sublicense, or distribute the Document except
as expressly provided for under this License.  Any other attempt to
copy, modify, sublicense or distribute the Document is void, and will
automatically terminate your rights under this License.  However,
parties who have received copies, or rights, from you under this
License will not have their licenses terminated so long as such
parties remain in full compliance.


10. FUTURE REVISIONS OF THIS LICENSE

The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time.  Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.  See
http://www.gnu.org/copyleft/.

Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License "or any later version" applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation.  If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.


ADDENDUM: How to use this License for your documents

To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:

    Copyright (c)  YEAR  YOUR NAME.
    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 1.2
    or any later version published by the Free Software Foundation;
    with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
    A copy of the license is included in the section entitled "GNU
    Free Documentation License".

If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the "with...Texts." line with this:

    with the Invariant Sections being LIST THEIR TITLES, with the
    Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.

If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.

If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.