Commit 6ff633d0 by Mathieu Hemery

### Switch from binomial to quadratic_reduction terminology

parent b4e914b5
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), with_output_to(atom(_), reduction:polynomial_ODE). test(polynomial_ODE_False) :- command(a/b for a => b), with_output_to(atom(_), \+ 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], -(2*b^2) + a*b). :- end_tests(binomial_reduction).
 ... ... @@ -24,7 +24,6 @@ commands = [ "add_vertex", "alias", "bifurcations", "binomial_reduction_ODE", "canonical", "change_parameter_to_variable", "check_conservations", ... ... @@ -187,6 +186,7 @@ commands = [ "polynomial_ODE", "present", "prolog", "quadratic_reduction_ODE", "quit", "reaction_graph", "reaction_model", ... ...
 ... ... @@ -46,7 +46,7 @@ Rq: The distinction between pivp_string and pivp_list is not always obvious. :- use_module(library(clpfd)). :- use_module(doc). :- use_module(binomial_reduction). :- use_module(quadratic_reduction). :- use_module(biocham). :- use_module(lazy_negation_gpac). :- use_module(objects). ... ... @@ -64,12 +64,12 @@ Rq: The distinction between pivp_string and pivp_list is not always obvious. %%% Main Tools of the module %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% :- doc('The option for binomial reduction restricts the synthesis to reactions with at :- doc('The option for quadratic reduction restricts the synthesis to reactions with at most two reactants (the default is not, since this process may be costly). Two methods are available to perform this a posteriori reduction: natively or using an external SAT solver.'). :- initial(option(binomial_reduction: no)). :- initial(option(quadratic_reduction: no)). :- doc('Another option is the lazy introduction of molecular species for negative real values (the default is yes).'). ... ... @@ -97,10 +97,10 @@ compile_from_expression(Expr, Output) :- The expression is restricted to standard functions and simple operations using a functional notation where \\texttt{id} represents the time operand. '), option( binomial_reduction, quadratic_reduction, reduction_methods, _Reduction, 'Determine if the binomial reduction for synthesizing reactions with at most two reactants has to be performed' 'Determine if the quadratic reduction for synthesizing reactions with at most two reactants has to be performed' ), option( lazy_negatives, ... ... @@ -112,7 +112,7 @@ compile_from_expression(Expr, Output) :- negation_first, yesno, _Negation_first, 'Determine if the negation of variables is perform before or after the binomialisation' 'Determine if the negation of variables is perform before or after the quadratization' ), expression_to_PIVP(Expr, PIVP), PIVP = [N, _PODE, _IC], ... ... @@ -144,10 +144,10 @@ compile_from_expression(Expr, Input, Output) :- The Input species is initialized with the value of a special parameter named input. This species may be degraded by the computation. '), option( binomial_reduction, quadratic_reduction, reduction_methods, _Reduction, 'Determine if the binomial reduction for synthesizing reactions with at most two reactants has to be performed' 'Determine if the quadratic reduction for synthesizing reactions with at most two reactants has to be performed' ), option( lazy_negatives, ... ... @@ -308,10 +308,10 @@ compile_from_pivp(PIVP, Output) :- creates a CRN that immplements a function of time, specified by the variable "Output" of the solution of the PIVP. '), option( binomial_reduction, quadratic_reduction, reduction_methods, _Reduction, 'Determines if the binomial reduction has to be performed' 'Determines if the quadratic reduction has to be performed' ), sort_output(PIVP, Output, PIVP_sorted), compile_from_pivp(PIVP_sorted, time, Output). ... ... @@ -333,7 +333,7 @@ compile_from_pivp(PIVP, Output) :- \\begin{example} Compilation of the Hill function of order 2 as a function of time, $h(t)=t^2/(1+t^2)$ \n '). %:- biocham(option(lazy_negatives:yes)). :- biocham(option(binomial_reduction:native)). :- biocham(option(quadratic_reduction:native)). :- biocham(compile_from_pivp((0.0,d(h)/dt= 2*n^2*t;1.0,d(n)/dt= -2*n^2*t;0.0,d(t)/dt=1),h)). :- biocham(list_model). :- biocham(numerical_simulation(time:10)). % method:msbdf ... ... @@ -366,10 +366,10 @@ compile_from_pivp(PIVP, Input, Output) :- The "Input" variable must not appear in the PIVP. It is created and initialized with a parameter named "input". '), option( binomial_reduction, quadratic_reduction, reduction_methods, _Reduction, 'Determines if the binomial reduction has to be performed' 'Determines if the quadratic reduction has to be performed' ), sort_output(PIVP, Output, PIVP_sorted), format_pivp(PIVP_sorted, P, Name_list), ... ... @@ -386,10 +386,10 @@ compile_from_ode(Input, Output) :- type(Output, name), doc('Compile the current ODE system in a CRN, Input is usually "time" but could be the name of a new species, Output have to be the name of an existing variable.'), option( binomial_reduction, quadratic_reduction, reduction_methods, _Reduction, 'Determines if the binomial reduction has to be performed' 'Determines if the quadratic reduction has to be performed' ), option( lazy_negatives, ... ... @@ -416,14 +416,14 @@ compile_from_ode(Input, Output) :- \\texttt{sat_reactions} that minimizes the number of monomes. '). %:- biocham(option(lazy_negatives:yes)). :- biocham(option(binomial_reduction:sat_species)). :- biocham(option(quadratic_reduction:sat_species)). :- biocham(compile_from_pivp((0.0,d(h)/dt= 2*n^2*t;1.0,d(n)/dt= -2*n^2*t;0.0,d(t)/dt=1),x,h)). :- biocham(parameter(input=2)). :- biocham(list_model). :- biocham(numerical_simulation(time:10)). % method:msbdf :- biocham(plot(show:{h})). :- biocham(plot(show:{h}, logscale:x)). :- biocham(compile_from_pivp((0.0,d(h)/dt= 2*n^2*t;1.0,d(n)/dt= -2*n^2*t;0.0,d(t)/dt=1),x,h, binomial_reduction: sat_reactions)). :- biocham(compile_from_pivp((0.0,d(h)/dt= 2*n^2*t;1.0,d(n)/dt= -2*n^2*t;0.0,d(t)/dt=1),x,h, quadratic_reduction: sat_reactions)). :- biocham(list_model). :- doc(' \\end{example} ... ... @@ -447,7 +447,7 @@ compile_from_ode(Input, Output) :- %! main_compiler(+PIVP_list, +Name_list, +Input) % % Compile a PIVP_list, this predicate dispatch the various options of compilation % it first check if the PIVP should be reduce to a binomial form % it first check if the PIVP should be reduce to a quadratic form % then implement a lazy negation if asked % when Input is not time it then call g_to_c_PIVP/3. % and finally make a call to compile_to_biocham_model to make the final implementation ... ... @@ -465,13 +465,13 @@ main_compiler(PIVP_raw, Name_list_raw, Input):- g_to_c_PIVP(PIVP_raw, PIVP_input, 1.0), append(Name_list_raw, [Input], Name_list_input) ), ( % determine the order for binomialisation/negation ( % determine the order for quadratization/negation NegFirst = yes -> negation_step(PIVP_input, Name_list_input, PIVP_tempo, Name_list_tempo), binomialization_step(PIVP_tempo, Name_list_tempo, PIVP_final, Name_list_final) quadratization_step(PIVP_tempo, Name_list_tempo, PIVP_final, Name_list_final) ; binomialization_step(PIVP_input, Name_list_input, PIVP_tempo, Name_list_tempo), quadratization_step(PIVP_input, Name_list_input, PIVP_tempo, Name_list_tempo), negation_step(PIVP_tempo, Name_list_tempo, PIVP_final, Name_list_final) ), !, % avoid strangebacktrack effect while loading file ... ... @@ -499,8 +499,8 @@ negation_step(PIVP_input, Names_input, PIVP_output, Names_output) :- true ). binomialization_step(PIVP_input, Names_input, PIVP_output, Names_output) :- get_option(binomial_reduction, Reduction), quadratization_step(PIVP_input, Names_input, PIVP_output, Names_output) :- get_option(quadratic_reduction, Reduction), ( Reduction \= no -> ... ...
 /** A rewriting of the lazy negation module to be used with the gpac representation of a PIVP, the purpose was to be able to negate the PIVP after the binomial reduction. PIVP, the purpose was to be able to negate the PIVP after the quadratic reduction. For the record, gpac PIVP are represented as pivp_list that is: pivp_list - a list description of the PIVP used for internal computation ... ...
 ... ... @@ -30,7 +30,7 @@ else fi echo "load($1). compile_from_ode(time,$2, lazy_negatives:$LAZY, binomial_reduction:$QUADRATIZATION). compile_from_ode(time, $2, lazy_negatives:$LAZY, quadratic_reduction:$QUADRATIZATION).$WRITER(\$OUTPUT). quit." | biocham ... ...
 ... ... @@ -135,7 +135,7 @@ - gpac.pl - lazy_negation.pl - lazy_negation_gpac.pl - binomial_reduction.pl - quadratic_reduction.pl ** Synthesis from transfer functions - transfer_function.pl #** Synthesis from programs ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!