Commit c6039c01 authored by SOLIMAN Sylvain's avatar SOLIMAN Sylvain

first working invariant code

parent 684a5826
......@@ -23,10 +23,12 @@ cpu_time(T) :-
% find the complete set of minimal P-invariants
find_all_pinvar :-
biocham_command,
find_pinvar(sup).
find_pinvar :-
biocham_command,
find_pinvar(4).
......@@ -35,10 +37,11 @@ find_pinvar :-
% find a set of minimal P-invariants with a given max value
find_pinvar(ForcedMax) :-
find_invar_aux(ForcedMax, 'place', 'transition', '#=').
find_invar_aux(ForcedMax, 'is_place', 'is_transition', '#=').
find_invar_aux(ForcedMax, Type, OtherType, Operator) :-
reaction_graph,
cpu_time(Time1),
findall(
(Ins, Outs),
......@@ -81,6 +84,31 @@ find_invar_aux(ForcedMax, Type, OtherType, Operator) :-
format_debug(3, "Time: ~w ms~n", [Time]).
arc(A, B, C) :-
get_current_graph(GraphId),
item([parent: GraphId, item: (A -> B)]),
(
get_attribute(A -> B, stoichiometry: C)
->
true
;
C = 1
).
is_type(P, Type) :-
get_current_graph(GraphId),
item([parent: GraphId, item: P, kind: vertex]),
get_attribute(P, kind: Type).
is_place(P) :-
is_type(P, place).
is_transition(T) :-
is_type(T, transition).
%% mark_singular(+Type)
%
% mark singular places/transitions (depending on Type)
......@@ -348,16 +376,7 @@ get_constraints([(KL, KR) | L], Vars, VarList, NVars, NVarList, MaxDomain, NMaxD
make_sum(KL, SL, Vars, VarList, Vars1, VarList1, Max1),
make_sum(KR, SR, Vars1, VarList1, Vars2, VarList2, Max2),
% set upper bound
MaxDomain3 is MaxDomain * max(max(1, Max1), max(1, Max2)),
(
% overflow :(
MaxDomain3 < 0
->
fd_max_integer(N),
MaxDomain2 = N
;
MaxDomain2 = MaxDomain3
),
MaxDomain2 is MaxDomain * max(max(1, Max1), max(1, Max2)),
Constr =.. [Operator, SL, SR],
Constr,
% add constraint X.M = O
......@@ -388,8 +407,7 @@ make_sum([(S, M)], VV, Vars, VarList, Vars1, VarList1, S) :-
Vars1 = Vars,
VarList1 = VarList
;
fd_max_integer(MaxInt),
V in 0..MaxInt,
V in 0..sup,
Vars1 = [M | Vars],
VarList1 = [V | VarList]
),
......@@ -410,8 +428,7 @@ make_sum([(S, M) | L], VV + Sum, Vars, VarList, Vars1, VarList1, Max) :-
Vars2 = Vars,
VarList2 = VarList
;
fd_max_integer(MaxInt),
V in 0..MaxInt,
V in 0..sup,
Vars2 = [M | Vars],
VarList2 = [V | VarList]
),
......@@ -616,11 +633,6 @@ update_neighbors([N-A | L], B, [M-A | LL]) :-
),
update_neighbors(L, B, LL).
% store the Petri Net
:- dynamic(place/1).
:- dynamic(transition/1).
:- dynamic(arc/3).
%% format_debug(+Level, +String, +Args)
%
% print debug messages if debug above Level
......
......@@ -51,6 +51,7 @@
- aliases.pl
*** Algebraic invariants, conservation laws and P-invariants
- conservation_laws.pl
- invariants.pl
** Simulations
*** ODE and stochastic simulations
- simplify_arithmetic.pl
......
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