Commit ad08ab3d authored by HEMERY Mathieu's avatar HEMERY Mathieu
Browse files

Merge convert_into_hybrid 1 and 2 in a single predicate

parent eb7a836e
......@@ -389,7 +389,7 @@ convert_MA(Reaction,Reactions,Hybrid_original_list,NewKinetics) :-
reaction(Reaction, [kinetics: Kinetics,reactants: Reactants,inhibitors: _, products: _]),
Kinetics =.. ['MA',K],
kinetics:eval_kinetics(Reactants, _, product(in('S'*'M', [reactants]), 'M'^'S'), Value),
convert_into_hybrid(Value,Hybrid_original_list,NewValue),!,
convert_into_hybrid(Value, Hybrid_original_list, std, NewValue),!,
(
nb_current(dynamic_parameters,_)
->
......@@ -404,33 +404,41 @@ convert_MA(Reaction,Reactions,Hybrid_original_list,NewKinetics) :-
).
%! convert_into_hybrid(+Rate, +List_species, -NewRate)
%! convert_into_hybrid(+Rate, +List_species, +Mode, -NewRate)
%
% Rewrite the reaction rate using the species_total function
% When Mode = stoch, Species outside Liste_species are convert to Species_stoch
% and are otherwise untouched
convert_into_hybrid(Value * 1, List_species, NewValue) :-
convert_into_hybrid(Value, List_species, NewValue).
convert_into_hybrid(Value * 1, List_species, Mode, NewValue) :-
convert_into_hybrid(Value, List_species, Mode, NewValue).
convert_into_hybrid(Value ^ 1, List_species, NewValue) :-
convert_into_hybrid(Value, List_species, NewValue).
convert_into_hybrid(Value ^ 1, List_species, Mode, NewValue) :-
convert_into_hybrid(Value, List_species, Mode, NewValue).
convert_into_hybrid(Value1 * Value2, List_species, NewValue1 * NewValue2) :-
convert_into_hybrid(Value1, List_species, NewValue1),
convert_into_hybrid(Value2, List_species, NewValue2).
convert_into_hybrid(Value1 * Value2, List_species, Mode, NewValue1 * NewValue2) :-
convert_into_hybrid(Value1, List_species, Mode, NewValue1),
convert_into_hybrid(Value2, List_species, Mode, NewValue2).
convert_into_hybrid(Value1 ^ Value2, List_species, NewValue1 ^ NewValue2) :-
convert_into_hybrid(Value1, List_species, NewValue1),
convert_into_hybrid(Value2, List_species, NewValue2).
convert_into_hybrid(Value1 ^ Value2, List_species, Mode, NewValue1 ^ NewValue2) :-
convert_into_hybrid(Value1, List_species, Mode, NewValue1),
convert_into_hybrid(Value2, List_species, Mode, NewValue2).
convert_into_hybrid(Number, _, Number) :-
convert_into_hybrid(Number, _, _Mode, Number) :-
number(Number),
!.
convert_into_hybrid(Molecule, List_species, Molecule) :-
\+(member(Molecule, List_species)),
!.
convert_into_hybrid(Molecule, List_species, Mode, Out_Molecule) :-
\+(member(Molecule, List_species)),!,
(
Mode = stoch
->
species_to_stoch(Molecule, Out_Molecule)
;
Out_Molecule = Molecule
).
convert_into_hybrid(Molecule, List_species, HybridMolecule) :-
convert_into_hybrid(Molecule, _List_species, _Mode, HybridMolecule) :-
get_option(stochastic_conversion, Rate),
nb_getval(volume,Volume),
species_to_total(Molecule, Molecule_total),
......@@ -451,7 +459,7 @@ convert_MA2(Reaction,ODESpecies,NewKinetics,Reactants,Products) :-
reaction(Reaction, [kinetics: Kinetics,reactants: Reactants,inhibitors: _, products: Products]),
Kinetics =.. ['MA',K],
kinetics:eval_kinetics(Reactants, _, product('S'*'M' in [reactants], 'M'^'S'), Value),
convert_into_hybrid2(Value,ODESpecies,NewValue),!,
convert_into_hybrid(Value, ODESpecies, stoch, NewValue),!,
NewKinetics = K * NewValue,
(
nb_current(dynamic_parameters,_)
......@@ -461,42 +469,6 @@ convert_MA2(Reaction,ODESpecies,NewKinetics,Reactants,Products) :-
assertz(reaction_kinetics(Reaction,NewKinetics))
).
convert_into_hybrid2(Value * 1, ODESpecies,NewValue) :-
convert_into_hybrid2(Value,ODESpecies,NewValue).
convert_into_hybrid2(Value ^ 1, ODESpecies,NewValue) :-
convert_into_hybrid2(Value,ODESpecies,NewValue).
convert_into_hybrid2(Value1 * Value2, ODESpecies,NewValue1 * NewValue2) :-
convert_into_hybrid2(Value1,ODESpecies,NewValue1),
convert_into_hybrid2(Value2,ODESpecies,NewValue2).
convert_into_hybrid2(Value1 ^ Value2, ODESpecies,NewValue1 ^ NewValue2) :-
convert_into_hybrid2(Value1,ODESpecies,NewValue1),
convert_into_hybrid2(Value2,ODESpecies,NewValue2).
convert_into_hybrid2(Number,_,Number) :-
number(Number),
!.
% this is the part that differentiate it from convert_into_hybrid
convert_into_hybrid2(Molecule,ODESpecies,StochMolecule) :-
\+(member(Molecule,ODESpecies)),
species_to_stoch(Molecule,StochMolecule),
!.
convert_into_hybrid2(Molecule,Hybrid_original_list,HybridMolecule) :-
get_option(stochastic_conversion, Rate),
nb_getval(volume,Volume),
member(Molecule,Hybrid_original_list),
species_to_total(Molecule, Molecule_total),
atom_concat('(',Molecule_total,Molecule1),
atom_concat(Molecule1,'/(',Molecule2),
atom_concat(Molecule2,Rate,Molecule3),
atom_concat(Molecule3,'*',Molecule4),
atom_concat(Molecule4,Volume,Molecule5),
atom_concat(Molecule5,'))',HybridMolecule),
!.
% build_stoechiometry(+Reactant_list, +Product_list, +Species_list, -Stoechiometry)
%
......@@ -1183,8 +1155,6 @@ hybrid_dynamic_simulation(InputFile,OutFilename,Volume,Time,PropTresh,PartTresh)
)
),
Reactants_by_rules),
writeln(Reactants1),
writeln(Reactants_by_rules),
build_constraints_by_rules(Reactants_by_rules, SortedReactants, 1, [], Hybrid_reactants_list),
build_constraints_list(Hybrid_reactants_list, Constraints_list),
......
Markdown is supported
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