aboutsummaryrefslogtreecommitdiffstats
path: root/src/jaulibs/menge.h
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-10-25 18:45:40 +0200
committerSven Gothel <[email protected]>2022-10-25 18:45:40 +0200
commitdbde7b6876d8124ef97b6a2ff623c63ce6fd6836 (patch)
treed5adca200b117ecbf69d3c5127add0c33081eb2d /src/jaulibs/menge.h
Initial git checking of gentech incl. river and salesman solver, original work from March 1994ancient_1994
This work was produced in March 1994 by the authors as an excessive work for a homework in OOP at the FH-Bielefeld under the supervision of Prof. Dr. Bunse. The background research and work on the actual genetic algorithm (gentech.lib) was mostly performed by Sven Gothel using [1] - [5] and other articles read about the matter earlier. Christian Mueller contributed reviewing [6], validating the algorithm and code. We finalized the code and bug fixes together. Bibliographie [1] Holland, John H. : Genetische Algorithmen, Spektrum der Wissenschaft, September 1992, S.44-51 [2] Chambon, Pierre : Gestueckelte Gene - ein Informations-Mosaik, Spektrum der Wissenschaft, Juli 1981, S.104-117 [3] Dewdney, A.K. : Genetische Algorithmen, Computer-Kurzweil, Spektrum-der-Wissenschaft-Verlagsgesellschaft 1988, ISBN 3-922508-50-2, S.68-72 [4] Weckwerth, Guido : Zeugende Zahlen, MC, Oktober 1993, S.54-58, Januar 1994, S.72-75 [5] Schader, Kuhlins : Programmieren in C++, Springer-Verlag Heidelberg 1993, ISBN 3-540-56524-8 [6] Schoeneburg, Eberhard : Genetische Algorithmen und Evolutionsstrategien Addison-Wesley 1994, ISBN 3-89319-495-2
Diffstat (limited to 'src/jaulibs/menge.h')
-rw-r--r--src/jaulibs/menge.h111
1 files changed, 111 insertions, 0 deletions
diff --git a/src/jaulibs/menge.h b/src/jaulibs/menge.h
new file mode 100644
index 0000000..2b29001
--- /dev/null
+++ b/src/jaulibs/menge.h
@@ -0,0 +1,111 @@
+// author : Sven Gothel - Stapenhorststrasse 35a - 33615 Bielefeld
+//
+// menge.h
+//
+// Original von
+// Martin Schader & Stefan Kuhlins : Programmieren in C++, Springer Verlag,
+// ISBN-3-540-56524-8
+//
+// Kapitel 18, Aufgabe 9
+//
+/*
+ *
+ * $Log: menge.h $
+ * Revision 1.4 1995/04/07 16:54:53 Sven_Gothel
+ * *** empty log message ***
+ * Revision 1.3 1995/04/04 10:37:29 Sven_Gothel
+ * *** empty log message ***
+ * Revision 1.2 1994/12/15 15:28:16 Sven_Gothel
+ * the very first check in !!!
+ * all files contains the log message now !!!
+ * Sven Gothel, Bielefeld 14.12.1994 !!!
+ *
+ * Revision 1.1 1994/12/15 15:18:42 Sven_Gothel
+ * Initial revision
+ *
+*/
+
+# ifndef _MENGE_H
+ # define _MENGE_H
+
+ #include <iostream.h>
+ #include "liste.h" // Template-Liste
+
+ template<class T> class Menge {
+ public:
+ int leer() const { return l.laenge() == 0; }
+ int card() const { return l.laenge(); }
+ int istElement(const T&);
+ int fuegeEin(const T&);
+ int loesche(const T&);
+ void inhalt() const;
+ Menge operator*(Menge&) const;
+ private:
+ Liste<T> l;
+ };
+
+ template<class T> int Menge<T>::fuegeEin(const T& x)
+ {
+ return (istElement(x) >= 0) ? 0 : l.fuegeEin(x);
+ }
+
+ template<class T> int Menge<T>::loesche(const T& x)
+ {
+ int pos = istElement(x);
+ if (pos >= 0)
+ l.loesche(pos);
+ return pos >= 0;
+ }
+
+ template<class T> int Menge<T>::istElement(const T& x)
+ {
+ for (int i = 0; i < card(); i++)
+ if (l[i] == x)
+ return i;
+ return -1;
+ }
+
+ template<class T> void Menge<T>::inhalt() const
+ {
+ cout << "{ ";
+ if (!leer()) {
+ cout << l[0];
+ for (int i=1; i<card(); i++)
+ cout << ", " << l[i];
+ }
+ cout << " }" << endl;
+ }
+
+ template<class T> Menge<T> Menge<T>::operator*(Menge<T>& a) const
+ {
+ Menge<T> axb;
+ for (int i=0; i<card(); i++)
+ if (a.istElement(l[i]) >= 0)
+ axb.fuegeEin(l[i]);
+ return axb;
+ }
+
+ // TESTTEIL DER MENGE ::
+ /*
+ int main()
+ {
+ Menge<int> m1;
+ m1.fuegeEin(127);
+ m1.fuegeEin(214);
+ m1.fuegeEin(63);
+ cout << "m1 = "; m1.inhalt();
+
+ Menge<int> m2;
+ m2.fuegeEin(127);
+ m2.fuegeEin(210);
+ m2.fuegeEin(63);
+ cout << "m2 = "; m2.inhalt();
+
+ const Menge<int> x = m1*m2;
+ cout << "m1*m2 = "; x.inhalt();
+ return 0;
+ }
+
+ */
+
+# endif