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

Rewrite print_normal

parent 26ea5aa1
......@@ -528,12 +528,12 @@ print_event(Reactions_data, Stoch_list, Hybrid_reactants_list, Constraints_list,
print_hybrid_species_constraint(Hybrid_reactants_list, 1, Stream),
% 2. Build alpha list and alpha subsums.
build_alphas(Number_of_alpha, Alpha_list, Alpha_accumulation_list),
build_alphas(Number_of_alpha, Alpha_accumulation_list),
% 3. Print reactions in event
constant_list(Number_of_species,[],Init_list2),
% Build the print_helper_list.
print_normal(Reactions_data, Init_list2, Print_helper_list, Alpha_list, Alpha_accumulation_list, Constraints_list, Stoch_list),
print_normal(Reactions_data, Init_list2, Print_helper_list, Alpha_accumulation_list, Constraints_list, Stoch_list, 1),
% Use print_helper_list to really print out the event part.
print_change_list(Number_of_species,Print_helper_list, Stoch_list, 1, Number_of_species, Stream).
......@@ -615,9 +615,9 @@ print_alpha_sr([N|Tail], Stream) :-
%== Build Alpha lists for current event ==%
%========================================%
%! build_alphas(+N_alpha, -Alpha_list, -Alpha_accumulation_list)
%! build_alphas(+N_alpha, -Alpha_accumulation_list)
build_alphas(N_alpha, Alpha_list, Alpha_accumulation_list) :-
build_alphas(N_alpha, Alpha_accumulation_list) :-
numlist(1, N_alpha, NL),
build_alpha_list(NL, Alpha_list),
alpha_accumulation(Alpha_list, '', Alpha_accumulation_list).
......@@ -650,22 +650,21 @@ alpha_accumulation([], _Acc, []).
%== Get Data from Reactions ==%
%=============================%
print_normal(Reactions_data, Init_list, N_finish_list, Alpha_list, Alpha_accumulation_list, Constraints_list, Stoch_species_order) :-
%! print_normal(Reactions_data, In_list, Out_list, Alpha_accumulation_list, Constraints_list, Stoch_species_order)
% Find alpha.
nth1(1, Alpha_list, First_alpha),
print_normal([[Sp_change|_]|DataTail], In_list, Out_list, [Alp1|AlpTail], [Cons|ConsTail], Sp_list, 1) :-
check_change1(Alp1, Cons, Sp_list, 1, Sp_change, In_list, Tempo_list),
print_normal(DataTail, Tempo_list, Out_list, [Alp1|AlpTail], ConsTail, Sp_list, 2).
print_normal([[Sp_change|_]|DataTail], In_list, Out_list, [A1,A2|ATail], [Cons|CTail], Sp_list, 2) :-
check_change(A1, A2, Cons, Sp_list, 1, Sp_change, In_list, Tempo_list),
print_normal(DataTail, Tempo_list, Out_list, [A2|ATail], CTail, Sp_list, 2).
print_normal([], Out_list, Out_list, _A, _C_list, _Sp_list, _N).
% Build Connections to constraints.
nth1(1, Constraints_list, Constraint),
% Check species changes
nth1(1, Reactions_data, First_datalist),
nth1(1, First_datalist, First_species_change),
check_change1(First_alpha, Constraint, Stoch_species_order,1, First_species_change, Init_list, Later_list),
% Recursive call for all Normal reactions.
print_normal_middle(Reactions_data, Later_list, N_finish_list,Alpha_list, Alpha_accumulation_list, Constraints_list,Stoch_species_order, 2).
check_change1(First_alpha, Constraint, Stoch_species_order, Species_counter, First_species_change, Orig_list, Later_list) :-
nth1(Species_counter, First_species_change, Species_change),
......@@ -723,31 +722,6 @@ add_n_copy_list(Orig_list, Start_counter, Species_counter, Next_list_temp, Out_i
Next_list = Out_init
).
print_normal_middle(Reactions_data, Orig_list, Result_list, Alpha_list, Alpha_accumulation_list, Constraints_list,Stoch_species_order, Counter_for_reaction) :-
%%% print('Orig_list: '), print(Orig_list), print('\n'),
% Find alpha and the range of constraints.
length(Reactions_data, Last_reaction),
nth1(Counter_for_reaction, Reactions_data, Datalist),
nth1(Counter_for_reaction, Constraints_list, Constraint),
Previous_reaction is (Counter_for_reaction - 1),
% Get the species changes.
nth1(1, Datalist, Species_change),
nth1(Previous_reaction, Alpha_accumulation_list, First_alpha),
nth1(Counter_for_reaction, Alpha_accumulation_list, Second_alpha),
check_change(First_alpha, Second_alpha, Constraint, Stoch_species_order,1, Species_change, Orig_list, Middle_list),
% Recursive condition.
(
length(Reactions_data, Last_reaction),
Counter_for_reaction < Last_reaction
->
Next_reaction is (Counter_for_reaction + 1),
print_normal_middle(Reactions_data, Middle_list, Result_list,Alpha_list, Alpha_accumulation_list, Constraints_list,Stoch_species_order, Next_reaction)
;
Result_list = Middle_list
).
check_change(First_alpha, Second_alpha, Constraint, Stoch_species_order,Species_counter, Species_change, Orig_list, Result_list) :-
nth1(Species_counter, Species_change, Change),
......@@ -1204,14 +1178,14 @@ print_dynamic_event(SortedSpecies,Reactions_data, HybridDynamicReactants,MaxPart
write(Stream,' tau = Time+delta_t/'),write(Stream,Rate),write(Stream,','),nl(Stream),
write(Stream,' ran = random_float,'),nl(Stream),
print_hybrid_species_constraint(Hybrid_reactants_list, 1, Stream),
build_alphas(Number_of_alpha, Alpha_list, Alpha_accumulation_list),
build_alphas(Number_of_alpha, Alpha_accumulation_list),
% 3. Print reactions in event
length(Stoch_species_order, Number_of_species),
constant_list(Number_of_species,[],Init_list2),
% Build the print_helper_list.
print_normal(Reactions_data, Init_list2, Print_helper_list, Alpha_list, Alpha_accumulation_list, Constraints_list, Stoch_species_order),
print_normal(Reactions_data, Init_list2, Print_helper_list, Alpha_accumulation_list, Constraints_list, Stoch_species_order, 1),
% Use print_helper_list to really print out the event part.
length(Stoch_species_order,NumberOfSpecies),
......
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