Commit 1df1f7ba authored by HEMERY Mathieu's avatar HEMERY Mathieu
Browse files

Reactions are now parametrized to

parent 55f5a6d3
......@@ -162,6 +162,7 @@ commands = [
"option",
"pac_learning",
"parameter",
"parametrize",
"pattern_reduction",
"place",
"plot",
......
......@@ -56,8 +56,8 @@
get_parent/2,
get_model/2,
load_all/2,
parametrize_initial_concentration/0
% parametrize_reaction/0
parametrize_initial_concentration/0,
parametrize_reaction/0
]
).
......@@ -275,7 +275,8 @@ inherits(Ancestors) :-
parametrize :-
biocham_command,
doc('Replace the all the numbers of a model by parameters.'),
parametrize_initial_concentration.
parametrize_initial_concentration,
parametrize_reaction.
:- devdoc('\\section{Public API}').
......@@ -1102,19 +1103,67 @@ find_model_refs(RefSet, Models) :-
Models
).
%! parametrize_initial_concentration
%
% replace numeral initial concentration by parameter with the same value
parametrize_initial_concentration :-
forall(
item([item: present(Species, Value), kind:initial_state])
(
item([item: present(Species, Value), kind:initial_state])
;
(item([item: present(Species), kind:initial_state]) ,Value=1)
)
,
(
number(Value),
writeln(Species),
writeln(Value)
number(Value)
->
new_parameter(K),
command(present(Species, K)),
command(parameter(K = Value))
;
true
)
).
%! parametrize_reaction
%
% Replace the numeral of a kinetic by similar parameter
parametrize_reaction :-
forall(
item([item: Reac, kind: reaction, id: Id])
,
(delete_item(Id),
introduce_param(Reac, Reac2),
command(Reac2))
).
%! introduce_param(+reaction, -parametrized_reaction)
%
% recursive routine for parametrize_reaction
introduce_param(Kin for Reac, Kin2 for Reac) :-
introduce_param(Kin, Kin2).
introduce_param(A+B, A2+B2) :-
introduce_param(A, A2),
introduce_param(B, B2).
introduce_param(A*B, A2*B2) :-
introduce_param(A, A2),
introduce_param(B, B2).
introduce_param(X, K) :-
number(X),
new_parameter(K),
command(parameter(K = X)).
introduce_param(Func, Func2) :-
Func =.. [Name | Param],
maplist(introduce_param, Param, Param2),
Func2 =.. [Name | Param2].
introduce_param(O,O).
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment