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

Add a disapointing test of rsbk :(

parent 67ebb89b
:- use_module(rosenbrock).
near(X, Y, Epsilon) :-
Epsilon >= abs(X-Y);
Error is abs(X-Y),
write(Error).
(Epsilon >= abs(X-Y),!);
(Error is abs(X-Y),write(Error),fail).
check_integration_1([]).
check_integration_1([Head|Tail]) :-
check_integration_1([], _Epsilon) :- !.
check_integration_1([Head|Tail], Epsilon) :-
Head = row(T,A,B),
Sum is A+B, near(1.0, Sum, 0.001),
Value is exp(-T), near(B, Value, 0.001),
check_integration_1(Tail).
Sum is A+B, near(1.0, Sum, Epsilon),
Value is exp(-T), near(B, Value, Epsilon),
check_integration_1(Tail, Epsilon).
check_integration_2([], _Epsilon) :- !.
check_integration_2([Head|Tail], Epsilon) :-
Head = row(T,Cos,Sin),
ValueC is cos(T), near(ValueC, Cos, Epsilon),
ValueS is sin(T), near(ValueS, Sin, Epsilon),
check_integration_2(Tail, Epsilon).
:- begin_tests(rosenbrock).
......@@ -31,11 +37,19 @@ test(eva_coeff_2) :-
rosenbrock:eval_coeff(infinity,[1.5,2.5,3.5],[-1,2], 1, R3), R3 =:= inf,
rosenbrock:eval_coeff(random,[1.5,2.5,3.5],[-1,2], 1, _R4).
test(simple_integration) :-
test(simple_integration, [cleanup(command(clear_model))]) :-
command(a => b),
command(present(a,1.0)),
command(numerical_simulation(method:rsbk)),
get_table_data(D),
check_integration_1(D).
check_integration_1(D, 1e-3).
test(cosinus_integration, [cleanup(command(clear_model))]) :-
command(1.0*a for "_" => b),
command(-1.0*b for "_" => a),
command(present(a,1.0)),
command(numerical_simulation(method:rsbk)),
get_table_data(D),
check_integration_2(D, 1e-3).
:- end_tests(rosenbrock).
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