Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

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

Rewrite print_constraint and concat_species

parent a3497ba4
......@@ -730,67 +730,44 @@ print_if_then_else([[Lower, Upper], Change, Constraint | Change_Tail], Stream) :
print_if_then_else(Change_Tail, Stream).
print_single_reaction_constraints(Constraints, Total, Current, Stream) :-
(
Current < Total
->
nth1(Current, Constraints, To_print),
write(Stream, To_print),
write(Stream, ' and '),
Next is Current + 1,
print_single_reaction_constraints(Constraints, Total, Next, Stream)
;
nth1(Current, Constraints, To_print),
write(Stream, To_print),
!
).
%! print_single_reaction_constraints(Constraint_list, Stream)
print_single_reaction_constraints([To_print], Stream) :-
format(Stream, "~w", [To_print]), !.
print_single_reaction_constraints([To_print | Tail], Stream) :-
format(Stream, "~w and ", [To_print]),
print_single_reaction_constraints(Tail, Stream).
%! print_hybrid_species_constraint(Hybrid_reactants_list, Stream)
print_hybrid_species_constraint(Constraints_list, Stream) :-
print_hybrid_species_constraint(Constraints_list, 1, Stream).
print_hybrid_species_constraint(Hybrid_reactants_list, Current_counter, Stream) :-
length(Hybrid_reactants_list, Total_count),
nth1(Current_counter, Hybrid_reactants_list, This_reaction_constraints),
length(This_reaction_constraints, Number_of_constraints),
print_hybrid_species_constraint([], _Counter, _Stream).
print_hybrid_species_constraint([Constraints|Tail], Counter, Stream) :-
(
This_reaction_constraints \== [0]
Constraints \== [0]
->
write(Stream, ' lower_level'),
write(Stream,Current_counter),
write(Stream,' = (if '),
print_single_reaction_constraints(This_reaction_constraints, Number_of_constraints, 1, Stream),
write(Stream, ' then 1 else 0),'),
nl(Stream)
format(Stream, " lower_level~w = (if " , [Counter]),
print_single_reaction_constraints(Constraints, Stream),
format(Stream, " then 1 else 0),~n", [])
;
!
!
),
(
Current_counter < Total_count
->
Next_counter is Current_counter + 1,
print_hybrid_species_constraint(Hybrid_reactants_list, Next_counter, Stream)
;
!
).
Counterp is Counter + 1,
print_hybrid_species_constraint(Tail, Counterp, Stream).
concat_species(Species, Count, Init, Results) :-
length(Species, L),
(
Count =< L
->
nth1(Count, Species, Species1),
species_to_total(Species1,Species1_processed),
atom_concat(', ', Species1_processed, Species2_processed),
atom_concat(Init, Species2_processed, NewSubstring),
Next_count is Count + 1,
concat_species(Species, Next_count, NewSubstring, Results)
;
Init = Results
).
concat_species([Sp|Sp_tail], Result) :-
species_to_total(Sp, Sp_tot),
foldl(concat_species_sr, Sp_tail, Sp_tot, Result).
concat_species2(Species, Init, Results) :-
nth1(1, Species, First),
species_to_total(First,First1),
atom_concat(Init, First1, Newsubstring),
concat_species(Species, 2, Newsubstring, Results).
concat_species_sr(Sp, Acc, Accn) :-
species_to_total(Sp, Sp_tot),
atomic_list_concat([Acc, ', ', Sp_tot], Accn).
print_show_option(Hybrid_original_list,Stream) :-
(
......@@ -798,7 +775,7 @@ print_show_option(Hybrid_original_list,Stream) :-
->
write(Stream,'%option(show: {}).'),nl(Stream)
;
concat_species2(Hybrid_original_list,'',SpeciesList),
concat_species(Hybrid_original_list, SpeciesList),
write(Stream,'option(show: {'),
write(Stream,SpeciesList),
write(Stream,'}). % Choose here the species to plot'),
......
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