Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing issue #65

  • Loading branch information...
commit 5b9800c616a04f90352be43d5f7c453f0db9d0a6 1 parent 3cb18ee
Krivine authored
Showing with 25 additions and 6 deletions.
  1. +13 −1 dataStructures/mods.ml
  2. +2 −2 main/main.ml
  3. +10 −3 simulation/state.ml
View
14 dataStructures/mods.ml
@@ -99,7 +99,19 @@ module Num =
match n with
| F x -> (int_of_float x)
| I x -> x
- | I64 x -> invalid_arg "Cannot convert a 64 bit integer into a 32 bit one"
+ | I64 x -> Int64.to_int x (*Might exceed thebiggest 32 bits integer*)
+
+ let is_zero n =
+ match n with
+ | F x -> x = 0.
+ | I64 x -> x = Int64.zero
+ | I x -> x = 0
+
+ let to_string n =
+ match n with
+ | F x -> Printf.sprintf "%E" x
+ | I64 x -> Printf.sprintf "%Ld" x
+ | I x -> Printf.sprintf "%d" x
end
View
4 main/main.ml
@@ -3,7 +3,7 @@ open Mods
open State
open Random_tree
-let version = "3.1-0511 12"
+let version = "3.1-191112"
let usage_msg = "KaSim "^version^": \n"^"Usage is KaSim -i input_file [-e events | -t time] [-p points] [-o output_file]\n"
let version_msg = "Kappa Simulator: "^version^"\n"
@@ -17,7 +17,7 @@ let close_desc opt_env =
let main =
let options = [
- ("--version", Arg.Unit (fun () -> print_string (version_msg^"\n") ; flush stdout ; exit 0), "display kaSim version");
+ ("--version", Arg.Unit (fun () -> print_string (version_msg^"\n") ; flush stdout ; exit 0), "display KaSim version");
("-i", Arg.String (fun fic -> Parameter.inputKappaFileNames:= fic:: (!Parameter.inputKappaFileNames)),
"name of a kappa file to use as input (can be used multiple times for multiple input files)");
("-e", Arg.Int (fun i -> if i < 0 then Parameter.maxEventValue := None else Parameter.maxTimeValue:= None ; Parameter.maxEventValue := Some i) ,
View
13 simulation/state.ml
@@ -202,7 +202,9 @@ let eval_activity ?using rule state counter env =
(match k_def with
| Dynamics.CONST f ->
let n = (match using with None -> instance_number mix_id state env | Some x -> Num.I x) in
- (Num.mult f n)
+ if Num.is_zero n then (Num.I 0)
+ else
+ (Num.mult f n) (*Issue #65*)
| Dynamics.VAR k_fun ->
let act_of_id id = instance_number id state env
and v_of_var id = value state id counter env
@@ -215,7 +217,10 @@ let eval_activity ?using rule state counter env =
(Counter.event counter) (Counter.null_event counter) (Sys.time()) v_of_token
in
let n = (match using with None -> instance_number mix_id state env | Some x -> Num.I x) in
- Num.mult k n
+ if Num.is_zero n then (Num.I 0)
+ else
+ Num.mult k n
+
)
in
(*overestimated activity of unary instances of the rule*)
@@ -238,7 +243,9 @@ let eval_activity ?using rule state counter env =
let k = k_fun act_of_id v_of_var (Counter.time counter) (Counter.event counter) (Counter.null_event counter) (Sys.time()) v_of_token
in
let n = nl_instance_number mix_id state env in
- Num.mult k n
+ if Num.is_zero n then (Num.I 0)
+ else
+ Num.mult k n
end
in
(a_2,a_1)
Please sign in to comment.
Something went wrong with that request. Please try again.