feat: correct greedy/lazy and inplace/functional, split into multiple inputs
This commit is contained in:
parent
b037dacccf
commit
5bce9e5b01
12 changed files with 117 additions and 65 deletions
|
|
@ -3,20 +3,29 @@ open Hsim
|
|||
open Examples
|
||||
open Common
|
||||
|
||||
let sample = ref 10
|
||||
let stop = ref 30.0
|
||||
let greedy = ref false
|
||||
let sample = ref 10
|
||||
let stop = ref 30.0
|
||||
let greedy = ref false
|
||||
let inplace = ref false
|
||||
let steps = ref 1
|
||||
|
||||
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 gt0i v i = v := if i <= 0 then 1 else i
|
||||
let gt0f v f = v := if f <= 0.0 then 1.0 else f
|
||||
|
||||
let doc_sample = "n \tSample count (default=10)"
|
||||
let doc_stop = "n \tStop time (default=10.0)"
|
||||
let doc_debug = "\tPrint debug information"
|
||||
let doc_greedy = "\tUse greedy simulation"
|
||||
let doc_inplace = "\tUse greedy simulation"
|
||||
let doc_steps = "n \tSplit simulation into [n] steps (default=1)"
|
||||
|
||||
let opts = [
|
||||
"-sample", Arg.Set_int sample, doc_sample;
|
||||
"-stop", Arg.Set_float stop, doc_stop;
|
||||
"-debug", Arg.Set Debug.debug, doc_debug;
|
||||
"-greedy", Arg.Set greedy, doc_greedy;
|
||||
"-sample", Arg.Int (gt0i sample), doc_sample;
|
||||
"-stop", Arg.Float (gt0f stop), doc_stop;
|
||||
"-debug", Arg.Set Debug.debug, doc_debug;
|
||||
"-greedy", Arg.Set greedy, doc_greedy;
|
||||
"-inplace", Arg.Set inplace, doc_inplace;
|
||||
"-steps", Arg.Int (gt0i steps), doc_steps;
|
||||
]
|
||||
|
||||
let errmsg = "Usage: " ^ Sys.executable_name ^ " [OPTIONS]\nOptions are:"
|
||||
|
|
@ -30,11 +39,19 @@ let () =
|
|||
let zsolver = StatefulZ.Functional.zsolve in
|
||||
let solver = Solver.solver_c csolver zsolver in
|
||||
let model = Ball.bouncing_ball () in
|
||||
if !greedy then
|
||||
let open Sim.GreedySim(State.FunctionalSimState) in
|
||||
run_until model solver !stop (Output.print !sample)
|
||||
if !inplace then
|
||||
let module S = State.InPlaceSimState in
|
||||
if !greedy then
|
||||
let open Sim.GreedySim(S) in
|
||||
run_until_multiple model solver !stop !steps (Output.print !sample)
|
||||
else
|
||||
let open Sim.LazySim(S) in
|
||||
run_until_multiple model (Solver.solver_from_c solver) !stop !steps (Output.print !sample)
|
||||
else
|
||||
let open Sim.LazySim(State.FunctionalSimState) in
|
||||
run_until model (Solver.solver_from_c solver) !stop (Output.print !sample)
|
||||
|
||||
|
||||
let module S = State.FunctionalSimState in
|
||||
if !greedy then
|
||||
let open Sim.GreedySim(S) in
|
||||
run_until_multiple model solver !stop !steps (Output.print !sample)
|
||||
else
|
||||
let open Sim.LazySim(S) in
|
||||
run_until_multiple model (Solver.solver_from_c solver) !stop !steps (Output.print !sample)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue