Mercurial > pokemon-types
comparison org/lpsolve.org @ 20:47fa6dc56e30
remove incanter filth.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 10 Mar 2013 19:17:47 +0000 |
parents | 2bec94944460 |
children | f88b7d2c25d9 |
comparison
equal
deleted
inserted
replaced
19:a69ddac5657e | 20:47fa6dc56e30 |
---|---|
156 #+name: intro | 156 #+name: intro |
157 #+begin_src clojure :results silent | 157 #+begin_src clojure :results silent |
158 (ns pokemon.lpsolve | 158 (ns pokemon.lpsolve |
159 (:import lpsolve.LpSolve) | 159 (:import lpsolve.LpSolve) |
160 (:require pokemon.types) | 160 (:require pokemon.types) |
161 (:require incanter.core) | 161 ;;(:require incanter.core) |
162 (:require rlm.map-utils)) | 162 (:require rlm.map-utils)) |
163 #+end_src | 163 #+end_src |
164 | 164 |
165 The =lp_solve= Java interface is available from the same site as | 165 The =lp_solve= Java interface is available from the same site as |
166 =lp_solve= itself, http://lpsolve.sourceforge.net/ Using it is the | 166 =lp_solve= itself, http://lpsolve.sourceforge.net/ Using it is the |
559 | 559 |
560 (defn log-clamp-matrix [matrix] | 560 (defn log-clamp-matrix [matrix] |
561 ;; we have to clamp the Infinities to a more reasonable negative | 561 ;; we have to clamp the Infinities to a more reasonable negative |
562 ;; value because lp_solve does not play well with infinities in its | 562 ;; value because lp_solve does not play well with infinities in its |
563 ;; constraint matrix. | 563 ;; constraint matrix. |
564 (map (fn [row] (map #(if (= Double/NEGATIVE_INFINITY %) -1e3 %) row)) | 564 (map (fn [row] (map #(if (= Double/NEGATIVE_INFINITY %) -1e3 %) |
565 (incanter.core/log2 | 565 (map #(/ (Math/log %) (Math/log 2)) row))) |
566 (incanter.core/trans | 566 (apply mapv vector ;; transpose |
567 matrix)))) | 567 matrix))) |
568 | 568 |
569 ;; constraint matrices | 569 ;; constraint matrices |
570 (defn log-defense-matrix [] | 570 (defn log-defense-matrix [] |
571 (log-clamp-matrix | 571 (log-clamp-matrix |
572 (doall (map (pokemon.types/defense-strengths) | 572 (doall (map (pokemon.types/defense-strengths) |
573 (pokemon.types/type-names))))) | 573 (pokemon.types/type-names))))) |
574 | 574 |
575 (defn log-attack-matrix [] | 575 (defn log-attack-matrix [] |
576 (incanter.core/trans (log-defense-matrix))) | 576 (apply mapv vector (log-defense-matrix))) |
577 | 577 |
578 ;; target vectors | 578 ;; target vectors |
579 (defn all-resistant [] | 579 (defn all-resistant [] |
580 (doall (map (constantly -1) (pokemon.types/type-names)))) | 580 (doall (map (constantly -1) (pokemon.types/type-names)))) |
581 | 581 |