ANNOUNCE: A Simple Genetic Algorithm in NewLisp...

Q&A's, tips, howto's
Locked
oofoe
Posts: 61
Joined: Wed Sep 28, 2005 7:13 pm
Contact:

ANNOUNCE: A Simple Genetic Algorithm in NewLisp...

Post by oofoe »

Hi!

In my quest to construct a program to derive the question to the answer of Life, the Universe and Everything (which is, as any schoolchild knows, 42), I wrote a very simple genetic algorithm solver.

I don't mean simple as in "simple to use", I mean absolute braindead simple. By some definitions, this is not really a genetic algorithm because the "genome" is the same as the data being operated on (there is no "expression"), but it's a cute toy and somebody else might find it entertaining as well:

https://bitbucket.org/oofoe/ga/src/9523 ... at=default

I am currently hard at work on a new program which will use a genetic algorithm to do lossy image compression through vector shapes, just have to teach NewLisp about reading %.png files...
Testing can show the presence of bugs, but not their absence.

oofoe
Posts: 61
Joined: Wed Sep 28, 2005 7:13 pm
Contact:

Re: ANNOUNCE: A Simple Genetic Algorithm in NewLisp...

Post by oofoe »

Incidentally, here's how to determine if a file is a png image using the standard libpng library:

Code: Select all

;; C library functions.
(import "msvcrt.dll" "fopen")
(import "msvcrt.dll" "fread")

;; PNG library functions.
(import "libpng16-16.dll" "png_sig_cmp")

(define (pngfile? path)
  "( path -- f) Determines if path is a %.png file."

  (letn ((header "XXXXXXXX")
	 (fp (fopen path "rb")))
	(fread header 1 (length header) fp)
	(zero? (png_sig_cmp header 0 (length header)))))
Sorry, Windows only at this point. UNIX users please substitute library names as appropriate.
Testing can show the presence of bugs, but not their absence.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: ANNOUNCE: A Simple Genetic Algorithm in NewLisp...

Post by Lutz »

Genetic algorithms are great. You also might be interested in fuzzy logic. Similarly to genetic algorithms, fuzzy logic can solve mathematically complex problems in a simple way. This book uses newLISP for all examples:


A Practical Introduction to Fuzzy Logic using LISP
By Luis Argüelles Méndez (arguelles on this forum)

http://www.springer.com/us/book/9783319231853

Locked