rosenbrock.plt 2.84 KB
 Mathieu Hemery committed Sep 30, 2019 1 2 ``````:- use_module(rosenbrock). `````` HEMERY Mathieu committed Oct 29, 2019 3 ``````near(X, Y, Epsilon) :- `````` HEMERY Mathieu committed Nov 22, 2019 4 5 `````` (Epsilon >= abs(X-Y),!); (Error is abs(X-Y),write(Error),fail). `````` HEMERY Mathieu committed Oct 29, 2019 6 `````` `````` HEMERY Mathieu committed Nov 22, 2019 7 8 ``````check_integration_1([], _Epsilon) :- !. check_integration_1([Head|Tail], Epsilon) :- `````` HEMERY Mathieu committed Oct 29, 2019 9 `````` Head = row(T,A,B), `````` HEMERY Mathieu committed Nov 22, 2019 10 11 12 13 14 15 16 17 18 19 `````` 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). `````` HEMERY Mathieu committed Oct 29, 2019 20 `````` `````` HEMERY Mathieu committed Dec 13, 2019 21 22 23 24 25 26 27 ``````check_integration_ball([], _Epsilon) :- !. check_integration_ball([Head|Tail], Epsilon) :- Head = row(_T,_TT,X,_Y), X >= -Epsilon, check_integration_ball(Tail, Epsilon). `````` Mathieu Hemery committed Sep 30, 2019 28 29 ``````:- begin_tests(rosenbrock). `````` Mathieu Hemery committed Oct 01, 2019 30 ``````test(eva_coeff_1) :- `````` HEMERY Mathieu committed Oct 03, 2019 31 `````` nb_setval(hdid,0.01), `````` Mathieu Hemery committed Oct 01, 2019 32 33 34 35 36 37 38 39 40 `````` rosenbrock:eval_coeff(1*[0],[1.5,2.5,3.5],[-1,2], 1, R1), R1 =:= 1.5, rosenbrock:eval_coeff(2*[0] + p(1),[1.5,2.5,3.5],[-1,2], 1, R2), R2 =:= 5.0, rosenbrock:eval_coeff(t,[1.5,2.5,3.5],[-1,2], 1.23, R3), R3 =:= 1.23, rosenbrock:eval_coeff(2*[0] - p(0),[1.5,2.5,3.5],[-1,2], 1, R4), R4 =:=4.0, rosenbrock:eval_coeff(-p(1),[1.5,2.5,3.5],[-1,2], 1, R5), R5 =:= -2, rosenbrock:eval_coeff(25/[1],[1.5,2.5,3.5],[-1,2], 1, R6), R6 =:= 10, rosenbrock:eval_coeff([1]^p(1),[1.5,2.5,3.5],[-1,2], 1, R7), R7 =:= 6.25. test(eva_coeff_2) :- `````` HEMERY Mathieu committed Oct 03, 2019 41 `````` nb_setval(hdid,0.01), `````` Mathieu Hemery committed Oct 01, 2019 42 43 44 `````` rosenbrock:eval_coeff(floor(1*[0]),[1.5,2.5,3.5],[-1,2], 1, R1), R1 =:= 1, rosenbrock:eval_coeff(min([0], p(1)),[1.5,2.5,3.5],[-1,2], 1, R2), R2 =:= 1.5, rosenbrock:eval_coeff(infinity,[1.5,2.5,3.5],[-1,2], 1, R3), R3 =:= inf, `````` HEMERY Mathieu committed Oct 03, 2019 45 `````` rosenbrock:eval_coeff(random,[1.5,2.5,3.5],[-1,2], 1, _R4). `````` Mathieu Hemery committed Oct 01, 2019 46 `````` `````` HEMERY Mathieu committed Dec 10, 2019 47 ``````test(simple_integration, [setup(command(clear_model)), cleanup(command(clear_model))]) :- `````` HEMERY Mathieu committed Oct 03, 2019 48 49 `````` command(a => b), command(present(a,1.0)), `````` HEMERY Mathieu committed Oct 29, 2019 50 51 `````` command(numerical_simulation(method:rsbk)), get_table_data(D), `````` Mathieu Hemery committed Dec 04, 2019 52 `````` check_integration_1(D, 1e-5). `````` HEMERY Mathieu committed Nov 22, 2019 53 `````` `````` HEMERY Mathieu committed Dec 10, 2019 54 ``````test(cosinus_integration, [setup(command(clear_model)), cleanup(command(clear_model))]) :- `````` HEMERY Mathieu committed Nov 22, 2019 55 56 57 58 59 `````` 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), `````` Mathieu Hemery committed Dec 04, 2019 60 `````` check_integration_2(D, 1e-5). `````` HEMERY Mathieu committed Oct 03, 2019 61 `````` `````` HEMERY Mathieu committed Dec 13, 2019 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 ``````test(test_ball, [setup(command(clear_model)), cleanup(command(clear_model))]) :- command(load("library/examples/RobustMonitoring/ball.bc")), command(option(maximum_step_size:1e-2)), command(numerical_simulation(method:rsbk)), get_table_data(D), check_integration_ball(D, 1e-3). test(test_time_event, [setup(command(clear_model)), cleanup(command(clear_model))]) :- command(k*a for a => b), command(present(a,1.0)), command(parameter(k=1)), command(add_event('Time'>2, k=0)), command(add_event('Time'>=4, k=1)), command(numerical_simulation(method:rsbk, time:5)), get_table_data(D), last(D, row(T,_B,A)), near(A, exp(2-T), 1e-5). `````` Mathieu Hemery committed Sep 30, 2019 80 ``:- end_tests(rosenbrock).``