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

Currently rewriting print_ifThenElse, BUG

parent 33b0c8d4
......@@ -699,50 +699,25 @@ append_elem_list([H1|T1],[H2|T2],[H12|T12]) :-
print_change_list(NumberOfSpecies,Print_helper_list, Species_order, Current_counter, Last_counter, Stream) :-
%%% print(Print_helper_list), print('\n'),
nth1(Current_counter, Print_helper_list, Change_list),
Change_list = [[Lower, Upper], First_change, Constraint | Change_Tail],
nth1(Current_counter,Species_order,Species),
(
length(Change_list, Triple_of_change),
Triple_of_change > 0
->
% First Change start with only "if".
write(Stream,' '),
write(Stream,Species),
write(Stream, ' = (if alpha_sum*ran>'),
nth1(1, Change_list, First_alpha),
nth1(1, First_alpha, Lower),
write(Stream, Lower),
write(Stream, ' and alpha_sum*ran<='),
nth1(2, First_alpha, Upper),
write(Stream, Upper),
nth1(3, Change_list, Constraint),
(
Constraint \== '0'
->
write(Stream, ' and '),
write(Stream, Constraint),
write(Stream, '>0')
;
debug(hybrid, "No constraint for this\n", [])
),
write(Stream, ' then '),
nth1(2, Change_list, First_change),
write(Stream, First_change),
format(Stream, " ~w = (if alpha_sum*ran>~w and alpha_sum*ran<=~w", [Species, Lower, Upper]),
format(Stream, " and ~w >0 then ~w", [Constraint, First_change]),
(
Change_number is (Triple_of_change / 3),
Change_number > 1
->
print_ifThenElse(Change_list, 2, Change_number, Stream)
print_ifThenElse(Change_Tail, Stream)
;
!
),
% The last one.
nl(Stream),
write(Stream, ' else '),
nth1(Current_counter, Species_order, Species_name),
write(Stream, Species_name),
write(Stream,')'),
format(Stream, "~n else ~w)", [Species]),
(
Current_counter = NumberOfSpecies
->
......@@ -766,40 +741,25 @@ print_change_list(NumberOfSpecies,Print_helper_list, Species_order, Current_coun
).
print_ifThenElse(Change_list, Start, End, Stream) :-
print_ifThenElse([], _Stream) :- !.
print_ifThenElse([[Lower, Upper], Change, Constraint | Change_Tail], Stream) :-
nl(Stream),
write(Stream, ' else if alpha_sum*ran>'),
Alpha_pos is (3 * Start - 2),
nth1(Alpha_pos, Change_list, [Lower, Upper]),
write(Stream, Lower),
write(Stream, ' and alpha_sum*ran<='),
write(Stream, Upper),
Constraint_pos is (3 * Start),
nth1(Constraint_pos, Change_list, Constraint),
(
Constraint \== '0'
Constraint \== '0'
->
write(Stream, ' and '),
write(Stream, Constraint),
write(Stream, '>0')
write(Stream, ' and '),
write(Stream, Constraint),
write(Stream, '>0')
;
true
%print('no constraint!\n')
true
),
write(Stream, ' then '),
Change_pos is (3 * Start - 1),
nth1(Change_pos, Change_list, Change),
write(Stream, Change),
(
Start < End
->
Next_start is (Start + 1),
print_ifThenElse(Change_list, Next_start, End, Stream)
;
!
).
print_ifThenElse(Change_Tail, Stream).
print_single_reaction_constraints(Constraints, Total, Current, Stream) :-
(
......
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