ANNOUNCE: A Simple Genetic Algorithm in NewLisp...

Q&A's, tips, howto's

ANNOUNCE: A Simple Genetic Algorithm in NewLisp...

Postby oofoe » Sat Sep 17, 2016 2:38 pm

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: 60
Joined: Wed Sep 28, 2005 7:13 pm

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

Postby oofoe » Sat Sep 17, 2016 4:12 pm

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.
oofoe
 
Posts: 60
Joined: Wed Sep 28, 2005 7:13 pm

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

Postby Lutz » Tue Sep 20, 2016 2:05 pm

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
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest