Skip to content

Commit

Permalink
perturbation -> intervention
Browse files Browse the repository at this point in the history
  • Loading branch information
pirbo committed Dec 3, 2017
1 parent 1e55b86 commit c3be8ed
Show file tree
Hide file tree
Showing 136 changed files with 280 additions and 2,121 deletions.
16 changes: 9 additions & 7 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,13 @@ is:
[LHS] <-> [RHS] @ [binary rate] {unary rate}, [reverse rate]
```

### every modification (perturbation action) ends by a semicolon
### Kappa speaks about intervention instead of perturbation

Perturbations used to take a semi-colon separated list of modification
### every modification (intervention action) ends by a semicolon

Interventions used to take a semi-colon separated list of modification
as body. Now, every modification ends by a semi-colon. Said
diferrently even the last (or only) modification of a perturbation
diferrently even the last (or only) modification of a intervention
ends by `;`.

```
Expand All @@ -134,7 +136,7 @@ ends by `;`.
$ADD 10 A();
```

### Repetitive perturbation syntax has changed
### Repetitive intervention syntax has changed
Usage is now if _precondition_ do _modification(s)_ and repeat as long
as _condition_.

Expand Down Expand Up @@ -225,9 +227,9 @@ filename.

## Ctrl-c does not kill the simulator

Ctrl-c now pauses the simulation and launches a toplevel environment in
which you can do modifications and perturbations interactively, and
then (optionally) continue the simulation.
Ctrl-c now pauses the simulation and launches a toplevel environment
in which you can do modifications interactively, and then (optionally)
continue the simulation.

You can use `-mode batch` to get a Ctrl-c that does kill the simulator
(and more generally to get a KaSim that never asks questions and assumes
Expand Down
4 changes: 2 additions & 2 deletions api/api.mli
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class type manager_simulation = object

method simulation_pause : unit result Lwt.t

method simulation_perturbation :
Api_types_t.simulation_perturbation -> string result Lwt.t
method simulation_intervention :
Api_types_t.simulation_intervention -> string result Lwt.t

method simulation_continue : string -> unit result Lwt.t

Expand Down
2 changes: 1 addition & 1 deletion api/api_types.atd
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type simulation_parameter = {
store_trace : bool ;
} <ocaml field_prefix="simulation_">

type simulation_perturbation = { perturbation_code : string }
type simulation_intervention = { intervention_code : string }

type plot_limit = { plot_limit_offset <json name="offset"> : int nullable ;
plot_limit_points <json name="nb_points"> : int nullable ; }
Expand Down
8 changes: 4 additions & 4 deletions api/kappa_facade.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ let msg_process_not_paused =
"process not paused"
let msg_observables_less_than_zero =
"Plot observables must be greater than zero"
let msg_missing_perturbation_context =
"Invalid runtime state missing missing perturbation context"
let msg_missing_intervention_context =
"Invalid runtime state: missing intervention context"

(** System process
Expand Down Expand Up @@ -473,11 +473,11 @@ let stop
let perturbation
~(system_process : system_process)
~(t : t)
~(perturbation:Api_types_t.simulation_perturbation)
~(perturbation:Api_types_t.simulation_intervention)
: (string, Api_types_t.errors) Result.result Lwt.t =
let () = ignore(system_process) in
let lexbuf =
Lexing.from_string perturbation.Api_types_t.perturbation_code
Lexing.from_string perturbation.Api_types_t.intervention_code
in
Lwt.catch
(fun () ->
Expand Down
20 changes: 10 additions & 10 deletions api/kappa_facade.mli
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,39 @@ val parse :
system_process:system_process ->
kappa_files:Api_types_t.file list ->
overwrites:(string * Nbr.t) list ->
(t, Api_types_j.errors) Result.result Lwt.t
(t, Api_types_t.errors) Result.result Lwt.t

val start :
system_process:system_process ->
parameter:Api_types_j.simulation_parameter ->
parameter:Api_types_t.simulation_parameter ->
t:t ->
(unit, Api_types_j.errors) Result.result Lwt.t
(unit, Api_types_t.errors) Result.result Lwt.t

val pause :
system_process:system_process ->
t:t -> (unit, Api_types_j.errors) Result.result Lwt.t
t:t -> (unit, Api_types_t.errors) Result.result Lwt.t

val stop :
system_process:system_process ->
t:t -> (unit, Api_types_j.errors) Result.result Lwt.t
t:t -> (unit, Api_types_t.errors) Result.result Lwt.t

val perturbation :
system_process:system_process ->
t:t ->
perturbation:Api_types_j.simulation_perturbation ->
(string, Api_types_j.errors) Result.result Lwt.t
perturbation:Api_types_t.simulation_intervention ->
(string, Api_types_t.errors) Result.result Lwt.t

val continue :
system_process:system_process -> t:t -> pause_condition:string ->
(unit, Api_types_j.errors) Result.result Lwt.t
(unit, Api_types_t.errors) Result.result Lwt.t

val progress :
system_process:system_process -> t:t ->
(Api_types_t.simulation_progress, Api_types_j.errors) Result.result Lwt.t
(Api_types_t.simulation_progress, Api_types_t.errors) Result.result Lwt.t

val outputs :
system_process:system_process -> t:t ->
(Api_data.simulation_detail_output, Api_types_j.errors) Result.result Lwt.t
(Api_data.simulation_detail_output, Api_types_t.errors) Result.result Lwt.t

val efficiency : t -> Counter.Efficiency.t

Expand Down
4 changes: 2 additions & 2 deletions api/manager_simulation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ class manager_simulation
)
)

method simulation_perturbation
(simulation_perturbation : Api_types_j.simulation_perturbation) :
method simulation_intervention
(simulation_perturbation : Api_types_j.simulation_intervention) :
string Api.result Lwt.t =
Model_storage.bind_simulation
project
Expand Down
14 changes: 7 additions & 7 deletions api/mpi_api.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ let on_message
| `SimulationPause ->
manager#simulation_pause >>=
(handler (fun () -> `SimulationPause))
| `SimulationPerturbation simulation_perturbation ->
(manager#simulation_perturbation simulation_perturbation) >>=
(handler (fun s -> `SimulationPerturbation s))
| `SimulationIntervention simulation_intervention ->
(manager#simulation_intervention simulation_intervention) >>=
(handler (fun s -> `SimulationIntervention s))
| `SimulationStart simulation_parameter ->
(manager#simulation_start simulation_parameter) >>=
(handler (fun result -> `SimulationStart result))
Expand Down Expand Up @@ -368,13 +368,13 @@ class virtual manager_base () : manager_base_type =
(Api_common.result_error_exception
(BadResponse response)))

method simulation_perturbation
(simulation_perturbation : Api_types_j.simulation_perturbation) :
method simulation_intervention
(simulation_intervention : Api_types_j.simulation_intervention) :
string Api.result Lwt.t =
self#message (`SimulationPerturbation simulation_perturbation) >>=
self#message (`SimulationIntervention simulation_intervention) >>=
Api_common.result_bind_lwt
~ok:(function
| `SimulationPerturbation s ->
| `SimulationIntervention s ->
Lwt.return (Api_common.result_ok s)
| response ->
Lwt.return
Expand Down
6 changes: 3 additions & 3 deletions api/mpi_message.atd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type project_parse <ocaml from="Api_types"> = abstract
type project_parameter <ocaml from="Api_types"> = abstract

type simulation_parameter <ocaml from="Api_types"> = abstract
type simulation_perturbation <ocaml from="Api_types"> = abstract
type simulation_intervention <ocaml from="Api_types"> = abstract
type simulation_info <ocaml from="Api_types"> = abstract
type simulation_efficiency <ocaml module="Counter.Efficiency" t="t"> = abstract
type file_line <ocaml from="Api_types"> = abstract
Expand Down Expand Up @@ -70,7 +70,7 @@ type request = [
| SimulationTrace
| SimulationParameter
| SimulationPause
| SimulationPerturbation of simulation_perturbation
| SimulationIntervention of simulation_intervention
| SimulationStart of simulation_parameter
]

Expand Down Expand Up @@ -104,7 +104,7 @@ type response_content = [
| SimulationContinue
| SimulationDelete
| SimulationPause
| SimulationPerturbation of string
| SimulationIntervention of string
| SimulationStart of simulation_artifact
]

Expand Down
8 changes: 4 additions & 4 deletions dataStructures/operator.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type bin_bool_op = AND | OR
type un_bool_op = NOT
type compare_op = GREATER | SMALLER | EQUAL | DIFF

type rev_dep = ALG of int | RULE of int | PERT of int
type rev_dep = ALG of int | RULE of int | MODIF of int

let bin_alg_op_to_string = function
| MULT -> "*"
Expand Down Expand Up @@ -134,17 +134,17 @@ let print_rev_dep f = function
| ALG id ->
Format.fprintf f "algebraic variable [%i]" id
(*"variable '%a'" (Model.print_alg env) id*)
| PERT id -> Format.fprintf f "perturbation [%i]" id
| MODIF id -> Format.fprintf f "intervention [%i]" id

let rev_dep_to_yojson = function
| RULE id -> `List [ `String "RULE"; `Int id ]
| ALG id -> `List [ `String "ALG"; `Int id ]
| PERT id -> `List [ `String "PERT"; `Int id ]
| MODIF id -> `List [ `String "MODIF"; `Int id ]

let rev_dep_of_yojson = function
| `List [ `String "RULE"; `Int id ] -> RULE id
| `List [ `String "ALG"; `Int id ] -> ALG id
| `List [ `String "PERT"; `Int id ] -> PERT id
| `List [ `String "MODIF"; `Int id ] -> MODIF id
| x -> raise (Yojson.Basic.Util.Type_error ("Uncorrect rev_dep",x))

module DepSetMap = SetMap.Make (struct type t = rev_dep
Expand Down
2 changes: 1 addition & 1 deletion dataStructures/operator.mli
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ val compare_op_of_json : Yojson.Basic.json -> compare_op

(** {6 Dependencies management} *)

type rev_dep = ALG of int | RULE of int | PERT of int
type rev_dep = ALG of int | RULE of int | MODIF of int
module DepSet : SetMap.Set with type elt = rev_dep
val print_rev_dep : Format.formatter -> rev_dep -> unit
val rev_dep_to_yojson : rev_dep -> Yojson.Basic.json
Expand Down
10 changes: 5 additions & 5 deletions grammar/eval.ml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ let effects_of_modif
| _ ->
raise
(ExceptionDefn.Malformed_Decl
("Ambiguous rule in perturbation is impossible",pos)) in
("Ambiguous rule in modifition is impossible",pos)) in
(domain'',
(Primitives.ITER_RULE (alg_pos, elem_rule))::rev_effects)
| UPDATE ((i, _), alg_expr) ->
Expand Down Expand Up @@ -316,9 +316,9 @@ let effects_of_modifs
domain',List.rev rev_effects

let compile_modifications_no_track =
effects_of_modifs [] [] (Operator.PERT (-1))
effects_of_modifs [] [] (Operator.MODIF (-1))

(* perturbations without pre and post, but with alarm are not applied
(* interventions without pre and post, but with alarm are not applied
at initialisation *)
let pert_not_init = function
| (Some _, None, None) ->
Expand All @@ -343,7 +343,7 @@ let pert_of_result
raise (ExceptionDefn.Malformed_Decl
("alarm has to be strictly greater than 0.0", pos)) else ()
| None -> () in
let origin = Operator.PERT p_id in
let origin = Operator.MODIF p_id in
let pre_expr' = pert_not_init (alarm,pre_expr,opt_post) in
let (domain',pre) =
compile_bool ?bwd_bisim ~compileModeOn ~origin contact_map domain pre_expr' in
Expand Down Expand Up @@ -537,7 +537,7 @@ let compile ~outputs ~pause ~return ~max_sharing ?bwd_bisim ~compileModeOn ?over
let rule_nd = Array.of_list compiled_rules in

pause @@ fun () ->
outputs (Data.Log "\t -perturbations");
outputs (Data.Log "\t -interventions");
let (preenv,alg_deps'',pert,has_tracking) =
pert_of_result
result.variables result.rules alg_deps' ?bwd_bisim ~compileModeOn
Expand Down
4 changes: 2 additions & 2 deletions grammar/kparser4.mly
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ effect:
pend,p) }
| INTRO annot error
{ raise (ExceptionDefn.Syntax_Error
(add_pos 3 "Malformed perturbation instruction, I was expecting \
(add_pos 3 "Malformed intervention instruction, I was expecting \
'$ADD alg_expression kappa_expression'")) }
| DELETE annot alg_expr pattern
{ let (m,pend,p) = $4 in
Expand All @@ -581,7 +581,7 @@ effect:
pend,p) }
| DELETE annot error
{ raise (ExceptionDefn.Syntax_Error
(add_pos 3 "Malformed perturbation instruction, I was \
(add_pos 3 "Malformed intervention instruction, I was \
expecting '$DEL alg_expression kappa_expression'")) }
| SNAPSHOT print_expr { let (s,pend,p) = $2 in (Ast.SNAPSHOT s,pend,p) }
| STOP print_expr { let (s,pend,p) = $2 in (Ast.STOP s,pend,p) }
Expand Down
2 changes: 1 addition & 1 deletion grammar/snip.ml
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ let rec complete_with_creation
(Primitives.Transformation.Agent place::added) links_transf actions [] 0

let incr_origin = function
| ( Operator.ALG _ | Operator.PERT _ as x) -> x
| ( Operator.ALG _ | Operator.MODIF _ as x) -> x
| Operator.RULE i -> Operator.RULE (succ i)

let connected_components_of_mixture created mix (env,origin) =
Expand Down
6 changes: 3 additions & 3 deletions js/panel_settings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module FormPerturbation : Ui_common.Div = struct
Html.button
~a:[ Html.a_button_type `Submit
; Html.a_class ["btn"; "btn-default" ] ]
[ Html.cdata "perturbation" ]
[ Html.cdata "intervention" ]
let form = Html.form ~a:
[Tyxml_js.R.Html.a_class
(visible_on_states
Expand All @@ -56,13 +56,13 @@ module FormPerturbation : Ui_common.Div = struct
(fun _ ->
let model_perturbation : string = Js.to_string input_dom##.value in
let () =
State_perturbation.set_model_perturbation model_perturbation in
State_perturbation.set_model_intervention model_perturbation in
Js._true)
in

let () = form_dom##.onsubmit :=
Dom.handler (fun _ ->
let () = Panel_settings_controller.perturb_simulation () in
let () = Panel_settings_controller.intervene_simulation () in
Js._false) in
let () = input_dom##.onchange := Dom.handler handler in
()
Expand Down
6 changes: 3 additions & 3 deletions js/panel_settings_controller.ml
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ let start_simulation () =
>>= (fun _ -> Lwt.return_unit)
)

let perturb_simulation () =
let intervene_simulation () =
Common.async
__LOC__
(fun () ->
let model_perturbation =
React.S.value State_perturbation.model_perturbation in
React.S.value State_perturbation.model_intervention in
State_error.wrap
__LOC__ (State_simulation.perturb_simulation model_perturbation) >>=
__LOC__ (State_simulation.intervene_simulation model_perturbation) >>=
Api_common.result_map
~ok:(fun _ message_text ->
let () = State_error.add_error __LOC__ [{
Expand Down
2 changes: 1 addition & 1 deletion js/panel_settings_controller.mli
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ val continue_simulation : unit -> unit
val pause_simulation : unit -> unit
val stop_simulation : unit -> unit
val start_simulation : unit -> unit
val perturb_simulation : unit -> unit
val intervene_simulation : unit -> unit
val simulation_trace : unit -> unit
val focus_range : Api_types_j.range -> unit
10 changes: 5 additions & 5 deletions js/rest_api.ml
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,18 @@ class manager
(fun result ->
(`SimulationParameter
(Mpi_message_j.simulation_parameter_of_string result)))
| `SimulationPerturbation simulation_perturbation ->
| `SimulationIntervention simulation_intervention ->
send
?timeout
(Format.sprintf
"%s/v2/projects/%s/simulation/perturbation"
"%s/v2/projects/%s/simulation/intervention"
url
project_id)
`PUT
~data:(Api_types_j.string_of_simulation_perturbation
simulation_perturbation)
~data:(Api_types_j.string_of_simulation_intervention
simulation_intervention)
(fun result ->
`SimulationPerturbation
`SimulationIntervention
(Yojson.Safe.read_string
(Yojson.Safe.init_lexer ()) (Lexing.from_string result)))
| `SimulationStart simulation_parameter ->
Expand Down
2 changes: 1 addition & 1 deletion js/state_perturbation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
(* |_|\_\ * GNU Lesser General Public License Version 3 *)
(******************************************************************************)

let model_perturbation, set_model_perturbation = React.S.create ""
let model_intervention, set_model_intervention = React.S.create ""
4 changes: 2 additions & 2 deletions js/state_perturbation.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
(* | . \ * This file is distributed under the terms of the *)
(* |_|\_\ * GNU Lesser General Public License Version 3 *)
(******************************************************************************)
val model_perturbation : string React.signal
val set_model_perturbation : ?step:React.step -> string -> unit
val model_intervention : string React.signal
val set_model_intervention : ?step:React.step -> string -> unit
Loading

0 comments on commit c3be8ed

Please sign in to comment.