Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve clarity of code in kappa compiler and counter compiler #676

Merged
merged 7 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions core/KaSa_rep/abstract_domains/mvbdu/dune
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
(library
(name kappa_mvbdu)
(libraries kappa_kasa_kastor_toolset kappa-library.generic)
(flags (:standard -w @a
-open Kappa_parameters
-open Kappa_errors
-open Kappa_logging
-open Kappa_kasa_kastor_toolset
-open Kappa_generic_toolset
)))
(name kappa_mvbdu)
(libraries kappa_kasa_kastor_toolset kappa-library.generic)
(flags
(:standard
-w
@a
-open
Kappa_parameters
-open
Kappa_errors
-open
Kappa_logging
-open
Kappa_kasa_kastor_toolset
-open
Kappa_generic_toolset)))
28 changes: 18 additions & 10 deletions core/KaSa_rep/abstract_domains/numerical_domains/dune
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
(library
(name kappa_numerical_domains)
(libraries kappa_kasa_frontend)
(flags (:standard -w @a
-open Kappa_parameters
-open Kappa_errors
-open Kappa_logging
-open Kappa_kasa_kastor_toolset
-open Kappa_generic_toolset
-open Kappa_kasa_frontend
)))
(name kappa_numerical_domains)
(libraries kappa_kasa_frontend)
(flags
(:standard
-w
@a
-open
Kappa_parameters
-open
Kappa_errors
-open
Kappa_logging
-open
Kappa_kasa_kastor_toolset
-open
Kappa_generic_toolset
-open
Kappa_kasa_frontend)))
41 changes: 28 additions & 13 deletions core/KaSa_rep/backend/dune
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
(library
(name kappa_kasa_backend)
(libraries yojson kappa_kasa_frontend kappa_kasa_remanent_state kappa_kasa_site_graphs)
(flags (:standard -w @a
-open Kappa_kasa_frontend
-open Kappa_kasa_kastor_toolset
-open Kappa_parameters
-open Kappa_errors
-open Kappa_logging
-open Kappa_generic_toolset
-open Kappa_kasa_remanent_state
-open Kappa_kasa_site_graphs
-open Kappa_kasa_type_interface
)))
(name kappa_kasa_backend)
(libraries
yojson
kappa_kasa_frontend
kappa_kasa_remanent_state
kappa_kasa_site_graphs)
(flags
(:standard
-w
@a
-open
Kappa_kasa_frontend
-open
Kappa_kasa_kastor_toolset
-open
Kappa_parameters
-open
Kappa_errors
-open
Kappa_logging
-open
Kappa_generic_toolset
-open
Kappa_kasa_remanent_state
-open
Kappa_kasa_site_graphs
-open
Kappa_kasa_type_interface)))
29 changes: 18 additions & 11 deletions core/KaSa_rep/counting_enumerating_species/dune
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
(library
(name kappa_species_count_enumeration)
(libraries num kappa_kasa_remanent_state kappa-library.generic)
(flags (:standard)
-open Kappa_parameters
-open Kappa_errors
-open Kappa_kasa_remanent_state
-open Kappa_kasa_frontend
-open Kappa_logging
-open Kappa_generic_toolset
-open Kappa_kasa_kastor_toolset
))
(name kappa_species_count_enumeration)
(libraries num kappa_kasa_remanent_state kappa-library.generic)
(flags
(:standard)
-open
Kappa_parameters
-open
Kappa_errors
-open
Kappa_kasa_remanent_state
-open
Kappa_kasa_frontend
-open
Kappa_logging
-open
Kappa_generic_toolset
-open
Kappa_kasa_kastor_toolset))
73 changes: 49 additions & 24 deletions core/KaSa_rep/export/dune
Original file line number Diff line number Diff line change
@@ -1,25 +1,50 @@
(library
(name kappa_kasa_export)
(libraries kappa_flow_analysis kappa_reachability kappa_influence_map kappa_polymers_analysis kappa_symmetries)
(flags (:standard)
-open Kappa_kasa_frontend
-open Kappa_kasa_remanent_state
-open Kappa_grammar
-open Kappa_terms
-open Kappa_logging
-open Kappa_generic_toolset
-open Kappa_errors
-open Kappa_reachability
-open Kappa_flow_analysis
-open Kappa_parameters
-open Kappa_kasa_kastor_toolset
-open Kappa_cli
-open Kappa_profiling
-open Kappa_mixtures
-open Kappa_influence_map
-open Kappa_polymers_analysis
-open Kappa_kasa_site_graphs
-open Kappa_kasa_backend
-open Kappa_symmetries
-open Kappa_kasa_type_interface
))
(name kappa_kasa_export)
(libraries
kappa_flow_analysis
kappa_reachability
kappa_influence_map
kappa_polymers_analysis
kappa_symmetries)
(flags
(:standard)
-open
Kappa_kasa_frontend
-open
Kappa_kasa_remanent_state
-open
Kappa_grammar
-open
Kappa_terms
-open
Kappa_logging
-open
Kappa_generic_toolset
-open
Kappa_errors
-open
Kappa_reachability
-open
Kappa_flow_analysis
-open
Kappa_parameters
-open
Kappa_kasa_kastor_toolset
-open
Kappa_cli
-open
Kappa_profiling
-open
Kappa_mixtures
-open
Kappa_influence_map
-open
Kappa_polymers_analysis
-open
Kappa_kasa_site_graphs
-open
Kappa_kasa_backend
-open
Kappa_symmetries
-open
Kappa_kasa_type_interface))
41 changes: 28 additions & 13 deletions core/KaSa_rep/export/export.ml
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,21 @@ functor
in
let () = cli.Run_cli_args.syntaxVersion <- syntax_version in
let () = cli.Run_cli_args.inputKappaFileNames <- files in
let (_, env, contactmap, _, _, _, _, init), _ =
let compilation_result : Cli_init.compilation_result =
Cli_init.get_compilation
~warning:(fun ~pos:_ _msg -> ())
~debugMode:false cli
~debug_mode:false cli
in
let state =
Remanent_state.set_init_state init
(Remanent_state.set_env (Some env)
(Remanent_state.set_contact_map_int (Some contactmap) state))
Remanent_state.set_init_state compilation_result.init_l
(Remanent_state.set_env (Some compilation_result.env)
(Remanent_state.set_contact_map_int
(Some compilation_result.contact_map) state))
in
state, Some (env : Model.t), Some init, Some contactmap
( state,
Some (compilation_result.env : Model.t),
Some compilation_result.init_l,
Some compilation_result.contact_map )

let compute_env show_title state =
let state, env, _, _ = compute_env_init show_title state in
Expand Down Expand Up @@ -1713,27 +1717,38 @@ functor
(Ckappa_sig.site_name_of_int y)
in
( state,
(Locality.dummy_annot sx, Locality.dummy_annot sy)
(Loc.annot_with_dummy sx, Loc.annot_with_dummy sy)
:: list ))
(state, []) rev_binding
in
let states' =
NamedDecls.create
(Tools.array_map_of_list
(fun i -> Locality.dummy_annot i, ())
(fun i -> Loc.annot_with_dummy i, ())
states)
in
( state,
(Locality.dummy_annot x, (states', binding', None)) :: acc
))
( Loc.annot_with_dummy x,
{
Signature.internal_state = states';
links = Some binding';
counters_info = None;
} )
:: acc ))
(state, []) interface
in
( state,
(Locality.dummy_annot a, NamedDecls.create (Array.of_list acc))
(Loc.annot_with_dummy a, NamedDecls.create_from_list acc)
:: list ))
(state, []) l.(0)
in
let signature = Signature.create ~counters:[] true l in

let agent_sigs =
LKappa_compiler.agent_sigs_of_agent_sigs_with_links_as_lists
~build_contact_map:true
(NamedDecls.create_from_list l)
in
let signature = Signature.create ~counters_per_agent:[] agent_sigs in
Remanent_state.set_signature signature state, signature

let get_signature = get_gen Remanent_state.get_signature compute_signature
Expand Down Expand Up @@ -1907,7 +1922,7 @@ functor
let cache = LKappa_auto.init_cache () in
let cc_cache = Pattern.PreEnv.of_env (Model.domain env) in
let _cc_cache, chemical_species =
Symmetry_interface.species_of_initial_state_env ~debugMode:false env
Symmetry_interface.species_of_initial_state_env ~debug_mode:false env
contact_map_int cc_cache init
in
let state, contact_map = get_contact_map ~accuracy_level state in
Expand Down
24 changes: 14 additions & 10 deletions core/KaSa_rep/flow/dune
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
(library
(name kappa_flow_analysis)
(libraries kappa_kasa_frontend)
(flags (:standard)
-open Kappa_kasa_frontend
-open Kappa_generic_toolset
-open Kappa_parameters
-open Kappa_logging
-open Kappa_errors

))
(name kappa_flow_analysis)
(libraries kappa_kasa_frontend)
(flags
(:standard)
-open
Kappa_kasa_frontend
-open
Kappa_generic_toolset
-open
Kappa_parameters
-open
Kappa_logging
-open
Kappa_errors))
8 changes: 4 additions & 4 deletions core/KaSa_rep/frontend/build_graph.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let add_agent parameters error handler cckappa_only agent_id agent_type mixture
Cckappa_sig.agent_kasim_id = agent_id;
Cckappa_sig.agent_name = agent_type;
Cckappa_sig.agent_interface = Ckappa_sig.Site_map_and_set.Map.empty;
Cckappa_sig.agent_position = Locality.dummy;
Cckappa_sig.agent_position = Loc.dummy;
Cckappa_sig.is_created = false;
}
in
Expand All @@ -45,7 +45,7 @@ let add_agent parameters error handler cckappa_only agent_id agent_type mixture
let empty_port =
{
Cckappa_sig.site_name = Ckappa_sig.dummy_site_name;
Cckappa_sig.site_position = Locality.dummy;
Cckappa_sig.site_position = Loc.dummy;
Cckappa_sig.site_free = None;
Cckappa_sig.site_state =
{
Expand Down Expand Up @@ -81,7 +81,7 @@ let add_site parameters error handler cckappa_only agent_id site_name mixture =
let site =
{
Cckappa_sig.site_name;
Cckappa_sig.site_position = Locality.dummy;
Cckappa_sig.site_position = Loc.dummy;
Cckappa_sig.site_free = None;
Cckappa_sig.site_state =
{
Expand Down Expand Up @@ -330,7 +330,7 @@ let add_link parameters error agent_id site_name agent_id' site_name'
in_progress =
let handler = in_progress.kappa_handler in
let lnk_id = in_progress.fresh_bond_id in
let fresh_bond_id = Ckappa_sig.next_lnk_value in_progress.fresh_bond_id in
let fresh_bond_id = Ckappa_sig.next_link_value in_progress.fresh_bond_id in
let error, mixture =
add_link parameters error handler in_progress.cckappa_only agent_id
site_name agent_id' site_name' lnk_id in_progress.mixture
Expand Down
7 changes: 3 additions & 4 deletions core/KaSa_rep/frontend/cckappa_sig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type kappa_handler = {
nagents: Ckappa_sig.c_agent_name;
agents_dic: Ckappa_sig.agent_dic;
agents_annotation:
(string * Locality.t list)
(string * Loc.t list)
Ckappa_sig.Agent_type_nearly_Inf_Int_storage_Imperatif.t;
interface_constraints:
Ckappa_sig.agent_specification
Expand Down Expand Up @@ -201,8 +201,7 @@ type compil = {
rules: enriched_rule Ckappa_sig.Rule_nearly_Inf_Int_storage_Imperatif.t;
(*rules (possibly named)*)
observables:
(mixture, string) Alg_expr.e Locality.annot
Int_storage.Nearly_inf_Imperatif.t;
(mixture, string) Alg_expr.e Loc.annoted Int_storage.Nearly_inf_Imperatif.t;
(*list of patterns to plot*)
init: enriched_init Int_storage.Nearly_inf_Imperatif.t;
(*initial graph declaration*)
Expand Down Expand Up @@ -615,7 +614,7 @@ let empty_port site =
site_name = site;
site_free = None;
site_state = empty_interval;
site_position = Locality.dummy;
site_position = Loc.dummy;
}
in
empty_port
Expand Down
5 changes: 2 additions & 3 deletions core/KaSa_rep/frontend/cckappa_sig.mli
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type kappa_handler = {
nagents: Ckappa_sig.c_agent_name;
agents_dic: Ckappa_sig.agent_dic;
agents_annotation:
(string * Locality.t list)
(string * Loc.t list)
Ckappa_sig.Agent_type_nearly_Inf_Int_storage_Imperatif.t;
interface_constraints:
Ckappa_sig.agent_specification
Expand Down Expand Up @@ -194,8 +194,7 @@ type compil = {
rules: enriched_rule Ckappa_sig.Rule_nearly_Inf_Int_storage_Imperatif.t;
(*rules (possibly named)*)
observables:
(mixture, string) Alg_expr.e Locality.annot
Int_storage.Nearly_inf_Imperatif.t;
(mixture, string) Alg_expr.e Loc.annoted Int_storage.Nearly_inf_Imperatif.t;
(*list of patterns to plot*)
init: enriched_init Int_storage.Nearly_inf_Imperatif.t;
(*initial graph declaration*)
Expand Down
Loading