Commit 0c53ef28 authored by Mathieu Hemery's avatar Mathieu Hemery
Browse files

Seems to work, now go for testing it

parent 46db3d2b
...@@ -1381,22 +1381,14 @@ normalize_expression(-Expr, ListVar, NExpr) :- !, ...@@ -1381,22 +1381,14 @@ normalize_expression(-Expr, ListVar, NExpr) :- !,
normalize_expression(TExpr, ListVar, NExpr). normalize_expression(TExpr, ListVar, NExpr).
normalize_expression(Term, ListVar, NTerm) :- normalize_expression(Term, ListVar, NTerm) :-
normalize_term(Term, ListVar, NTerm). normalize_term(Term, ListVar, TermTempo),
simplify(TermTempo, NTerm).
normalize_term(TermRaw, ListVar, NewTerm) :- normalize_term(Term, ListVar, NewTerm) :-
simplify(TermRaw, Term), filter_denominator(Term, Numerator, Denominator),
( filter_other(Numerator, ListVar, Numbers, Parameters, Variables),
Term =.. [-, TermP] rewrite_term(Numbers, Parameters, Variables, Denominator, NewTerm).
->
filter_denominator(TermP, Numerator, Denominator),
filter_other(Numerator, ListVar, Numbers, Parameters, Variables),
rewrite_term([-1|Numbers], Parameters, Variables, Denominator, NewTerm)
;
filter_denominator(Term, Numerator, Denominator),
filter_other(Numerator, ListVar, Numbers, Parameters, Variables),
rewrite_term(Numbers, Parameters, Variables, Denominator, NewTerm)
).
%! filter_denominator(Term, Numerator, Denominator) %! filter_denominator(Term, Numerator, Denominator)
...@@ -1414,10 +1406,17 @@ filter_denominator(Term*X^N, Num, [NTerm|Den]) :- ...@@ -1414,10 +1406,17 @@ filter_denominator(Term*X^N, Num, [NTerm|Den]) :-
filter_denominator(Term*X^N, [X^N|Num], Den) :- !, filter_denominator(Term*X^N, [X^N|Num], Den) :- !,
number(N), N>0, !, number(N), N>0, !,
filter_denominator(Term, Num, Den). filter_denominator(Term, Num, Den).
filter_denominator(Term*X, [X|Num], Den) :- !,
filter_denominator(Term, Num, Den). filter_denominator(T1*T2, Num12, Den12) :- !,
filter_denominator(T1, Num1, Den1),
filter_denominator(T2, Num2, Den2),
append(Num1, Num2, Num12),
append(Den1, Den2, Den12).
filter_denominator(Term/X, Num, [X|Den]) :- !, filter_denominator(Term/X, Num, [X|Den]) :- !,
filter_denominator(Term, Num, Den). filter_denominator(Term, Num, Den).
filter_denominator(X^N, [], [NTerm]) :- !, filter_denominator(X^N, [], [NTerm]) :- !,
number(N), N<0, !, number(N), N<0, !,
Nm is -N, Nm is -N,
......
...@@ -109,7 +109,7 @@ test( ...@@ -109,7 +109,7 @@ test(
clear_model, clear_model,
with_current_ode_system(( with_current_ode_system((
add_ode(d(x)/dt = (1*(k9*k1*k2) + (-1)*(k9*k3*x1) + (-1)*(k9*k8*x*x/(x+k7)))/k9), add_ode(d(x)/dt = (1*(k9*k1*k2) + (-1)*(k9*k3*x1) + (-1)*(k9*k8*x*x/(x+k7)))/k9),
normalize_ode([d(x)/dt= k2*k1+ -1*x1*k3+ -1*x^2*k8/(x+k7)]) normalize_ode([d(x)/dt=k1*k2+ - (k3*x1)+ -1*k8*x^2/(x+k7)])
)). )).
test( test(
...@@ -117,7 +117,7 @@ test( ...@@ -117,7 +117,7 @@ test(
clear_model, clear_model,
with_current_ode_system(( with_current_ode_system((
add_ode(d(x)/dt = k7+ -1*k8*x + -1*k9*x/(x+k1)), add_ode(d(x)/dt = k7+ -1*k8*x + -1*k9*x/(x+k1)),
normalize_ode([d(x)/dt = k7+ -1*k8*x+ -1*k9*x/(x+k1)]) normalize_ode([d(x)/dt=k7+ - (k8*x)+ -1*k9*x/(x+k1)])
)). )).
:- end_tests(ode). :- end_tests(ode).
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