rate_independence.plt 2.3 KB
Newer Older
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
:- use_module(library(plunit)).


:- begin_tests(rate_independence).


test('fork', [true(Reason == fork('B1')), setup(max_model), cleanup(clear_model)]) :-
  command('B1 => C'),
  reaction_graph,
  get_current_graph(Id),
  \+ rate_independence:is_fork_free(Id),
  nb_getval(rate_dependence_reason, Reason).

test('synthesis', [true(Reason = synthesis(_)), setup(max_model), cleanup(clear_model)]) :-
  command('C => C + D'),
  reaction_graph,
  \+ rate_independence:is_synthesis_free,
  nb_getval(rate_dependence_reason, Reason).

test('loop', [true(Reason = loop(_)), setup(max_model), cleanup(clear_model)]) :-
  command('delete_reaction(Sum + Min => _)'),
  command('Sum + Min => B'),
  reaction_graph,
  get_current_graph(Id),
  \+ rate_independence:is_loop_free(Id),
  nb_getval(rate_dependence_reason, Reason).

test('Max', [setup(max_model), cleanup(clear_model)]) :-
  with_output_to(atom(Result), test_rate_independence),
30
  atom_concat('The model is rate independent', _, Result).
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
31

32
test('input_sinks', [
33
  fixme('Work in progress'),
34
35
36
37
38
  condition(flag(slow_test, true, true)),
  forall((expand_file_name('./library/examples/tests/rate_independence_*.bc', FileList), member(File, FileList))),
  setup((with_output_to(atom(ExpectedLong), command(load(File))), sub_string(ExpectedLong, 0, 9, _, Expected))),
  true(File-Output == File-Expected)
]) :-
39
40
41
42
  with_output_to(atom(OutputFull), command(test_rate_independence_inputs_sinks)),
  split_string(OutputFull, "\n", "\r\t ", OutputLines),
  reverse(OutputLines, [_, OutputLong | _]),
  sub_string(OutputLong, 0, 9, _, Output).
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
43

44
test('invariants', [
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
45
46
  fixme('Work in progress'),
  condition(flag(slow_test, true, true)),
47
48
49
50
51
52
53
54
  forall((expand_file_name('./library/examples/tests/rate_independence_*.bc', FileList), member(File, FileList))),
  setup((with_output_to(atom(ExpectedLong), command(load(File))), sub_string(ExpectedLong, 0, 9, _, Expected))),
  true(File-Output == File-Expected)
]) :-
  with_output_to(atom(OutputFull), command(test_rate_independence_invariants)),
  split_string(OutputFull, "\n", "\r\t ", [OutputLong | _]),
  sub_string(OutputLong, 0, 9, _, Output).

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
55
56
57
58
59
60
61
62
63
64
:- end_tests(rate_independence).

max_model :-
  clear_model,
  command('A => A1 + A2'),
  command('B => B1 + B2'),
  command('A1 => Sum'),
  command('B1 => Sum'),
  command('A2 + B2 => Min'),
  command('Sum + Min => _').