Commit 403788e0 authored by Mathieu Hemery's avatar Mathieu Hemery
Browse files

Merge with current gpac branch

parents b352315e 91d771f8
This diff is collapsed.
......@@ -33,10 +33,20 @@ test(compute_number_species) :-
gpac:compute_number_species([0,3,0,1,0],8,3),
gpac:compute_number_species([2,2,0],9,1).
test(generate_variable) :-
gpac:generate_variable([3,1],7,[[1,0],[2,0],[3,0],[0,1],[1,1],[2,1],[3,1]]),
gpac:generate_variable([2,2],8,[[1,0],[2,0],[0,1],[1,1],[2,1],[0,2],[1,2],[2,2]]),
gpac:generate_variable([0,2,0,1],7,[[1,0,0,0],[0,0,1,0],[0,1,0,0],[0,2,0,0],[0,0,0,1],[0,1,0,1],[0,2,0,1]]).
test(generate_sufficient_variables1) :-
PODE = [[[1,[1, 1]],[3,[0, 1]]],[[-1,[3, 0]]]],
gpac:generate_sufficient_variables(PODE,Set),
once(permutation(Set, [[1,0],[0,1],[2,0]])).
test(generate_sufficient_variables2) :-
PODE = [[[1,[3, 1]]],[[-1,[1, 3]]]],
gpac:generate_sufficient_variables(PODE,Set),
once(permutation(Set, [[1,0],[0,1],[2,0],[1,1],[0,2],[3,0],[1,2],[2,1],[0,3]])).
test(generate_sufficient_variables3) :-
PODE = [[[1,[0, 3]]],[[-1,[0, 2]]]],
gpac:generate_sufficient_variables(PODE,Set),
once(permutation(Set, [[1,0],[0,1],[0,2]])).
test(reduce_to_binomial_nomodif) :-
once(gpac:reduce_to_binomial([2,[[[1,[1, 1]]],[[-1,[1, 0]]]],[1,2]],P)),
......@@ -51,23 +61,50 @@ test(scan_order_multivar) :-
gpac:scan_order_multivar([[1,[1, 2]],[1,[1, 1]]],3),
gpac:scan_order_multivar([[1,[1, 2]],[1,[12, 1]]],13).
test(add_new_variable_monomial) :-
gpac:add_new_variable_monomial([1,[1,1,1]],[1,0,1],[1,[0,1,0,1]]),
gpac:add_new_variable_monomial([2,[1,1,0]],[1,0,1],[2,[1,1,0,0]]),
gpac:add_new_variable_monomial([2,[2,1,3]],[1,0,1],[2,[0,1,1,2]]).
test(add_all_sons) :-
gpac:add_all_sons([a, b],[a, b, c],[],[[a, b, c]]),
gpac:add_all_sons([a],[a, b, c],[[a, c]],[[a, b]]),
gpac:add_all_sons([a],[a, b, c],[],[[a, b], [a, c]]).
test(add_new_variable) :-
PODE = [ [[1,[0,1]],[2,[1,1]]] , [[3,[1,0]]] ],
Modified_PODE = [[[1,[0,1,0]],[2,[0,0,1]]],[[3,[1,0,0]]],[[3,[2,0,0]],[1,[0,2,0]],[2,[0,1,1]]]],
gpac:add_new_variable([2,PODE,[1,2]],[1,1],[3,Modified_PODE,[1,2,2]]).
%%% Test of PIVP manipulation %%%
test(compute_derivative) :-
test(compute_derivative1) :-
PODE = [ [[1,[0,1]],[2,[1,1]]] , [[3,[1,0]]] ],
gpac:compute_derivative([1,1],PODE,1,[[3,[2,0]],[1,[0,2]],[2,[1,2]]]).
gpac:compute_derivative([1,1], PODE, Deriv),
once(permutation(Deriv, [[3,[2,0]],[1,[0,2]],[2,[1,2]]])).
test(compute_derivative2) :-
PODE = [ [[1,[0,1,0]]] , [[3,[1,0,0]],[2,[1,1,0]]] , [[-2,[1,1,0]]] ],
gpac:compute_derivative([0,1,1], PODE, Deriv),
once(permutation(Deriv, [[3,[1,0,1]],[2,[1,1,1]],[-2,[1,2,0]]])).
test(compute_derivative3) :-
PODE = [ [[1,[0,1,0]]] , [[3,[0,2,0]]] , [[-2,[0,1,1]]] ],
gpac:compute_derivative([0,1,1], PODE, Deriv),
once(permutation(Deriv, [[1,[0,2,1]]])).
test(invert_PIVP) :-
gpac:exp_PIVP(Exp),
ResPIVP = [2,[[[-1,[2,1]]],[[1,[0,1]]]],[1,1]],
gpac:invert_PIVP(Exp, ResPIVP).
test(add_PIVP) :-
PIVP1 = [1, [ [ [1, [1]] ] ], [1]],
PIVP2 = [1, [ [ [-1, [2]] ] ], [1]],
gpac:add_PIVP(PIVP1, PIVP2, PIVP12),
PIVP12 = [3,[[[-1,[0,0,2]],[1,[0,1,0]]],[[1,[0,1,0]]],[[-1,[0,0,2]]]],[2,1,1]].
test(multiply_PIVP) :-
PIVP1 = [1, [ [ [1, [1]] ] ], [1]],
PIVP2 = [1, [ [ [-1, [2]] ] ], [1]],
gpac:multiply_PIVP(PIVP1, PIVP2, PIVP12),
PIVP12 = [3,[[[1,[0,1,1]],[-1,[0,1,2]]],[[1,[0,1,0]]],[[-1,[0,0,2]]]],[1,1,1]].
test(clean_writing) :-
gpac:clean_writing(1.0*2, 2),
gpac:clean_writing(0.0*2, 0),
gpac:clean_writing(1.0*input, input).
gpac:clean_writing(1.0*input, input),
gpac:clean_writing(input^1, input),
gpac:clean_writing(input^2, input^2).
:- end_tests(gpac).
......@@ -33,6 +33,18 @@ rewrite_PIVP([N,ODE,Init], [NewN,NewODE,NewInit], VarNeg) :-
rewrite_initial_concentration(Init, VarNeg, NewInit),
length(VarNeg, NVN), NewN is N+NVN.
%! rewrite_PIVP_all_negated(+PIVP_list, -PIVP_rewrited, -VarNeg)
%
% rewrite the ode set with all variables negated
rewrite_PIVP_all_negated([N,ODE,Init], [NewN,NewODE,NewInit], VarNeg) :-
numlist(1,N,VarNeg), %VarNeg contains all the variables
rewrite_derivative_main(ODE, VarNeg, ODE_Tempo),
clean_ODE(ODE_Tempo,VarNeg,NewODE),
rewrite_initial_concentration(Init, VarNeg, NewInit),
NewN is 2*N.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Detection part %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......
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