This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns mca.gillespie | |
(:require [clojure.contrib.generic.math-functions :as math])) | |
(defn choice [m] | |
(let [r (rand (apply + (vals m)))] | |
(loop [[[k w] & kws] (seq m) | |
sum 0] | |
(if (or (nil? kws) (< r (+ sum w))) k | |
(recur kws (+ sum w)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn get-molecule [state mol] | |
(get-in state [:mixture mol] 0)) | |
(defn get-activities [state] ;; FIXME this fn takes upto 80% of the time | |
(into {} (for [{:keys [lhs rate] :as r} (:rxns state)] | |
[r (apply * rate (for [[mol freq] lhs] | |
(* (get-molecule state mol) freq)))]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.Map as Map | |
import Random (randomRIO) | |
type Mol = String | |
type Mixture = Map.Map Mol Integer | |
type Rxn = (Mixture, (Mixture -> Mixture)) -- (Lhs, Action) | |
type State = (Double, Integer, Mixture) -- (Time, NumSteps, Mixture) | |
getActivities :: [Rxn] -> Mixture -> [Integer] | |
getActivities rxns mixture = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.Map as Map | |
type Mol = String | |
type Mixture = Map.Map Mol Integer | |
type Rxn = (Mixture, (Mixture -> Mixture), Double) | |
getActivities :: [Rxn] -> Mixture -> [Double] | |
getActivities rxns mixture = | |
let f acc mol sc = if sc == 1 -- sc is stoichiometric coefficient | |
then fromIntegral $ mixture Map.! mol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.Map as Map | |
import qualified Data.Set as Set | |
import Data.Maybe | |
import Data.List | |
import Random (randomRIO) | |
import qualified Data.Enumerator as E | |
import qualified Data.Enumerator.List as EL | |
type Mol = String | |
type Mixture = Map.Map Mol Integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.Map as Map | |
import qualified Data.Set as Set | |
type IntMap = Map.Map Int Int | |
type IntSet = Set.Set Int | |
extend :: IntMap -> IntSet -> IntMap -> Maybe (IntMap, IntSet) | |
extend inj codom map = Map.foldrWithKey f (Just (inj, codom)) map | |
where f :: Int -> Int -> Maybe (IntMap, IntSet) -> Maybe (IntMap, IntSet) | |
f i j (Just (inj, codom)) = if Set.member j codom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JOB "Main 1.kappa 10000 0 500 +RTS -hc -T" | |
DATE "Fri Mar 16 08:01 2012" | |
SAMPLE_UNIT "seconds" | |
VALUE_UNIT "bytes" | |
BEGIN_SAMPLE 0.00 | |
END_SAMPLE 0.00 | |
BEGIN_SAMPLE 0.09 | |
(898)CAF:nodeOfId 16 | |
(2523)findNewInjs.ccIdInjs/... 48 | |
(1943)infinity/add.(...)/ad... 16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JOB "Main 1.kappa 10000 0 500 +RTS -hc -T" | |
DATE "Fri Mar 16 08:13 2012" | |
SAMPLE_UNIT "seconds" | |
VALUE_UNIT "bytes" | |
BEGIN_SAMPLE 0.00 | |
END_SAMPLE 0.00 | |
BEGIN_SAMPLE 0.09 | |
(2524)create/findNewInjs.cc... 104 | |
(1740)evalMixture/evalObs.a... 192 | |
(2308)diff.addModifications... 64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import System.Process | |
import System.Environment (getArgs) | |
import Data.List (intercalate) | |
data Gender = Male | |
| Female | |
data Var = FirstValue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git main/main.ml main/main.ml | |
index fa98968..86c90ff 100644 | |
--- main/main.ml | |
+++ main/main.ml | |
@@ -37,6 +37,7 @@ let main = | |
("-load-sim", Arg.String (fun file -> Parameter.marshalizedInFile := file) , "load simulation package instead of kappa files") ; | |
("-make-sim", Arg.String (fun file -> Parameter.marshalizedOutFile := file) , "save kappa files as a simulation package") ; | |
("--implicit-signature", Arg.Unit (fun () -> Parameter.implicitSignature := true), "Program will guess agent signatures automatically") ; | |
+ ("--float-precision", Arg.Int (fun p -> Parameter.floatPrecision := Some p), "Use given precision to print floating point numbers (e.g. time)") ; | |
("-seed", Arg.Int (fun i -> Parameter.seedValue := Some i), "Seed for the random number generator") ; |