feat: greedy simulation
This commit is contained in:
parent
c867859cce
commit
b037dacccf
6 changed files with 164 additions and 17 deletions
|
|
@ -1,19 +1,22 @@
|
|||
|
||||
open Hsim
|
||||
open Examples
|
||||
open Common
|
||||
|
||||
let sample = ref 10
|
||||
let stop = ref 30.0
|
||||
let debug = ref false
|
||||
let greedy = ref false
|
||||
|
||||
let doc_sample = "n \tSample count [10]"
|
||||
let doc_stop = "n \tStop time [10.0]"
|
||||
let doc_debug = "\tPrint debug information"
|
||||
let doc_greedy = "\tUse greedy simulation"
|
||||
|
||||
let opts = [
|
||||
"-sample", Arg.Set_int sample, doc_sample;
|
||||
"-stop", Arg.Set_float stop, doc_stop;
|
||||
"-debug", Arg.Set debug, doc_debug
|
||||
"-debug", Arg.Set Debug.debug, doc_debug;
|
||||
"-greedy", Arg.Set greedy, doc_greedy;
|
||||
]
|
||||
|
||||
let errmsg = "Usage: " ^ Sys.executable_name ^ " [OPTIONS]\nOptions are:"
|
||||
|
|
@ -27,6 +30,11 @@ let () =
|
|||
let zsolver = StatefulZ.Functional.zsolve in
|
||||
let solver = Solver.solver_c csolver zsolver in
|
||||
let model = Ball.bouncing_ball () in
|
||||
let open Sim.LazySim(State.FunctionalSimState) in
|
||||
run_until model (Solver.solver_from_c solver) !stop (Output.print !sample)
|
||||
if !greedy then
|
||||
let open Sim.GreedySim(State.FunctionalSimState) in
|
||||
run_until model solver !stop (Output.print !sample)
|
||||
else
|
||||
let open Sim.LazySim(State.FunctionalSimState) in
|
||||
run_until model (Solver.solver_from_c solver) !stop (Output.print !sample)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue