Commit ed455f44 authored by Thierry Martinez's avatar Thierry Martinez

list_model shows initial state

parent abedb06f
......@@ -83,6 +83,11 @@ is_influence_model :-
check_influence_model :-
devdoc('
succeeds if the current model is an influence model
(i.e., does not contain any reaction rules)
and throws an exception otherwise.
'),
(
is_influence_model
->
......@@ -98,9 +103,10 @@ list_model_influences :-
(auxiliary predicate of list_model).
'),
\+ (
item([no_inheritance, kind: influence, item: Influence]),
item([no_inheritance, kind: influence, id: Id, item: Influence]),
\+ (
format('~w.\n', [Influence])
print_influence(Id, Influence),
write('.\n')
)
).
......
:- module(
initial_state,
[
get_initial_state/2,
get_initial_concentration/2,
% Commands
list_initial_state/0,
clear_initial_state/0,
present/1,
......@@ -10,48 +9,16 @@
absent/1,
undefined/1,
make_absent_not_present/0,
make_present_not_absent/0
make_present_not_absent/0,
% Public API
get_initial_state/2,
get_initial_concentration/2,
list_model_initial_state/0
]
).
get_initial_state(Object, State) :-
(
item([kind: initial_state, key: Object, item: Item])
->
(
Item = present(Object)
->
State = present(1)
;
Item = present(Object, Concentration)
->
(
Concentration = 0
->
State = absent
;
State = present(Concentration)
)
;
Item = absent(Object)
->
State = absent
)
;
State = undefined
).
get_initial_concentration(Object, Concentration) :-
get_initial_state(Object, State),
(
State = present(Concentration)
->
true
;
Concentration = 0
).
:- devdoc('\\section{Commands}').
list_initial_state :-
......@@ -99,16 +66,6 @@ absent(ObjectSet) :-
set_state(ObjectSet, Object, absent(Object)).
set_state(ObjectSet, Object, State) :-
\+ (
member(Object, ObjectSet),
\+ (
undefined_object(Object),
add_item([kind: initial_state, key: Object, item: State])
)
).
undefined(ObjectSet) :-
biocham_command,
type(ObjectSet, {object}),
......@@ -123,16 +80,6 @@ undefined(ObjectSet) :-
).
undefined_object(Object) :-
(
item([kind: initial_state, key: Object, id: Id])
->
delete_item(Id)
;
true
).
make_present_not_absent :-
biocham_command,
doc('
......@@ -163,5 +110,84 @@ make_absent_not_present :-
).
:- devdoc('\\section{Public API}').
get_initial_state(Object, State) :-
(
item([kind: initial_state, key: Object, item: Item])
->
(
Item = present(Object)
->
State = present(1)
;
Item = present(Object, Concentration)
->
(
Concentration = 0
->
State = absent
;
State = present(Concentration)
)
;
Item = absent(Object)
->
State = absent
)
;
State = undefined
).
get_initial_concentration(Object, Concentration) :-
get_initial_state(Object, State),
(
State = present(Concentration)
->
true
;
Concentration = 0
).
list_model_initial_state :-
devdoc('
lists the initial state in a loadable syntax
(auxiliary predicate of list_model).
'),
\+ (
item([no_inheritance, kind: initial_state, item: InitialState]),
\+ (
format('~w.\n', [InitialState])
)
).
:- devdoc('\\section{Private predicates}').
set_state(ObjectSet, Object, State) :-
\+ (
member(Object, ObjectSet),
\+ (
undefined_object(Object),
add_item([kind: initial_state, key: Object, item: State])
)
).
undefined_object(Object) :-
(
item([kind: initial_state, key: Object, id: Id])
->
delete_item(Id)
;
true
).
defined(Object) :-
once(item([kind: initial_state, key: Object])).
......@@ -195,6 +195,7 @@ list_model :-
->
list_model_influences
),
list_model_initial_state,
list_model_parameters,
list_model_functions.
......
......@@ -155,7 +155,6 @@ list_ode :-
'),
biocham_silent(clear_model),
biocham(a => b),
biocham(ode_system),
biocham(list_ode),
doc('
\\end{example}
......
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