Skip to content

Commit

Permalink
Done: add proper default value to counters, to do: check that is solv…
Browse files Browse the repository at this point in the history
…es: #685 and #687; also check json export of stories
  • Loading branch information
Jérôme FERET authored and antoinepouille committed Mar 28, 2024
1 parent b19d43d commit f5ece1e
Show file tree
Hide file tree
Showing 28 changed files with 672 additions and 247 deletions.
27 changes: 18 additions & 9 deletions core/KaSa_rep/frontend/ckappa_sig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@ type mixture =
| PLUS of c_agent_id * agent * mixture
| EMPTY_MIX

and agent = {
and 'counter parametric_agent = {
agent_name: string;
ag_intf: interface;
ag_intf: 'counter interface;
agent_name_pos: position; (*; ag_pos:position*)
}

and interface =
and agent = counter parametric_agent
and agent_sig = counter_sig parametric_agent
and 'counter interface =
| EMPTY_INTF
| PORT_SEP of port * interface
| COUNTER_SEP of counter * interface
| PORT_SEP of port * 'counter interface
| COUNTER_SEP of 'counter * 'counter interface

and port = {
port_name: string;
Expand All @@ -63,7 +65,14 @@ and counter = {
counter_test: counter_test option;
counter_delta: int option;
}

and counter_sig =
{
counter_sig_name: string;
counter_sig_default: int;
counter_sig_min: int option option;
counter_sig_max: int option option;
counter_visible: bool;
}
and counter_test = CEQ of int | CGTE of int | CVAR of string | UNKNOWN
and internal = string option list

Expand Down Expand Up @@ -112,8 +121,8 @@ type ('pattern, 'rule) modif_expr =

type 'pattern variable = ('pattern, string) Ast.variable_def

type ('agent, 'pattern, 'mixture, 'rule) compil =
('agent, 'pattern, 'mixture, string, 'rule) Ast.compil
type ('agent, 'agent_sig, 'pattern, 'mixture, 'rule) compil =
('agent, 'agent_sig, 'pattern, 'mixture, string, 'rule) Ast.compil

type ('a, 'b, 'c) site_type = Internal of 'a | Binding of 'b | Counter of 'c
type site = (site_name, site_name, site_name) site_type
Expand Down Expand Up @@ -869,7 +878,7 @@ type enriched_init = {
type c_compil = {
c_variables: c_variable Int_storage.Nearly_inf_Imperatif.t;
(*pattern declaration for reusing as variable in perturbations or kinetic rate*)
c_signatures: (agent * position) Int_storage.Nearly_inf_Imperatif.t;
c_signatures: (agent_sig * position) Int_storage.Nearly_inf_Imperatif.t;
(*agent signature declaration*)
c_rules: enriched_rule Int_storage.Nearly_inf_Imperatif.t;
(*rules (possibly named)*)
Expand Down
31 changes: 22 additions & 9 deletions core/KaSa_rep/frontend/ckappa_sig.mli
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,27 @@ val compare_unit_agent_site : unit -> unit -> int

type binding_state = Free | Lnk_type of agent_name * site_name

type mixture =
type mixture =
| SKIP of mixture
| COMMA of agent * mixture
| DOT of c_agent_id * agent * mixture
| PLUS of c_agent_id * agent * mixture
| EMPTY_MIX

and agent = {
and 'counter parametric_agent = {
agent_name: string;
ag_intf: interface;
ag_intf: 'counter interface;
agent_name_pos: position; (*; ag_pos:position*)
}

and interface =
and agent_sig = counter_sig parametric_agent
and agent = counter parametric_agent

and 'counter interface =
| EMPTY_INTF
| PORT_SEP of port * interface
| COUNTER_SEP of counter * interface
| PORT_SEP of port * 'counter interface
| COUNTER_SEP of 'counter * 'counter interface


and port = {
port_name: string;
Expand All @@ -143,6 +147,15 @@ and counter = {
counter_delta: int option;
}

and counter_sig =
{
counter_sig_name: string;
counter_sig_default: int;
counter_sig_min: int option option;
counter_sig_max: int option option;
counter_visible: bool;
}

and counter_test = CEQ of int | CGTE of int | CVAR of string | UNKNOWN
and internal = string option list

Expand Down Expand Up @@ -187,8 +200,8 @@ type ('pattern, 'rule) modif_expr =

type 'pattern variable = ('pattern, string) Ast.variable_def

type ('agent, 'pattern, 'mixture, 'rule) compil =
('agent, 'pattern, 'mixture, string, 'rule) Ast.compil
type ('agent, 'agent_sig, 'pattern, 'mixture, 'rule) compil =
('agent, 'agent_sig, 'pattern, 'mixture, string, 'rule) Ast.compil

type ('a, 'b, 'c) site_type = Internal of 'a | Binding of 'b | Counter of 'c
type site = (site_name, site_name, site_name) site_type
Expand Down Expand Up @@ -415,7 +428,7 @@ type enriched_init = {
type c_compil = {
c_variables: c_variable Int_storage.Nearly_inf_Imperatif.t;
(*pattern declaration for reusing as variable in perturbations or kinetic rate*)
c_signatures: (agent * position) Int_storage.Nearly_inf_Imperatif.t;
c_signatures: (agent_sig * position) Int_storage.Nearly_inf_Imperatif.t;
(*agent signature declaration*)
c_rules: enriched_rule Int_storage.Nearly_inf_Imperatif.t;
(*rules (possibly named)*)
Expand Down
13 changes: 9 additions & 4 deletions core/KaSa_rep/frontend/list_tokens.ml
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ let declare_dual parameter error handler ag site state ag' site' state' =
in
error, { handler with Cckappa_sig.dual }

let scan_agent parameters (error, handler) agent =
let scan_agent ~get_counter_name parameters (error, handler) agent =
let error, (handler, ag_id) =
declare_agent parameters error handler agent.Ckappa_sig.agent_name
(Some agent.Ckappa_sig.agent_name_pos)
Expand All @@ -296,7 +296,7 @@ let scan_agent parameters (error, handler) agent =
| Ckappa_sig.COUNTER_SEP (counter, interface) ->
let error, (handler, _, _c) =
declare_site_with_counter parameters (error, handler) ag_id
counter.Ckappa_sig.counter_name
(get_counter_name counter)
in
aux error interface handler
| Ckappa_sig.PORT_SEP (port, interface) ->
Expand Down Expand Up @@ -366,6 +366,11 @@ let scan_agent parameters (error, handler) agent =
in
aux error agent.Ckappa_sig.ag_intf handler

let get_counter_name c = c.Ckappa_sig.counter_name
let get_counter_name_sig c = c.Ckappa_sig.counter_sig_name

let scan_agent_sig = scan_agent ~get_counter_name:get_counter_name_sig
let scan_agent = scan_agent ~get_counter_name
let rec scan_mixture parameters remanent mixture =
match mixture with
| Ckappa_sig.EMPTY_MIX -> remanent
Expand Down Expand Up @@ -401,7 +406,7 @@ let scan_initial_states parameters =
List.fold_left (scan_token parameters) remanent tk_l)

let scan_declarations parameters =
List.fold_left (fun remanent a -> scan_agent parameters remanent a)
List.fold_left (fun remanent a -> scan_agent_sig parameters remanent a)

let scan_observables _scan_mixt _parameters remanent _variable =
(*TODO*)
Expand Down Expand Up @@ -474,7 +479,7 @@ let scan_compil parameters error compil =
remanent
in
let remanent = empty_handler parameters error in
let remanent = scan_declarations parameters remanent compil.Ast.signatures in
let remanent = scan_declarations parameters remanent (compil.Ast.signatures:Ckappa_sig.agent_sig list) in
let remanent = scan_initial_states parameters remanent compil.Ast.init in
let remanent =
scan_observables scan_tested_mixture parameters remanent
Expand Down
1 change: 1 addition & 0 deletions core/KaSa_rep/frontend/list_tokens.mli
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ val scan_compil :
Remanent_parameters_sig.parameters ->
Exception_without_parameter.method_handler ->
( Ckappa_sig.agent,
Ckappa_sig.agent_sig,
Ckappa_sig.mixture,
Ckappa_sig.mixture,
'a,
Expand Down
Loading

0 comments on commit f5ece1e

Please sign in to comment.