Commit f54f3bb2 authored by SOLIMAN Sylvain's avatar SOLIMAN Sylvain

Merge branch 'release/4.4.14'

parents d0e39c30 50ee79d5
......@@ -8,7 +8,7 @@
about/0
]).
version('4.4.13').
version('4.4.14').
copyright(
'Copyright (C) 2003-2020 Inria, EPI Lifeware, Saclay-Île de France, France'
......
FROM registry.gitlab.inria.fr/lifeware/biocham:v4.4.13
FROM registry.gitlab.inria.fr/lifeware/biocham:v4.4.14
This diff is collapsed.
list_reduction:- use_module(library(plunit)).
:- use_module(binomial_reduction).
:- begin_tests(binomial_reduction, [setup((clear_model, reset_options))]).
test(polynomial_ODE_True) :-
command(a => b),
command(3*a^2 for a+a => c),
reduction:polynomial_ODE.
test(polynomial_ODE_False) :-
command(a/b for a => b),
\+( reduction:polynomial_ODE ).
test(generate_names) :-
reduction:generate_names([a,'Out'], [[1,2],[1,0]], [aOut2, a]).
test(compute_number_species) :-
reduction:compute_number_species([3,1],8,0),
reduction:compute_number_species([0,3,0,1,0],8,3),
reduction:compute_number_species([2,2,0],9,1).
test(generate_sufficient_variables1) :-
PODE = [[[1,[1, 1]],[3,[0, 1]]],[[-1,[3, 0]]]],
reduction:generate_sufficient_variables(PODE,Set),
once(permutation(Set, [[1,0],[0,1],[2,0],[1,1],[3,0],[2,1]])).
test(generate_sufficient_variables2) :-
PODE = [[[1,[3, 1]]],[[-1,[1, 3]]]],
reduction: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],
[3,1],[2,2],[1,3],[3,2],[2,3]])).
test(generate_sufficient_variables3) :-
PODE = [[[1,[0, 3]]],[[-1,[0, 2]]]],
reduction:generate_sufficient_variables(PODE,Set),
once(permutation(Set, [[1,0],[0,1],[0,2]])).
test(list_reduction_nomodif) :-
once(reduction:list_reduction([2,[[[1,[1, 1]]],[[-1,[1, 0]]]],[1,2]],[a,b],P,[a,b])),
P = [2,[[[1,[1, 1]]],[[-1,[1, 0]]]],[1,2]].
test(list_reduction_simple) :-
once(reduction:list_reduction([2,[[[1,[1, 2]]],[[-1,[1, 0]]]],[1,2]],[a,b],P,[a,b,b2])),
P = [3,[[[1, [1, 0, 1]]], [[-1, [1, 0, 0]]], [[-2, [1, 1, 0]]]],[1,2,4]].
test(scan_order_multivar) :-
reduction:scan_order_multivar([[1,[1, 0]],[1,[1, 1]]],2),
reduction:scan_order_multivar([[1,[1, 2]],[1,[1, 1]]],3),
reduction:scan_order_multivar([[1,[1, 2]],[1,[12, 1]]],13).
test(add_all_sons) :-
reduction:add_all_sons([a, b],[a, b, c],[],[[a, b, c]]),
reduction:add_all_sons([a],[a, b, c],[[a, c]],[[a, b]]),
reduction:add_all_sons([a],[a, b, c],[],[[a, b], [a, c]]).
test(derivative_is_binomial) :-
reduction:derivative_is_binomial([[1,0],[0,2]],
[[1,[0,0]],[1,[1,0]],[1,[1,2]],[1,[2,0]]]).
%%% Test of PIVP manipulation %%%
test(compute_derivative1) :-
PODE = [ [[1,[0,1]],[2,[1,1]]] , [[3,[1,0]]] ],
reduction: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]]] ],
reduction: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]]] ],
reduction:compute_derivative([0,1,1], PODE, Deriv),
once(permutation(Deriv, [[1,[0,2,1]]])).
test(clean_writing) :-
reduction:clean_writing(1.0*2, 2),
reduction:clean_writing(0.0*2, 0),
reduction:clean_writing(1.0*input, input),
reduction:clean_writing(input^1, input),
reduction:clean_writing(input^2, input^2).
test(convert_poly_to_ode) :-
reduction:convert_poly_to_ode([[1, [1,1]]], [a,b], a*b),
reduction:convert_poly_to_ode([[1, [1,1]], [-2, [0,2]]], [a,b], a*b + -(2*b^2)).
:- end_tests(binomial_reduction).
{
"name": "gui",
"version": "4.4.13",
"version": "4.4.14",
"description": "biocham gui in jupyter notebook",
"main": "src/index.js",
"scripts": {
......
......@@ -24,6 +24,7 @@ commands = [
"add_vertex",
"alias",
"bifurcations",
"binomial_reduction_ODE",
"canonical",
"change_parameter_to_variable",
"check_conservations",
......@@ -179,6 +180,7 @@ commands = [
"pattern_reduction",
"place",
"plot",
"polynomial_ODE",
"present",
"prolog",
"quit",
......@@ -220,4 +222,5 @@ commands = [
"validity_domain",
"variation",
"which_p_m_mode",
"with_timer",
]
"""Example magic"""
__version__ = '4.4.13'
__version__ = '4.4.14'
This diff is collapsed.
......@@ -25,82 +25,19 @@ test(format_pivp_higher_order) :-
test(sort_output) :-
gpac:sort_output((1,d(cos)/dt=(-1*sin);0,d(sin)/dt=cos),cos,(1,d(cos)/dt=(-1*sin);0,d(sin)/dt=cos)),
gpac:sort_output((0,d(sin)/dt=cos;1,d(cos)/dt=(-1*sin)),cos,(1,d(cos)/dt=(-1*sin);0,d(sin)/dt=cos)).
gpac:sort_output((0,d(sin)/dt=cos;1,d(cos)/dt=(-1*sin)),cos,(1,d(cos)/dt=(-1*sin);0,d(sin)/dt=cos)),
gpac:sort_output((1.0, (d(f)/dt = f^3));(1.0, (d(g)/dt = f^3));(1.0, (d(h)/dt = g^3)), h,
(1.0, d(h)/dt = g^3);(1.0, d(f)/dt = f^3);(1.0, d(g)/dt = f^3)).
test(extract_names) :-
gpac:extract_names((1, d(a)/dt = 1; 2, d(b)/dt = 2), [a,b]).
test(generate_names) :-
gpac:generate_names([a,'Out'], [[1,2],[1,0]], [aOut2, a]).
%%% Test of g_to_c %%%
test(g_to_c_PIVP) :-
Old_PIVP = [1, [[[-1,[1]]]], [1]],
New_PIVP = [2, [[[-1,[1,1]]],[[-1,[0,1]]]], [1,input]],
gpac:g_to_c_PIVP(Old_PIVP,New_PIVP, 1.0).
%%% Test of binomial reduction %%%
test(compute_number_species) :-
gpac:compute_number_species([3,1],8,0),
gpac:compute_number_species([0,3,0,1,0],8,3),
gpac:compute_number_species([2,2,0],9,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],[1,1],[3,0],[2,1]])).
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],
[3,1],[2,2],[1,3],[3,2],[2,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]],[a,b],P,[a,b])),
P = [2,[[[1,[1, 1]]],[[-1,[1, 0]]]],[1,2]].
test(reduce_to_binomial_simple) :-
once(gpac:reduce_to_binomial([2,[[[1,[1, 2]]],[[-1,[1, 0]]]],[1,2]],[a,b],P,[a,b,b2])),
P = [3,[[[1, [1, 0, 1]]], [[-1, [1, 0, 0]]], [[-2, [1, 1, 0]]]],[1,2,4]].
test(scan_order_multivar) :-
gpac:scan_order_multivar([[1,[1, 0]],[1,[1, 1]]],2),
gpac:scan_order_multivar([[1,[1, 2]],[1,[1, 1]]],3),
gpac:scan_order_multivar([[1,[1, 2]],[1,[12, 1]]],13).
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(derivative_is_binomial) :-
gpac:derivative_is_binomial([[1,0],[0,2]],
[[1,[0,0]],[1,[1,0]],[1,[1,2]],[1,[2,0]]]).
%%% Test of PIVP manipulation %%%
test(compute_derivative1) :-
PODE = [ [[1,[0,1]],[2,[1,1]]] , [[3,[1,0]]] ],
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]],
......@@ -118,11 +55,4 @@ test(multiply_PIVP) :-
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(input^1, input),
gpac:clean_writing(input^2, input^2).
:- end_tests(gpac).
......@@ -75,6 +75,8 @@ find_invar_aux(ForcedMax, Type, OtherType, Operator) :-
Goal2 =.. [Type, P],
Goal2,
\+(member(P, Vars)),
% can be added by normalized_path
\+(base_mol([P])),
assertz(base_mol([P]))
),
[P]
......
This diff is collapsed.
......@@ -566,6 +566,8 @@ find_emptyable_siphons(GraphId) :-
retract(siphon(Current)),
ord_union(Siphon, Current, Union),
assertz(siphon(Union)),
debug(rate, "found siphon: ~w", [Siphon]),
debug(rate, "current union of siphons: ~w", [Union]),
fail
;
debugging(rate)
......@@ -595,6 +597,7 @@ pinv_constraints(LSpecies, LVars) :-
% enforce that P is not covered
is_not_covered(P, LSpecies, LVars) :-
maplist(get_var_from_species(LSpecies, LVars), P, PVars),
debug(rate, "constraint: ~w", [element(_, PVars, 0)]),
element(_, PVars, 0).
......@@ -635,6 +638,7 @@ siphon_constraints_aux([(NR, NP) | L], LSpecies, LVars) :-
sum(VR, #=, SR),
sum(VP, #=, SP),
SP #> 0 #==> SR #> 0,
debug(rate, "constraint ~w", [sum(VP) #> 0 #==> sum(VR) #> 0]),
siphon_constraints_aux(L, LSpecies, LVars).
......
......@@ -133,6 +133,7 @@
- gpac.pl
- lazy_negation.pl
- lazy_negation_gpac.pl
- binomial_reduction.pl
** Synthesis from transfer functions
- transfer_function.pl
#** Synthesis from programs
......
......@@ -23,7 +23,8 @@
list_model_options/0,
have_to_delete_temporary_files/0,
store_default_options/0,
reset_options/0
reset_options/0,
with_timer/1
]).
......@@ -566,3 +567,23 @@ reset_options :-
set_option(Option, Value)
)
).
with_timer(Goal, Time) :-
biocham_command,
doc('Execute a given Goal in a given Time (in ms). If no second argument is given, it displays the time taken to execute the command in the standard output.'),
get_time(T0),
command(Goal),
get_time(T1),
Time is (T1-T0)*1000.
with_timer(Goal) :-
biocham_command,
with_timer(Goal, Time),
format("The previous command takes ~g ms~n", Time).
:- doc('\\begin{example}
\\trace{
biocham: with_timer(a+b => c).
biocham_silent(clear_model).
}
\\end{example}').
......@@ -56,8 +56,9 @@
write_condition_to_c/2,
write_condition_to_c_with_parentheses/2,
normal_random/1,
atom_to_int/2,
realsetof/3
expand_polynomial/2,
atom_to_int/2,
realsetof/3
]).
:- use_module(library(process)).
......@@ -912,6 +913,43 @@ normal_random(X) :-
assertz(done_normal(Y)).
%! expand_polynomial(+Polynomial, -Expanded_polynomial)
%
% Expand a polynomial for parsing purpose
expand_polynomial(Poly, Expanded) :-
expand_polynomial_sr(Poly, Test),
(
Poly = Test
->
Expanded = Test
;
expand_polynomial(Test,Expanded)
).
expand_polynomial_sr(A*(B+C), (A*B) + (A*C)) :- !.
expand_polynomial_sr(A*(B-C), (A*B) - (A*C)) :- !.
expand_polynomial_sr((B+C)*A, (B*A) + (C*A)) :- !.
expand_polynomial_sr((B-C)*A, (B*A) - (C*A)) :- !.
expand_polynomial_sr(A*(B+C)*D, (A*B*D) + (A*C*D)) :- !.
expand_polynomial_sr(A*(B-C)*D, (A*B*D) - (A*C*D)) :- !.
expand_polynomial_sr(A*(B*C), (A*B)*C) :- !.
expand_polynomial_sr((B+C)/A, (B/A) + (C/A)) :- !.
expand_polynomial_sr((B-C)/A, (B/A) - (C/A)) :- !.
expand_polynomial_sr(A*B/C, A/C*B) :- !.
expand_polynomial_sr(E-(A+B), E-A-B) :- !.
expand_polynomial_sr(-(A+B), -A-B) :- !.
expand_polynomial_sr(A+B, AA+BB) :- !,
expand_polynomial_sr(A,AA),
expand_polynomial_sr(B,BB).
expand_polynomial_sr(A-B, AA-BB) :- !,
expand_polynomial_sr(A,AA),
expand_polynomial_sr(B,BB).
expand_polynomial_sr(A*B, AA*BB) :- !,
expand_polynomial_sr(A,AA),
expand_polynomial_sr(B,BB).
expand_polynomial_sr(A, A).
%! atom_to_int(+String:atom, -Int:integer) is det.
%
% Read an Int from a String (atom)
......
......@@ -12,4 +12,11 @@ test('new_molecule') :-
command('A' => 'B'),
new_molecule('C').
test('expand_polynomial') :-
expand_polynomial(a*(b+c)/d, a/d*b + a/d*c),
expand_polynomial(a*(b+c-d), (a*b)+(a*c)-(a*d)),
expand_polynomial((a+b)*(c-d), a*c+b*c-a*d-b*d),
expand_polynomial(p*r1*n1*(1-(n0+n1+n2)/k)/co, p/co*r1*n1*1-p/co*r1*n1*(n0/k)-p/co*r1*n1*(n1/k)-p/co*r1*n1*(n2/k)),
expand_polynomial(bb/e*(pa+ -1)*db, bb/e*pa*db + bb/e*(-1)*db).
:- end_tests(util).
......@@ -32,7 +32,7 @@
</head>
<body>
<h1>The Biochemical Abstract Machine BIOCHAM 4</h1>
<h1>version 4.4.13 May 2020</h1>
<h1>version 4.4.14 June 2020</h1>
<div class="authors">
<p>
......
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