So I've put together a small genetic algorithm simulation that I've
written in Java which I have recently ported to Clojure.  While the
code looks sound from my perspective, yet I get the following
exception when I run my uberjar:

Exception in thread "main" java.lang.RuntimeException:
java.lang.ClassCastException: clojure.lang.Cons cannot be cast to
clojure.lang.Associative
        at clojure.lang.LazySeq.sval(LazySeq.java:47)
        at clojure.lang.LazySeq.seq(LazySeq.java:56)
        at clojure.lang.RT.seq(RT.java:450)
        at clojure.core$seq.invoke(core.clj:122)
        at clojure.core$r.invoke(core.clj:793)
        at clojure.core$into.invoke(core.clj:2615)
        at net.auxesia.population$evolve.invoke(population.clj:87)
        at net.auxesia.core$_main.doInvoke(core.clj:49)
        at clojure.lang.RestFn.invoke(RestFn.java:398)
        at clojure.lang.AFn.applyToHelper(AFn.java:159)
        at clojure.lang.RestFn.applyTo(RestFn.java:133)
        at net.auxesia.core.main(Unknown Source)
Caused by: java.lang.ClassCastException: clojure.lang.Cons cannot be
cast to clojure.lang.Associative
        at clojure.lang.RT.assoc(RT.java:664)
        at clojure.core$assoc.invoke(core.clj:170)
        at net.auxesia.chromosome$mutate.invoke(chromosome.clj:58)
        at net.auxesia.population$evolve
$r_mutate__29.invoke(population.clj:76)
        at net.auxesia.population$evolve$fn__33.invoke(population.clj:
87)
        at clojure.core$map$fn__3695.invoke(core.clj:2094)
        at clojure.lang.LazySeq.sval(LazySeq.java:42)
        ... 11 more

The source can be found at:

https://github.com/jsvazic/GAHelloWorld/tree/master/clojure

I've narrowed it down to the call:

    (map #(r-mutate %) (chromosome/mate c1 c2))

which essentially takes two "chromosomes" and generates two new ones,
returning them in a vector.  Each element of the vector is a map, and
the r-mutate function simply updates one of the KVPs for the given map
(randomly, depending on a threshold being hit), and returns a new
"chromosome".  If the threshold isn't hit, it simply returns the same
chromosome it was provided.  Any ideas from anyone?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to