aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Holzmann <grholzi@users.sourceforge.net>2005-07-12 14:20:39 +0000
committerGeorg Holzmann <grholzi@users.sourceforge.net>2005-07-12 14:20:39 +0000
commitfd5998ef963f14817ba0059fcd5bac1eecb55f17 (patch)
treedd51bc7c707687013b813ad804d1377e30baa52a
parentefa45f81b5dcb9609b1e2365a51b7a25a1ba2ce0 (diff)
initial commit of GApop
svn path=/trunk/externals/grh/; revision=3318
-rwxr-xr-xGApop/build-pd-darwin.sh17
-rwxr-xr-xGApop/build-pd-linux.sh17
-rwxr-xr-xGApop/build-pd-mingw.bat3
-rwxr-xr-xGApop/build-pd-msvc.bat4
-rwxr-xr-xGApop/config-pd-darwin.txt35
-rwxr-xr-xGApop/config-pd-linux.txt36
-rwxr-xr-xGApop/config-pd-mingw.txt35
-rwxr-xr-xGApop/config-pd-msvc.txt19
-rwxr-xr-xGApop/gpl.txt340
-rwxr-xr-xGApop/license.txt50
-rwxr-xr-xGApop/make-files.txt3
-rwxr-xr-xGApop/makefile.pd-darwin77
-rwxr-xr-xGApop/makefile.pd-linux94
-rwxr-xr-xGApop/makefile.pd-mingw85
-rwxr-xr-xGApop/makefile.pd-msvc53
-rwxr-xr-xGApop/pd/help-GApop.pd173
-rwxr-xr-xGApop/readme.txt18
-rwxr-xr-xGApop/src/GApop.cpp495
18 files changed, 1554 insertions, 0 deletions
diff --git a/GApop/build-pd-darwin.sh b/GApop/build-pd-darwin.sh
new file mode 100755
index 0000000..38814a9
--- /dev/null
+++ b/GApop/build-pd-darwin.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+SYS=pd-darwin
+
+. config-${SYS}.txt
+
+make -f makefile.${SYS} &&
+{
+ if [ $INSTDIR != "" ]; then
+ echo Now install as root
+ sudo make -f makefile.${SYS} install
+ fi
+ if [ $HELPDIR != "" ]; then
+ echo Now install help as root
+ sudo make -f makefile.${SYS} install-help
+ fi
+}
diff --git a/GApop/build-pd-linux.sh b/GApop/build-pd-linux.sh
new file mode 100755
index 0000000..77c6e3f
--- /dev/null
+++ b/GApop/build-pd-linux.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+SYS=pd-linux
+
+. config-${SYS}.txt
+
+make -f makefile.${SYS} &&
+{
+ if [ $INSTDIR != "" ]; then
+ echo Now install as root
+ su -c "make -f makefile.${SYS} install"
+ fi
+ if [ $HELPDIR != "" ]; then
+ echo Now install help as root
+ su -c "make -f makefile.${SYS} install-help"
+ fi
+}
diff --git a/GApop/build-pd-mingw.bat b/GApop/build-pd-mingw.bat
new file mode 100755
index 0000000..fa8919a
--- /dev/null
+++ b/GApop/build-pd-mingw.bat
@@ -0,0 +1,3 @@
+mingw32-make -f makefile.pd-mingw
+mingw32-make -f makefile.pd-mingw install
+mingw32-make -f makefile.pd-mingw install-help
diff --git a/GApop/build-pd-msvc.bat b/GApop/build-pd-msvc.bat
new file mode 100755
index 0000000..d6187f0
--- /dev/null
+++ b/GApop/build-pd-msvc.bat
@@ -0,0 +1,4 @@
+@echo --- Building with MS Visual C++ ---
+
+nmake -f makefile.pd-msvc clean
+nmake -f makefile.pd-msvc
diff --git a/GApop/config-pd-darwin.txt b/GApop/config-pd-darwin.txt
new file mode 100755
index 0000000..1b84a23
--- /dev/null
+++ b/GApop/config-pd-darwin.txt
@@ -0,0 +1,35 @@
+# config file for GApop, adapted from Thomas Grill's xsample makefile
+#
+
+# your c++ compiler (if not g++)
+#CXX=g++-3.3
+
+# where does the PD installation reside?
+PD=/usr/local/lib/pd
+
+# where are the PD header files?
+# leave it blank if it is a system directory (like /usr/local/include),
+# since gcc 3.2 complains about it
+PDINC=${PD}/src
+
+# where is the PD executable?
+PDBIN=/usr/local/bin/pd
+
+# where do the flext libraries reside?
+FLEXTPATH=${PD}/flext
+
+# where should the GApop objects be built?
+TARGDIR=./pd-darwin
+
+# where should GApop be installed?
+# (leave blank to omit installation)
+INSTDIR=${PD}/extra
+
+# where should the GApop help be installed?
+# (leave blank to omit installation)
+HELPDIR=${PD}/doc/5.reference
+
+# additional compiler flags
+# (check whether they fit your system!)
+UFLAGS=-malign-power -maltivec -faltivec
+
diff --git a/GApop/config-pd-linux.txt b/GApop/config-pd-linux.txt
new file mode 100755
index 0000000..1e87ea1
--- /dev/null
+++ b/GApop/config-pd-linux.txt
@@ -0,0 +1,36 @@
+# config file for GApop, adapted from Thomas Grill's xsample makefile
+
+# your c++ compiler (if not g++)
+# CXX=icc
+
+
+# where does the PD installation reside?
+PD=/usr/lib/pd
+
+# where are the PD header files?
+# leave it blank if it is a system directory (like /usr/local/include),
+# since gcc 3.2 complains about it
+PDINC=/home/holzi/pd-0.38-4/src
+
+# where do the flext libraries reside?
+FLEXTPATH=/usr/lib/pd/flext
+
+# where should GApop objects be built?
+TARGDIR=./pd-linux
+
+# where should GApop be installed?
+# (leave blank to omit installation)
+INSTDIR=${PD}/externs
+
+# where should the GApop help be installed?
+# (leave blank to omit installation)
+HELPDIR=${PD}/doc/5.reference
+
+# additional compiler flags
+# (check whether they fit to your system!)
+#UFLAGS=-xN -tpp7 -ip -ipo_obj # icc
+UFLAGS=-march=pentium4 -mmmx -msse2 -msse -mfpmath=sse -g # gcc 3.2
+
+# define to link against shared flext library (flext version >= 0.5.0)
+FLEXT_SHARED=1
+
diff --git a/GApop/config-pd-mingw.txt b/GApop/config-pd-mingw.txt
new file mode 100755
index 0000000..6254bbd
--- /dev/null
+++ b/GApop/config-pd-mingw.txt
@@ -0,0 +1,35 @@
+# config file for GApop, adapted from Thomas Grill's xsample makefile
+#
+
+# your c++ compiler (define only if it's different than g++)
+# CXX=g++
+
+# where does the PD installation reside?
+PD=c:/programme/audio/pd
+
+# where are the PD header files?
+# leave it blank if it is a system directory (like /usr/local/include),
+# since gcc 3.2 complains about it
+PDINC=${PD}/src
+
+# where do the flext libraries reside?
+FLEXTPATH=${PD}/flext
+
+# where should GApop objects be built?
+TARGDIR=./pd-mingw
+
+# where should GApop be installed?
+# (leave blank to omit installation)
+INSTDIR=${PD}/extra
+
+# where should the GApop help be installed?
+# (leave blank to omit installation)
+HELPDIR=${PD}/doc/5.reference
+
+# additional compiler flags
+# (check whether they fit to your system!)
+UFLAGS=-mcpu=pentium4 -msse -mfpmath=sse # gcc 3.2
+# UFLAGS=-mcpu=pentiumpro # gcc 2.95
+
+# define to build with shared flext library
+# FLEXT_SHARED=1 \ No newline at end of file
diff --git a/GApop/config-pd-msvc.txt b/GApop/config-pd-msvc.txt
new file mode 100755
index 0000000..06faa52
--- /dev/null
+++ b/GApop/config-pd-msvc.txt
@@ -0,0 +1,19 @@
+# config file for GApop, adapted from Thomas Grill's xsample makefile
+#
+
+# where is PD?
+PDPATH=c:\programme\audio\pd
+
+# where do the flext libraries reside?
+FLEXTPATH=$(PDPATH)\flext
+
+# where is MS VC++?
+# (not necessary if the build started with the compiler environment)
+# MSVCPATH=c:\programme\prog\microsoft visual studio\VC98
+
+# where should the external be built?
+OUTPATH=pd-msvc
+
+# where should the external be installed?
+# (leave blank to omit installation)
+INSTDIR=$(PDPATH)\extra
diff --git a/GApop/gpl.txt b/GApop/gpl.txt
new file mode 100755
index 0000000..d60c31a
--- /dev/null
+++ b/GApop/gpl.txt
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program 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.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public 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.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/GApop/license.txt b/GApop/license.txt
new file mode 100755
index 0000000..82f6ec0
--- /dev/null
+++ b/GApop/license.txt
@@ -0,0 +1,50 @@
+GApop - genetic algorithm for PD and MAX/MSP
+Copyright (c) Georg Holzmann <grh@gmx.at>, 2004
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+In the official GApop distribution, the GNU General Public License is
+in the file gpl.txt
+
+---------------------------------------------------------
+
+ OTHER COPYRIGHT NOTICES
+
+---------------------------------------------------------
+This package uses the flext C++ layer - See its license text below:
+
+
+--- flext ----------------------------------------------
+flext - C++ layer for Max/MSP and pd (pure data) externals
+Copyright (C) 2001-2003 Thomas Grill
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+In the official flext distribution, the GNU General Public License is
+in the file gpl.txt
+
+
diff --git a/GApop/make-files.txt b/GApop/make-files.txt
new file mode 100755
index 0000000..7b5176b
--- /dev/null
+++ b/GApop/make-files.txt
@@ -0,0 +1,3 @@
+# all the source files from the package
+SRCDIR = src
+SRCS= GApop.cpp
diff --git a/GApop/makefile.pd-darwin b/GApop/makefile.pd-darwin
new file mode 100755
index 0000000..a8b338e
--- /dev/null
+++ b/GApop/makefile.pd-darwin
@@ -0,0 +1,77 @@
+# makefile adapted from thomas grill's xsample makefile
+#
+# Makefile for gcc @ OSX (darwin)
+#
+# usage:
+# to build run "make -f makefile.pd-darwin"
+# to install (as root), do "make -f makefile.pd-darwin install"
+# to install help, do "make -f makefile.pd-darwin install-help"
+#
+
+CONFIG=config-pd-darwin.txt
+
+include ${CONFIG}
+
+FLEXTLIB=$(FLEXTPATH)/libflext.a
+
+# compiler stuff
+INCLUDES=$(PDINC) ./headers/plugin_interface ./headers/common ./headers/server ./headers/app ./headers/lang /usr/include/machine/
+FLAGS=-DFLEXT_SYS=2
+CFLAGS=${UFLAGS} -dynamic -O2 -Wno-unused -Wno-parentheses -Wno-switch -Wstrict-prototypes -funroll-loops -fmove-all-movables -frerun-loop-opt -fno-rtti -fno-exceptions
+LIBS=m gcc
+LDFLAGS=$(FLEXTLIB) -bundle -bundle_loader $(PDBIN)
+FRAMEWORKS=Carbon veclib
+
+# ----------------------------------------------
+# the rest can stay untouched
+# ----------------------------------------------
+
+NAME=GApop
+
+include make-files.txt
+
+MAKEFILE=makefile.pd-darwin
+TARGET=$(TARGDIR)/$(NAME).pd_darwin
+
+
+# default target
+all: $(TARGDIR) $(TARGET)
+
+$(patsubst %,$(SRCDIR)/%,$(SRCS)): $(patsubst %,$(SRCDIR)/%,$(HDRS)) $(MAKEFILE) $(CONFIG)
+ touch $(patsubst %,$(SRCDIR)/%,$(SRCS))
+
+$(TARGDIR):
+ -mkdir $(TARGDIR)
+
+$(TARGDIR)/%.o : $(SRCDIR)/%.cpp
+ $(CXX) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES) $(FLEXTPATH)) $< -o $@
+
+$(TARGET) : $(patsubst %.cpp,$(TARGDIR)/%.o,$(SRCS))
+ $(CXX) $(LDFLAGS) $^ $(patsubst %,-framework %,$(FRAMEWORKS)) $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(LIBS)) -o $@
+ chmod 755 $@
+
+
+$(INSTDIR):
+ -mkdir $(INSTDIR)
+
+install:: $(INSTDIR)
+
+install:: $(TARGET)
+ cp -R $^ $(INSTDIR)
+# chown -R root.root $(INSTDIR)
+
+
+$(HELPDIR):
+ -mkdir $(HELPDIR)
+
+install-help:: $(HELPDIR)
+
+install-help:: ./pd
+ cp $^/*.* $(HELPDIR)
+# chown -R root.root $(HELPDIR)
+
+
+.PHONY: clean
+clean:
+ rm -f $(TARGDIR)/*.o $(TARGET)
+
diff --git a/GApop/makefile.pd-linux b/GApop/makefile.pd-linux
new file mode 100755
index 0000000..d9c34f5
--- /dev/null
+++ b/GApop/makefile.pd-linux
@@ -0,0 +1,94 @@
+# makefile adapted from thomas grill's xsample makefile
+#
+# Makefile for gcc @ linux
+#
+# usage:
+# to build run "make -f makefile.pd-linux"
+# to install (as root), do "make -f makefile.pd-linux install"
+#
+
+CONFIG=config-pd-linux.txt
+
+include ${CONFIG}
+
+FLEXTLIB=$(FLEXTPATH)/flext.a
+
+# compiler stuff
+INCLUDES=$(PDINC) ./headers/plugin_interface ./headers/common \
+ ./headers/server ./headers/app ./headers/lang
+FLAGS=-DFLEXT_SYS=2
+CFLAGS=${UFLAGS} -O3 -funroll-loops -fmove-all-movables -frerun-loop-opt -finline-functions -fno-rtti -fno-exceptions
+
+LIBS=m
+
+ifdef FLEXT_SHARED
+CFLAGS+=-DFLEXT_SHARED -DFLEXT_THREADS
+LDFLAGS+=-Bdynamic
+LINKFLEXT=-lflext_d
+else
+LINKFLEXT=$(FLEXTLIB)
+endif
+
+
+# ----------------------------------------------
+# the rest can stay untouched
+# ----------------------------------------------
+
+NAME=GApop
+
+include make-files.txt
+
+MAKEFILE=makefile.pd-linux
+TARGET=$(TARGDIR)/$(NAME).pd_linux
+
+# default target
+all: $(TARGDIR) $(TARGET)
+
+$(patsubst %,$(SRCDIR)/%,$(SRCS)): $(patsubst %,$(SRCDIR)/%,$(HDRS)) $(MAKEFILE) $(CONFIG)
+# touch $(patsubst %,$(SRCDIR)/%,$(SRCS))
+
+$(TARGDIR):
+ -mkdir $(TARGDIR)
+
+$(TARGDIR)/%.o : $(SRCDIR)/%.cpp
+ $(CXX) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES) $(FLEXTPATH)) $< -o $@
+
+$(TARGET) : $(patsubst %.cpp,$(TARGDIR)/%.o,$(SRCS))
+ $(CXX) $(LDFLAGS) -shared $^ $(patsubst %,-l%,$(LIBS)) -L$(FLEXTPATH) $(LINKFLEXT) -o $@
+ strip --strip-unneeded $@
+ chmod 755 $@
+
+$(INSTDIR):
+ -mkdir $(INSTDIR)
+
+install:: $(INSTDIR)
+
+install:: $(TARGET)
+ cp $^ $(INSTDIR)
+ chown root.root $(patsubst %,$(INSTDIR)/%,$(notdir $^))
+
+$(HELPDIR):
+ -mkdir $(HELPDIR)
+
+install-help:: $(HELPDIR)
+
+install-help:: ./pd
+ chmod 644 $^/*.*
+ cp $^/*.* $(HELPDIR)
+
+
+.PHONY: clean
+clean:
+ rm -f $(TARGDIR)/*.o $(TARGET)
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GApop/makefile.pd-mingw b/GApop/makefile.pd-mingw
new file mode 100755
index 0000000..4261527
--- /dev/null
+++ b/GApop/makefile.pd-mingw
@@ -0,0 +1,85 @@
+# makefile adapted from thomas grill's xsample makefile
+#
+# Makefile for gcc @ minGW
+#
+# usage:
+# to build run "make -f makefile.pd-mingw"
+# to install (as root), do "make -f makefile.pd-mingw install"
+#
+
+CONFIG=config-pd-mingw.txt
+MAKEFILE=makefile.pd-mingw
+
+include ${CONFIG}
+
+
+# compiler stuff
+INCLUDES=$(PDINC) ./headers/plugin_interface ./headers/common ./headers/server ./headers/app ./headers/lang
+
+FLAGS=-DFLEXT_SYS=2
+CFLAGS=-O2 -funroll-loops -fmove-all-movables -frerun-loop-opt -finline-functions -fno-rtti -fno-exceptions ${UFLAGS}
+
+PDLIBS=$(PD)/bin/pd.dll $(PD)/bin/pthreadVC.dll
+
+
+ifdef FLEXT_SHARED
+
+CFLAGS+=-DFLEXT_SHARED
+FLEXTLIB=$(FLEXTPATH)/flext.dll
+
+else
+
+FLEXTLIB=$(FLEXTPATH)/flext-pdwin.lib
+
+endif
+
+
+# ----------------------------------------------
+# the rest can stay untouched
+# ----------------------------------------------
+
+NAME=GApop
+
+include make-files.txt
+
+TARGET=$(TARGDIR)/$(NAME).dll
+
+# default target
+all: $(TARGDIR) $(TARGET)
+
+$(patsubst %,$(SRCDIR)/%,$(SRCS)): $(patsubst %,$(SRCDIR)/%,$(HDRS)) $(MAKEFILE) $(CONFIG)
+# echo touch $(patsubst %,$(SRCDIR)/%,$(SRCS)) # minGW has no touch
+
+$(TARGDIR):
+ -mkdir $(TARGDIR)
+
+$(TARGDIR)/%.o : $(SRCDIR)/%.cpp
+ $(CXX) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES) $(FLEXTPATH)) $< -o $@
+
+$(TARGET) : $(patsubst %.cpp,$(TARGDIR)/%.o,$(SRCS)) $(FLEXTLIB)
+ $(CXX) -shared $(LDFLAGS) $^ ${PDLIBS} $(patsubst %,-l%,$(LIBS)) -o $@
+ strip --strip-unneeded $@
+ chmod 755 $@
+
+$(INSTDIR):
+ -mkdir $(INSTDIR)
+
+install:: $(INSTDIR)
+
+install:: $(TARGET)
+ cp $^ $(INSTDIR)
+# chown root.root $(patsubst %,$(INSTDIR)/%,$(notdir $^))
+
+$(HELPDIR):
+ -mkdir $(HELPDIR)
+
+install-help:: $(HELPDIR)
+
+install-help:: ./pd
+ chmod 644 $^/*.*
+ cp $^/*.* $(HELPDIR)
+
+
+.PHONY: clean
+clean:
+ rm -f $(TARGDIR)/*.o $(TARGET)
diff --git a/GApop/makefile.pd-msvc b/GApop/makefile.pd-msvc
new file mode 100755
index 0000000..78161ed
--- /dev/null
+++ b/GApop/makefile.pd-msvc
@@ -0,0 +1,53 @@
+# makefile adapted from thomas grill's xsample makefile
+#
+# Makefile for MSVC++ 6
+#
+# usage:
+# to build run "make -f makefile.pd-msvc"
+#
+
+!include config-pd-msvc.txt
+
+# includes
+INCPATH=/I"$(MSVCPATH)\include" /I"$(PDPATH)\src" /I"$(FLEXTPATH)" /I"./headers/plugin_interface" /I"./headers/common" /I"/headers/server" /I"./headers/app" /I"./headers/lang
+LIBPATH=/LIBPATH:"$(MSVCPATH)\lib" /LIBPATH:"$(PDPATH)\bin" /LIBPATH:"$(FLEXTPATH)"
+LIBS=pd.lib pthreadVC.lib flext-pdwin.lib
+
+# compiler definitions and flags
+DEFS=/DFLEXT_SYS=2
+
+CFLAGS=/GR- /GX- /GD /G6 /Ox /EHsc /ML
+
+# the rest can stay untouched
+# ----------------------------------------------
+
+NAME=GApop
+
+!include make-files.txt
+
+
+all: $(OUTPATH) $(OUTPATH)\$(NAME).dll
+
+# remove build
+clean:
+ -del /q $(OUTPATH) > nul
+ -rmdir $(OUTPATH) > nul
+
+OBJS= $(SRCS:.cpp=.obj)
+
+$(OUTPATH):
+ -mkdir $(OUTPATH) > nul
+
+{$(SRCDIR)}.cpp{}.obj:
+ cl /c /LD $(CFLAGS) $(DEFS) $(INCPATH) $** /Fo$(OUTPATH)\$@
+
+$(OUTPATH)\$(NAME).dll: $(OBJS)
+ cd $(OUTPATH)
+ link /DLL /out:$(NAME).dll /INCREMENTAL:NO $** $(LIBS) $(LIBPATH)
+ @-del *.exp
+ @-del *.lib
+ cd ..
+!ifdef INSTPATH
+ @-if not exist $(INSTPATH) mkdir $(INSTPATH)
+ copy $@ $(INSTPATH) > nul
+!endif
diff --git a/GApop/pd/help-GApop.pd b/GApop/pd/help-GApop.pd
new file mode 100755
index 0000000..18b1526
--- /dev/null
+++ b/GApop/pd/help-GApop.pd
@@ -0,0 +1,173 @@
+#N canvas 319 0 1050 843 10;
+#N canvas 0 0 450 300 graph1 0;
+#X array pop1 100 float 1;
+#A 0 0.7173 0.4191 0.3337 0.5792 0.615 0.233 0.5085 0.2329 0.2695 0.4994
+0.4409 0.4816 0.2609 0.6508 0.6687 0.4443 0.6549 0.6947 0.2325 0.7254
+0.6687 0.4331 0.6746 0.3324 0.463 0.3028 0.3377 0.2766 0.3946 0.4865
+0.4048 0.3509 0.4751 0.4503 0.6866 0.6687 0.2866 0.3899 0.397 0.6973
+0.3522 0.5653 0.3529 0.3067 0.0877 0.296 0.5321 0.5064 0.408 0.2631
+0.6214 0.349 0.3362 0.2524 0.4922 0.1996 0.2766 0.5568 0.8308 0.6892
+0.2074 0.2048 0.6521 0.5131 0.5122 0.3661 0.1928 0.3226 0.2943 0.446
+0.6965 0.6668 0.5907 0.3637 0.6658 0.6942 0.191 0.4147 0.445 0.5536
+0.6667 0.2692 0.5879 0.5852 0.4976 0.7099 0.7257 0.6857 0.8582 0.419
+0.2759 0.624 0.6144 0.2375 0.2493 0.6749 0.6655 0.8358 0.7917 0.521
+;
+#X coords 0 1 99 0 200 140 1;
+#X restore 70 159 graph;
+#N canvas 0 0 450 300 graph1 0;
+#X array fit1 101 float 1;
+#A 0 0.0480164 0.0551593 0.0623023 0.0623023 0.0694452 0.0908741 0.0980171
+0.112303 0.119446 0.133732 0.140875 0.148018 0.155161 0.162304 0.183732
+0.183732 0.190875 0.198018 0.205161 0.212304 0.219447 0.233733 0.233733
+0.233733 0.240876 0.240876 0.255162 0.262305 0.283734 0.290877 0.305163
+0.319448 0.319448 0.333734 0.340877 0.34802 0.355163 0.376592 0.390878
+0.398021 0.405164 0.41945 0.426593 0.440879 0.455165 0.469451 0.476593
+0.483736 0.498022 0.505165 0.512308 0.526594 0.533737 0.54088 0.548023
+0.562309 0.569452 0.590881 0.598024 0.605167 0.626596 0.626596 0.633739
+0.648024 0.66231 0.66231 0.683739 0.683739 0.698025 0.705168 0.712311
+0.719454 0.740883 0.740883 0.740883 0.755169 0.755169 0.762312 0.762312
+0.776598 0.776598 0.783741 0.783741 0.798027 0.80517 0.812313 0.826599
+0.826599 0.833741 0.848027 0.848027 0.869456 0.869456 0.890885 0.898028
+0.905171 0.919457 0.9266 0.940886 0.948029 0.990887;
+#X coords 0 1 100 0 200 140 1;
+#X restore 427 223 graph;
+#X msg 600 772 getattributes;
+#X obj 958 754 print;
+#X msg 182 672 getmutrange;
+#X msg 301 647 mutprop 0.3;
+#X msg 300 672 getmutprop;
+#X msg 90 646 pairs 5;
+#X msg 89 671 getpairs;
+#X obj 883 727 GApop pop1;
+#X msg 598 631 cross;
+#X floatatom 883 769 5 0 0 0 - - -;
+#X floatatom 883 665 5 0 0 0 - - -;
+#X msg 680 285 getfitbuf;
+#X msg 61 380 getpopbuf;
+#X msg 600 746 help;
+#X msg 658 632 update;
+#X obj 898 699 r GAmessages;
+#X obj 679 311 s GAmessages;
+#X obj 18 13 cnv 15 130 30 empty empty GApop: 7 15 0 16 -217163 -262144
+0;
+#X text 152 15 Georg Holzmann <grh@gmx.at>;
+#X obj 61 405 s GAmessages;
+#X obj 22 103 cnv 15 30 30 empty empty 1 10 14 0 14 -233017 -1 0;
+#X text 60 105 you have to give in a population:;
+#X text 102 132 - values between 0 and 1;
+#X text 183 326 <- set population;
+#X msg 61 326 set pop1;
+#X msg 61 353 popbuf pop1;
+#X text 184 352 <- set population;
+#X text 183 381 <- get population;
+#X text 425 129 - values between 0 and 1;
+#X text 386 107 give in a fitness function:;
+#N canvas 627 403 307 135 init 0;
+#X msg 46 57 \; pop1 ylabel 107 0 0.5 1 \; fit1 ylabel 108 0 0.5 1
+;
+#X obj 46 27 loadbang;
+#X connect 1 0 0 0;
+#X restore 18 48 pd init;
+#X text 429 369 0;
+#X text 621 371 1;
+#X text 515 370 0.5;
+#X msg 680 258 fitbuf fit1;
+#X text 425 147 - size must be 101 \, because in this array you can
+draw the fitness of the values from pop1 \, for example if a value
+in pop1 is 0.34 \, than the fitness of this value is fit1(0.34*100)
+= fit1(34);
+#X text 784 257 <- set fitfunction;
+#X text 783 285 <- get fitfunction;
+#X text 57 465 set the other parameters:;
+#X text 90 487 - pairs: specifies have much new parameters are generated
+at crossover \, for example if pairs=2 that means that 2 pairs of parents
+(the fittest) generate 4 children and replace the worst fit parameters
+;
+#X obj 89 716 s GAmessages;
+#X msg 183 647 mutrange 0.2;
+#X text 88 550 - mutprop: after crossover mutation occurs. mutprop
+is the probability \, with wich one parameter will mutate;
+#X text 593 488 - cross: with this message you can make the crossover
+and mutation;
+#X text 595 527 - number in inlet0: gives out the parameters: for example
+if you give in 0 \, GApop puts out the value of the fittest parameters
+\, if you give in 1 \, the value of the next fit parameter \, ...;
+#X obj 598 664 s GAmessages;
+#X text 746 662 give in numbers:;
+#X obj 600 799 s GAmessages;
+#X text 619 719 Help:;
+#X text 755 768 get parameters:;
+#N canvas 250 214 851 496 demo 0;
+#X obj 36 40 inlet;
+#X text 32 17 toggle;
+#X obj 36 66 select 1;
+#X obj 36 240 s GAmessages;
+#X msg 37 117 popbuf pop1;
+#X msg 38 140 fitbuf fit1;
+#X msg 35 212 mutprop 0.3;
+#X msg 38 163 pairs 5;
+#X msg 423 177 cross;
+#X msg 423 233 update;
+#X obj 423 207 t b;
+#X msg 394 120 1;
+#X obj 422 151 metro 1000;
+#X obj 394 97 delay 100;
+#X msg 449 124 0;
+#X obj 383 273 s GAmessages;
+#X msg 37 188 mutrange 0.2;
+#X msg 185 168 \; pop1 const 0.07 \;;
+#X connect 0 0 2 0;
+#X connect 2 0 4 0;
+#X connect 2 0 5 0;
+#X connect 2 0 7 0;
+#X connect 2 0 16 0;
+#X connect 2 0 6 0;
+#X connect 2 0 13 0;
+#X connect 2 0 17 0;
+#X connect 2 1 14 0;
+#X connect 4 0 3 0;
+#X connect 5 0 3 0;
+#X connect 6 0 3 0;
+#X connect 7 0 3 0;
+#X connect 8 0 10 0;
+#X connect 8 0 15 0;
+#X connect 9 0 15 0;
+#X connect 10 0 9 0;
+#X connect 11 0 12 0;
+#X connect 12 0 8 0;
+#X connect 13 0 11 0;
+#X connect 14 0 12 0;
+#X connect 16 0 3 0;
+#X restore 547 48 pd demo;
+#X obj 547 15 tgl 30 0 empty empty empty 0 -6 0 8 -260818 -1 -1 0 1
+;
+#X text 424 23 demonstration ->;
+#X text 154 29 Vers 0.1 \, Feb 2004;
+#X obj 348 99 cnv 15 30 30 empty empty 2 10 14 0 14 -233017 -1 0;
+#X obj 18 457 cnv 15 30 30 empty empty 3 10 14 0 14 -233017 -1 0;
+#X text 85 592 - mutrange: the parameters will be changed randomly
+in this range (+/- mutrange) if it mutates;
+#X obj 526 450 cnv 15 30 30 empty empty 4 10 14 0 14 -233017 -1 0;
+#X text 566 457 get the data:;
+#X text 595 591 - update: updates the pop1 array (only to see the changes)
+;
+#X connect 2 0 49 0;
+#X connect 4 0 42 0;
+#X connect 5 0 42 0;
+#X connect 6 0 42 0;
+#X connect 7 0 42 0;
+#X connect 8 0 42 0;
+#X connect 9 0 11 0;
+#X connect 9 1 3 0;
+#X connect 10 0 47 0;
+#X connect 12 0 9 0;
+#X connect 13 0 18 0;
+#X connect 14 0 21 0;
+#X connect 15 0 49 0;
+#X connect 16 0 47 0;
+#X connect 17 0 9 0;
+#X connect 26 0 21 0;
+#X connect 27 0 21 0;
+#X connect 36 0 18 0;
+#X connect 43 0 42 0;
+#X connect 53 0 52 0;
diff --git a/GApop/readme.txt b/GApop/readme.txt
new file mode 100755
index 0000000..4f7be1a
--- /dev/null
+++ b/GApop/readme.txt
@@ -0,0 +1,18 @@
+GApop - genetic algorithm for PD and MAX/MSP Vers 0.1
+
+Copyright (c) Georg Holzmann <grh@mur.at>, 2004
+For information on usage and redistribution, and for a DISCLAIMER OF ALL
+WARRANTIES, see the file, "license.txt," in this distribution.
+
+more info: http://grh.mur.at/software/gapop.html
+
+----------------------------------------------------------------------------
+
+You will need the flext C++ layer for PD and Max/MSP externals to compile this.
+see http://www.parasitaere-kapazitaeten.net/ext
+
+----------------------------------------------------------------------------
+
+To compile the external edit the config-pd-*.txt file of your platform and the run build-pd-*.
+
+For suggestions, bugs, ... mail me: grh@mur.at \ No newline at end of file
diff --git a/GApop/src/GApop.cpp b/GApop/src/GApop.cpp
new file mode 100755
index 0000000..4552055
--- /dev/null
+++ b/GApop/src/GApop.cpp
@@ -0,0 +1,495 @@
+//*************************************************************************
+// GApop - external for PD and MAX/MSP
+//
+// This is a genetic algorithm, see the PD help-file
+// how to use it
+//
+// Copyright (c) 2004 Georg Holzmann <grh@gmx.at>
+// For information on usage and redistribution, and for a DISCLAIMER OF ALL
+// WARRANTIES, see the file, "license.txt," in this distribution.
+//
+// You'll need flext by Thomas Grill to compile this external
+//*************************************************************************
+
+
+
+// IMPORTANT: enable attribute processing (specify before inclusion of flext headers!)
+// For clarity, this is done here, but you'd better specify it as a compiler definition
+// FLEXT_ATTRIBUTES must be 0 or 1,
+#define FLEXT_ATTRIBUTES 1
+
+// includes
+#include <flext.h>
+#include <stdlib.h>
+#include <ctime>
+
+// check for appropriate flext version
+#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 400)
+#error You need at least flext version 0.4.0
+#endif
+
+
+// define the class that stands for a pd/Max object
+class GApop:
+ // inherit from basic flext class
+ public flext_base
+{
+ // obligatory flext header (class name,base class name) featuring a setup function
+ FLEXT_HEADER_S(GApop,flext_base,setup)
+
+public:
+ // constructor with a variable argument list
+ GApop(int argc,const t_atom *argv);
+
+protected:
+
+ // 2 Arrays are saved here:
+ // popbuf: the population itself
+ // fitbuf: the fitness function
+ const t_symbol *fitname, *popname;
+ buffer *fitbuf, *popbuf;
+ // size of the popbuf
+ int buffsize;
+ // the fitness order
+ int *tempfit;
+
+ // the other parameters:
+ // pairs = number of pairs at crossover
+ // mutprop = mutation probability
+ // mutrange = mutation range
+ int pairs;
+ float mutprop, mutrange;
+
+
+ // set new buffer for the population
+ void m_set(int argc,const t_atom *argv);
+
+ // get population buffer name
+ void mg_pop(AtomList &lst) const;
+ // set population buffer name
+ inline void ms_pop(const AtomList &lst) { m_set(lst.Count(),lst.Atoms()); }
+
+ // get fitness function buffer name
+ void mg_fit(AtomList &lst) const;
+ // set fitness function buffer name
+ inline void ms_fit(const AtomList &lst);
+
+
+ // make the fitscaling, crossover and mutation
+ void m_cross();
+
+ // takes the incomig ints and gives out the specific individuum:
+ // 0 ... fittest individuum
+ // 1 ... next individuum
+ // ...
+ void m_trigger(int i);
+
+ // cuts a number, if it's greater than 1 or smaller than 0
+ float cutse(float nu);
+
+ // get number of pairs for crossover
+ void mg_pairs(int &p) { p = pairs; }
+ // set number of pairs for crossover
+ void ms_pairs(int &p) { pairs = p; }
+
+ // get mutation porpability
+ void mg_mutprop(float &mp) { mp = mutprop; }
+ // set mutation porpability
+ void ms_mutprop(float &mp) { mutprop = cutse(mp); }
+
+ // get mutation range
+ void mg_mutrange(float &mp) { mp = mutrange; }
+ // set mutation range
+ void ms_mutrange(float &mp) { mutrange = cutse(mp); }
+
+
+ // update the array (set the actual frame length)
+ inline void ms_frames() { if(Checkpopbuf()) popbuf->Frames(buffsize); }
+
+ // check and eventually update fit buffer reference (return true if valid)
+ bool Checkfitbuf();
+ // check and eventually update pop buffer reference (return true if valid)
+ bool Checkpopbuf();
+
+ // gives out a random float in the given boundaries
+ float ZZ(float b1, float b2);
+
+ // override default flext help function
+ virtual void m_help();
+
+
+private:
+ static void setup(t_classid c);
+
+ FLEXT_CALLBACK_V(m_set) // wrapper for method m_set (with variable argument list)
+
+ FLEXT_CALLVAR_V(mg_pop,ms_pop) // wrappers for attribute getter/setter (with variable argument list)
+ FLEXT_CALLVAR_V(mg_fit,ms_fit) // wrappers for attribute getter/setter (with variable argument list)
+
+ // callback for method "m_cross" (with no argument):
+ FLEXT_CALLBACK(m_cross)
+
+ // callback for method "m_trigger" (with one int argument):
+ FLEXT_CALLBACK_I(m_trigger)
+
+ // the variables:
+ FLEXT_CALLVAR_I(mg_pairs,ms_pairs)
+ FLEXT_CALLVAR_F(mg_mutprop,ms_mutprop)
+ FLEXT_CALLVAR_F(mg_mutrange,ms_mutrange)
+
+ FLEXT_CALLBACK(ms_frames) // callback for attribute setter ms_frames
+};
+
+// instantiate the class
+FLEXT_NEW_V("GApop",GApop)
+
+
+// setup function of the GApop
+void GApop::setup(t_classid c)
+{
+ // register methods and attributes
+
+ FLEXT_CADDMETHOD_(c,0,"set",m_set); // register method "set" for inlet 0
+ FLEXT_CADDMETHOD_(c,0,"cross",m_cross); // register method "cross" for inlet 0
+ // register a method to the default inlet (0)
+ FLEXT_CADDMETHOD(c,0,m_trigger);
+
+ FLEXT_CADDATTR_VAR(c,"popbuf",mg_pop,ms_pop); // register attribute "popbuf"
+ FLEXT_CADDATTR_VAR(c,"fitbuf",mg_fit,ms_fit); // register attribute "fitbuf"
+
+ FLEXT_CADDATTR_VAR(c,"pairs",mg_pairs,ms_pairs); // register attribute for pairs
+ FLEXT_CADDATTR_VAR(c,"mutprop",mg_mutprop,ms_mutprop); // register attribute for mutprop
+ FLEXT_CADDATTR_VAR(c,"mutrange",mg_mutrange,ms_mutrange); // register attribute for mutrange
+
+ FLEXT_CADDMETHOD_(c,0,"update",ms_frames); // register method "update" for inlet 0
+
+ // write to the console:
+ post("\nGApop - by Georg Holzmann <grh@gmx.at>, 2004");
+ post("(send me a help - message !!!)");
+}
+
+
+void GApop::m_help()
+{
+ // post a help message
+ // thisName() returns a char * for the object name
+ post("\nGApop, Vers.0.0.1 - a genetic algorithm object");
+ post("compiled with flext on %s",__DATE__);
+ post("1 - set all parameters:");
+ post("popbuf contains the population (array with numbers");
+ post(" between 0 and 1, max size is 200)");
+ post("fitbuf contains the fitness function (numbers between");
+ post(" 0 and 1, size should be 101: 0 = fitness(0),");
+ post(" 1 = fitness(0.01), ..., 100 = fitness(1) )");
+ post("pairs number of pairs for the crossover");
+ post("mutprop mutation probability (between 0 and 1)");
+ post("mutrange mutation range in percent (between 0 and 1)");
+ post("2 - get the data:");
+ post("cross makes fitscaling, crossover and mutation");
+ post("numbers in inlet 0 get the values: 0 means the value");
+ post(" of the fittest, 1 the value of the next...");
+ post("have fun - Georg Holzmann <grh@gmx.at>\n");
+}
+
+
+// constructor of GApop
+GApop::GApop(int argc,const t_atom *argv)
+{
+ // reset random numbers
+ srand(static_cast<int>(time(NULL)));
+
+ // set the variables
+ fitbuf=NULL; fitname=NULL;
+ popbuf=NULL; popname=NULL;
+ tempfit=NULL;
+ buffsize=0;
+ pairs = 0;
+ mutprop = 0; mutrange = 0;
+
+
+ // define inlets:
+ // first inlet must always be of type anything (or signal for dsp objects)
+ AddInAnything("message inlet"); // add one inlet for any message
+
+ // peek outlet
+ AddOutFloat("parameter outlet");
+
+ // set buffer according to creation arguments
+ if(argc == 1 && IsSymbol(argv[0]))
+ { m_set(argc,argv); }
+}
+
+
+// gives out a random float in the given boundaries
+float GApop::ZZ(float b1, float b2)
+{
+ const int faktor = 10000;
+
+ int min, max;
+
+ if(b1<b2)
+ {
+ min = int(b1*faktor);
+ max = int(b2*faktor);
+ } else
+ {
+ max = int(b1*faktor);
+ min = int(b2*faktor);
+ }
+
+ return (float(min + rand()%(max-min+1))/faktor);
+}
+
+
+// check and eventually update pop buffer reference (return true if valid)
+bool GApop::Checkpopbuf()
+{
+ if(!popbuf || !popbuf->Valid()) {
+ post("%s (%s) - no valid population buffer defined",thisName(),GetString(thisTag()));
+ // return zero length
+ return false;
+ }
+ else {
+ if(popbuf->Update()) {
+ // buffer parameters have been updated
+ if(popbuf->Valid()) {
+ post("%s (%s) - updated population buffer reference",thisName(),GetString(thisTag()));
+ return true;
+ }
+ else {
+ post("%s (%s) - population buffer has become invalid",thisName(),GetString(thisTag()));
+ return false;
+ }
+ }
+ else
+ return true;
+ }
+}
+
+
+// cuts a number, if it's greater than 1 or smaller than 0
+float GApop::cutse(float nu)
+{
+ if(nu>1) { return 1;}
+ else
+ {
+ if(nu<0) { return 0;}
+ else
+ {
+ return nu;
+ }
+ }
+}
+
+
+// and now the same for the fitness buffer
+bool GApop::Checkfitbuf()
+{
+ if(!fitbuf || !fitbuf->Valid()) {
+ post("%s (%s) - no valid fitness buffer defined",thisName(),GetString(thisTag()));
+ // return zero length
+ return false;
+ }
+ else {
+ if(fitbuf->Update()) {
+ // buffer parameters have been updated
+ if(fitbuf->Valid()) {
+ post("%s (%s) - updated fitness buffer reference",thisName(),GetString(thisTag()));
+ return true;
+ }
+ else {
+ post("%s (%s) - fitness buffer has become invalid",thisName(),GetString(thisTag()));
+ return false;
+ }
+ }
+ else
+ return true;
+ }
+}
+
+
+// set new buffer for the population
+void GApop::m_set(int argc,const t_atom *argv)
+{
+ if(argc == 1 && IsSymbol(argv[0])) {
+ // one symbol given as argument
+
+ // clear existing buffer
+ if(popbuf) delete popbuf;
+ if(tempfit) delete tempfit;
+
+ // save buffer name
+ popname = GetSymbol(argv[0]);
+ // make new reference to system buffer object
+ popbuf = new buffer(popname);
+ buffsize = popbuf->Frames();
+
+ // make new tempfit buffer
+ tempfit = new int[buffsize];
+
+ if(!popbuf->Ok()) {
+ post("%s (%s) - warning: population buffer is currently not valid!",thisName(),GetString(thisTag()));
+ }
+ }
+ else {
+ // invalid argument list, leave buffer as is but issue error message to console
+ post("%s (%s) - message argument of popbuf must be a symbol",thisName(),GetString(thisTag()));
+ }
+}
+
+
+// get population buffer name
+void GApop::mg_pop(AtomList &lst) const
+{
+ if(popbuf) {
+ // buffer exists: return buffer name
+ lst(1); SetSymbol(lst[0],popname);
+ }
+ else
+ // no buffer: set empty list
+ lst(0);
+}
+
+
+// get fitness function buffer name
+void GApop::mg_fit(AtomList &lst) const
+{
+ if(fitbuf) {
+ // buffer exists: return buffer name
+ lst(1); SetSymbol(lst[0],fitname);
+ }
+ else
+ // no buffer: set empty list
+ lst(0);
+}
+
+// set fitness function buffer name
+void GApop::ms_fit(const AtomList &lst)
+{
+ if(lst.Count() == 1 && IsSymbol(*lst.Atoms())) {
+ // one symbol given as argument
+
+ // clear existing buffer
+ delete fitbuf;
+ // save buffer name
+ fitname = GetSymbol(lst[0]);
+ // make new reference to system buffer object
+ fitbuf = new buffer(fitname);
+
+ if(!fitbuf->Ok()) {
+ post("%s (%s) - warning: fitness buffer is currently not valid!",thisName(),GetString(thisTag()));
+ }
+ }
+ else {
+ // invalid argument list, leave buffer as is but issue error message to console
+ post("%s (%s) - message argument of fitbuf must be a symbol",thisName(),GetString(thisTag()));
+ }
+}
+
+
+// make the fitscaling, crossover and mutation
+void GApop::m_cross()
+{
+ if(Checkpopbuf() && Checkfitbuf() && pairs<(buffsize/2-1))
+ {
+
+
+ // 1. step:
+ // every parameter get's a fitness from the
+ // given fitness function
+ // this fitness is saved into the temporary array tempfit1[]
+
+ // make temporary array
+ float *tempfit1 = new float[200];
+
+ // write the fitness
+ for(int i=0; i < buffsize; i++)
+ {
+ tempfit1[i] = cutse(fitbuf->Data()[int(popbuf->Data()[i]*100+0.5)]);
+ }
+
+
+ // 2. step:
+ // now the fitness order of the parameters are written
+ // into the array tempfit[]
+
+ for(int j=0; j < buffsize; j++)
+ {
+ int fitti=0;
+ float fittw=0;
+
+ // get max and set it to 0
+ for(int k = 0; k < buffsize; k++)
+ {
+ if(fittw<tempfit1[k])
+ {
+ fittw = tempfit1[k];
+ fitti = k;
+ }
+ }
+
+ // write the order to the tempfit array
+ tempfit[j] = fitti;
+ tempfit1[fitti] = 0;
+ }
+
+
+ // 3. step:
+ // the crossover: every pair generates 2 children and replace the
+ // individuums with the lowest fitness
+ // the number of pairs are given (int pairs)
+
+ for(int ii=pairs; ii>0; ii--)
+ {
+ // the first children
+ popbuf->Data()[tempfit[buffsize-ii*2+1]] =
+ cutse(ZZ(popbuf->Data()[tempfit[ii*2-1]],popbuf->Data()[tempfit[ii*2-2]]));
+ // the second children
+ popbuf->Data()[tempfit[buffsize-ii*2]] =
+ cutse(ZZ(popbuf->Data()[tempfit[ii*2-1]],popbuf->Data()[tempfit[ii*2-2]]));
+ }
+
+
+ // 4. step:
+ // the last step is the mutation:
+ // made with the parameter mutation probability (float mutprop)
+ // and mutation range (float mutrange)
+
+ for(int jj=0; jj<buffsize; jj++)
+ {
+
+ if(rand()%101 < int(mutprop*100))
+ {
+ popbuf->Data()[jj] = cutse(popbuf->Data()[jj] + (ZZ(0,2*mutrange)-mutrange));
+ }
+ }
+
+ // delete the temporary array
+ delete []tempfit1;
+ }
+
+
+ else
+ {
+ // invalid buffers
+ post("GApop - entered buffers are invalid!");
+ }
+}
+
+
+// takes the incomig ints and gives out the specific individuum:
+// 0 ... fittest individuum
+// 1 ... next individuum
+// ...
+void GApop::m_trigger(int i)
+{
+ // if buffer is invalid bail out
+ if(!Checkpopbuf()) return;
+
+ // make the boundaries for i:
+ if(i<0) {i=0;}
+ if(i>200) {i=200;}
+
+ // correct syntax, output value
+ ToOutFloat(0,popbuf->Data()[tempfit[i]]);
+}