Skip to content

Commit 3d03a21

Browse files
committed
repairable node list
1 parent fa76e5c commit 3d03a21

File tree

9 files changed

+33240
-160
lines changed

9 files changed

+33240
-160
lines changed

ASP/asyBIO.lp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#include <incmode>.
22

33
#program base.
4-
4+
isRepair(U):-vertex(U), not repairable(_), not isTemp(U,_).
5+
isRepair(U):-repairable(U), not isTemp(U,_).
56
timeStep(T):-obs_vlabel(_,_,_,T).
67
vertex(V,0):-edge(V,_,0).
78
vertex(V,0):-edge(_,V,0).
@@ -103,24 +104,24 @@ repairSign1(P,U,S,t) :- repair_functionNot(N,U,_), functionNot(N,U,_),isRegulato
103104

104105

105106
%Possible repairs
106-
pos(functionOr(N,O,0),t) :- repair_g, not nonePositive(O,N,P,t),not functionOr(N,O,0),functionAnd(N,O,0),exp(P),plusinfluence(O,t),timeStep(TI).
107-
pos(functionOr(N,O,0),t) :- repair_g, nonePositive(O,N,P,t),not functionOr(N,O,0),functionAnd(N,O,0),plusinfluence(O,t).
107+
pos(functionOr(N,O,0),t) :- repair_g, not nonePositive(O,N,P,t),not functionOr(N,O,0),functionAnd(N,O,0),exp(P),plusinfluence(O,t),timeStep(TI),isRepair(O).
108+
pos(functionOr(N,O,0),t) :- repair_g, nonePositive(O,N,P,t),not functionOr(N,O,0),functionAnd(N,O,0),plusinfluence(O,t),isRepair(O).
108109

109-
pos(functionAnd(N,O,0),t) :- repair_g, noneNegative(O,N,P,t),not functionAnd(N,O,0),functionOr(N,O,0),plusinfluence(O,t).
110-
pos(functionAnd(N,O,0),t) :- repair_g, not noneNegative(O,N,P,t),not functionAnd(N,O,0),functionOr(N,O,0),exp(P),plusinfluence(O,t),timeStep(TI).
110+
pos(functionAnd(N,O,0),t) :- repair_g, noneNegative(O,N,P,t),not functionAnd(N,O,0),functionOr(N,O,0),plusinfluence(O,t),isRepair(O).
111+
pos(functionAnd(N,O,0),t) :- repair_g, not noneNegative(O,N,P,t),not functionAnd(N,O,0),functionOr(N,O,0),exp(P),plusinfluence(O,t),timeStep(TI),isRepair(O).
111112

112113
plusinfluence(O,t):- edge(V,O,_), edge(W,O,_), W!=O,W!=V,V!=O, not repair(rEdge(V,O),_), not repair(rEdge(W,O),_),not removeEdge(V,O,_),not removeEdge(W,O,_).
113114

114115

115116
:-vertex(U,_),plusinfluence(U,0), not plusinfluence(U,t).
116-
pos(rEdge(U,V),t) :- repair_e, regulator(N,U), function(N,V,_), regulator(N,W), not removeEdge(W,V,_),not isTemp(V,_), not isTemp(U,_).
117-
pos(rEdge(U,D),t) :- repair_e, regulator(N,U), regulator(N,W), function(N,V,_),isTemp(V,_),isFunction(V,D), not isTemp(D,_), not isTemp(U,_).
117+
pos(rEdge(U,V),t) :- repair_e, regulator(N,U), function(N,V,_), regulator(N,W), not removeEdge(W,V,_),not isTemp(V,_), not isTemp(U,_),isRepair(O).
118+
pos(rEdge(U,D),t) :- repair_e, regulator(N,U), regulator(N,W), function(N,V,_),isTemp(V,_),isFunction(V,D), not isTemp(D,_), not isTemp(U,_),isRepair(O).
118119
removeEdge(U,W,t):-repair(rEdge(U,D),t),regulator(N,U), function(N,W,_), isTemp(W,_),isFunction(W,D), not isTemp(D,_).
119120
removeEdge(U,D,t):-repair(rEdge(U,D),t),regulator(N,U), function(N,D,_),regulator(N,W), not removeEdge(W,D,_), not isTemp(D,_).
120121
removeEdge(W,D,t):-removeEdge(U,W,_),regulator(N,U),functionU(N,W,_),regulator(M,W),function(M,D,_),D!=U,W!=D,M!=N.
121122

122-
pos(regulator(O,V),t):- repair_i, regulator(N,V), function(N,O,_), not isTemp(O,_), not isTemp(V,_),not removeRegulator(N,V,_).
123-
pos(regulator(O,V),t):- repair_i, regulator(N,V), function(N,W,_), isTemp(W,_),isFunction(W,O), not isTemp(O,_), not isTemp(V,_),not removeRegulator(N,V,_).
123+
pos(regulator(O,V),t):- repair_i, regulator(N,V), function(N,O,_), not isTemp(O,_), not isTemp(V,_),not removeRegulator(N,V,_),isRepair(O).
124+
pos(regulator(O,V),t):- repair_i, regulator(N,V), function(N,W,_), isTemp(W,_),isFunction(W,O), not isTemp(O,_), not isTemp(V,_),not removeRegulator(N,V,_),isRepair(O).
124125

125126

126127
repaired(N,V,t):- repair(regulator(O,V),_),regulator(N,V), function(N,W,_), isTemp(W,_),isFunction(W,O), not isTemp(O,_).

ASP/configA.gringo

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
% 'n' : nand and nor
99
% 'i' : negate input of functions
1010

11-
t_a :- time == asynchronous.
12-
t_s :- time == synchronous.
13-
t_a :- time == "asynchronous".
14-
t_s :- time == "synchronous".
11+
%t_a :- time == asynchronous.
12+
%t_s :- time == synchronous.
13+
%t_a :- time == "asynchronous".
14+
%t_s :- time == "synchronous".
1515

1616
repair_e :- repair == e.
1717
repair_e :- repair == eg.

ASP/core.lp

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@ sign(0;1).
22
complement(T,S) :- sign(S),sign(T),T!=S.
33
% Make unreached vertices inputs
44
input(P,V) :- exp(P), vertex(V), not function(_,V),not edge(U,V) : edge(U,V), U != V.
5-
5+
isRepair(U):-vertex(U), not repairable(_), not isTemp(U).
6+
isRepair(U):-repairable(U), not isTemp(U).
67
timeStep(TI):-obs_vlabel(_,_,_,TI).
78
1{vlabel(P,V,1,TI);vlabel(P,V,0,TI)}1:-vertex(V),exp(P),timeStep(TI).
89
:-vlabel(P,V,S,TI), obs_vlabel(P,V,T,TI),complement(S,T).
9-
:-vlabel(P,O,0,TI),functionAnd(N,O), noneNegative(O,N,P,TI), vertex(O), exp(P), not repair(functionOr(N,O)).
10-
:-vlabel(P,O,1,TI),functionAnd(N,O), oneNegative(O,N,P,TI), vertex(O), exp(P),timeStep(TI), not repair(functionOr(N,O)).
11-
:-vlabel(P,O,0,TI),repair(functionAnd(N,O)), noneNegative(O,N,P,TI), vertex(O), exp(P), not repair(functionOr(N,O)).
12-
:-vlabel(P,O,1,TI),repair(functionAnd(N,O)), oneNegative(O,N,P,TI), vertex(O), exp(P),timeStep(TI), not repair(functionOr(N,O)).
13-
:-vlabel(P,O,1,TI),functionOr(N,O), nonePositive(O,N,P,TI), vertex(O), exp(P), not repair(functionAnd(N,O)).
14-
:-vlabel(P,O,0,TI),functionOr(N,O), onePositive(O,N,P,TI), vertex(O), exp(P),timeStep(TI), not repair(functionAnd(N,O)).
15-
:-vlabel(P,O,1,TI),repair(functionOr(N,O)), nonePositive(O,N,P,TI), vertex(O), exp(P), not repair(functionAnd(N,O)).
16-
:-vlabel(P,O,0,TI),repair(functionOr(N,O)), onePositive(O,N,P,TI), vertex(O), exp(P),timeStep(TI), not repair(functionAnd(N,O)).
17-
:-vlabel(P,O,T,TI),functionId(N,O), not repaired(N,O), regulatorSign(P,N,O,S,TI), vertex(O), exp(P),complement(S,T),not removeRegulator(N,O).
18-
:-vlabel(P,O,T,TI),repair_functionNot(N,O), regulatorSign(P,N,O,S,TI), vertex(O), exp(P),complement(S,T),not removeRegulator(N,O).
10+
a(O):-vlabel(P,O,0,TI),functionAnd(N,O), noneNegative(O,N,P,TI), vertex(O), exp(P), not repair(functionOr(N,O)).
11+
a(O):-vlabel(P,O,1,TI),functionAnd(N,O), oneNegative(O,N,P,TI), vertex(O), exp(P),timeStep(TI), not repair(functionOr(N,O)).
12+
a(O):-vlabel(P,O,0,TI),repair(functionAnd(N,O)), noneNegative(O,N,P,TI), vertex(O), exp(P), not repair(functionOr(N,O)).
13+
a(O):-vlabel(P,O,1,TI),repair(functionAnd(N,O)), oneNegative(O,N,P,TI), vertex(O), exp(P),timeStep(TI), not repair(functionOr(N,O)).
14+
a(O):-vlabel(P,O,1,TI),functionOr(N,O), nonePositive(O,N,P,TI), vertex(O), exp(P), not repair(functionAnd(N,O)).
15+
a(O):-vlabel(P,O,0,TI),functionOr(N,O), onePositive(O,N,P,TI), vertex(O), exp(P),timeStep(TI), not repair(functionAnd(N,O)).
16+
a(O):-vlabel(P,O,1,TI),repair(functionOr(N,O)), nonePositive(O,N,P,TI), vertex(O), exp(P), not repair(functionAnd(N,O)).
17+
a(O):-vlabel(P,O,0,TI),repair(functionOr(N,O)), onePositive(O,N,P,TI), vertex(O), exp(P),timeStep(TI), not repair(functionAnd(N,O)).
18+
a(O):-vlabel(P,O,T,TI),functionId(N,O), not repaired(N,O), regulatorSign(P,N,O,S,TI), vertex(O), exp(P),complement(S,T),not removeRegulator(N,O).
19+
a(O):-vlabel(P,O,T,TI),repair_functionNot(N,O), regulatorSign(P,N,O,S,TI), vertex(O), exp(P),complement(S,T),not removeRegulator(N,O).
1920
:-vertex(V), exp(P), timeStep(T),not vlabel(P,V,_,T).
20-
:-vlabel(P,O,S,TI),functionNot(N,O), regulatorSign(P,N,O,S,TI), not repair_functionNot(N,O),not removeRegulator(N,O).
21-
21+
a(O):-vlabel(P,O,S,TI),functionNot(N,O), regulatorSign(P,N,O,S,TI), not repair_functionNot(N,O),not removeRegulator(N,O).
22+
b(O):-a(O),not isTemp(O).
23+
#show b/1.
2224
%Regulators, check if edge is removed
2325
isRegulator(N,V) :- regulator(N,V), not removeRegulator(N,V), not negReapir(N,V).
2426
negReapir(N,V):- repaired(N,V), not functionNot(N,_).
@@ -47,29 +49,29 @@ function(N,V) :- functionU(N,V).
4749
functionU(N,V):- functionNot(N,V).
4850
functionU(N,V):- functionId(N,V).
4951
%Possible repairs
50-
pos(functionOr(N,O)) :- repair_g, not obs_vlabel(P,O,_,TI),not nonePositive(O,N,P,TI),not functionOr(N,O),functionAnd(N,O),exp(P),plusinfluence(O),timeStep(TI).
51-
pos(functionOr(N,O)) :- repair_g, not obs_vlabel(P,O,_,TI),nonePositive(O,N,P,TI),not functionOr(N,O),functionAnd(N,O),plusinfluence(O).
52+
pos(functionOr(N,O)) :- repair_g, not obs_vlabel(P,O,_,TI),not nonePositive(O,N,P,TI),not functionOr(N,O),functionAnd(N,O),exp(P),plusinfluence(O),timeStep(TI), isRepair(O).
53+
pos(functionOr(N,O)) :- repair_g, not obs_vlabel(P,O,_,TI),nonePositive(O,N,P,TI),not functionOr(N,O),functionAnd(N,O),plusinfluence(O), isRepair(O).
5254

53-
pos(functionOr(N,O)) :- repair_g, obs_vlabel(P,O,1,TI),not nonePositive(O,N,P,TI),not functionOr(N,O),functionAnd(N,O),exp(P),plusinfluence(O).
54-
pos(functionOr(N,O)) :- repair_g, obs_vlabel(P,O,0,TI),nonePositive(O,N,P,TI),not functionOr(N,O),functionAnd(N,O),plusinfluence(O).
55+
pos(functionOr(N,O)) :- repair_g, obs_vlabel(P,O,1,TI),not nonePositive(O,N,P,TI),not functionOr(N,O),functionAnd(N,O),exp(P),plusinfluence(O), isRepair(O).
56+
pos(functionOr(N,O)) :- repair_g, obs_vlabel(P,O,0,TI),nonePositive(O,N,P,TI),not functionOr(N,O),functionAnd(N,O),plusinfluence(O), isRepair(O).
5557

56-
pos(functionAnd(N,O)) :- repair_g, not obs_vlabel(P,O,_,TI),noneNegative(O,N,P,TI),not functionAnd(N,O),functionOr(N,O),plusinfluence(O).
57-
pos(functionAnd(N,O)) :- repair_g, not obs_vlabel(P,O,_,TI),not noneNegative(O,N,P,TI),not functionAnd(N,O),functionOr(N,O),exp(P),plusinfluence(O),timeStep(TI).
58+
pos(functionAnd(N,O)) :- repair_g, not obs_vlabel(P,O,_,TI),noneNegative(O,N,P,TI),not functionAnd(N,O),functionOr(N,O),plusinfluence(O), isRepair(O).
59+
pos(functionAnd(N,O)) :- timeStep(TI),repair_g, not obs_vlabel(P,O,_,TI),not noneNegative(O,N,P,TI),not functionAnd(N,O),functionOr(N,O),exp(P),plusinfluence(O), isRepair(O).
5860

59-
pos(functionAnd(N,O)) :- repair_g, obs_vlabel(P,O,1,TI),noneNegative(O,N,P,TI),not functionAnd(N,O),functionOr(N,O),plusinfluence(O).
60-
pos(functionAnd(N,O)) :- repair_g, obs_vlabel(P,O,0,TI),not noneNegative(O,N,P,TI),not functionAnd(N,O),functionOr(N,O),exp(P),plusinfluence(O).
61+
pos(functionAnd(N,O)) :- repair_g, obs_vlabel(P,O,1,TI),noneNegative(O,N,P,TI),not functionAnd(N,O),functionOr(N,O),plusinfluence(O), isRepair(O).
62+
pos(functionAnd(N,O)) :- repair_g, obs_vlabel(P,O,0,TI),not noneNegative(O,N,P,TI),not functionAnd(N,O),functionOr(N,O),exp(P),plusinfluence(O), isRepair(O).
6163

6264
plusinfluence(O):- edge(V,O), edge(W,O), W!=O,W!=V,V!=O, not repair(rEdge(V,O)), not repair(rEdge(W,O)),not removeEdge(V,O),not removeEdge(W,O).
6365

6466

65-
pos(rEdge(U,V)) :- repair_e, regulator(N,U), function(N,V), regulator(N,W), not removeEdge(W,V),not isTemp(V), not isTemp(U).
66-
pos(rEdge(U,D)) :- repair_e, regulator(N,U), regulator(N,W), function(N,V),isTemp(V),isFunction(V,D), not isTemp(D), not isTemp(U).
67+
pos(rEdge(U,V)) :- repair_e, regulator(N,U), function(N,V), regulator(N,W), not removeEdge(W,V),not isTemp(V), not isTemp(U), isRepair(V).
68+
pos(rEdge(U,D)) :- repair_e, regulator(N,U), regulator(N,W), function(N,V),isTemp(V),isFunction(V,D), not isTemp(D), not isTemp(U), isRepair(D).
6769
removeEdge(U,W):-repair(rEdge(U,D)),regulator(N,U), function(N,W), isTemp(W),isFunction(W,D), not isTemp(D).
6870
removeEdge(U,D):-repair(rEdge(U,D)),regulator(N,U), function(N,D),regulator(N,W), not removeEdge(W,D), not isTemp(D).
6971
removeEdge(W,D):-removeEdge(U,W),regulator(N,U),functionU(N,W),regulator(M,W),function(M,D),D!=U,W!=D,M!=N.
7072

71-
pos(regulator(O,V)):- repair_i, regulator(N,V), function(N,O), not isTemp(O), not isTemp(V),not removeRegulator(N,V).
72-
pos(regulator(O,V)):- repair_i, regulator(N,V), function(N,W), isTemp(W),isFunction(W,O), not isTemp(O), not isTemp(V),not removeRegulator(N,V).
73+
pos(regulator(O,V)):- repair_i, regulator(N,V), function(N,O), not isTemp(O), not isTemp(V),not removeRegulator(N,V), isRepair(O).
74+
pos(regulator(O,V)):- repair_i, regulator(N,V), function(N,W), isTemp(W),isFunction(W,O), not isTemp(O), not isTemp(V),not removeRegulator(N,V), isRepair(O).
7375
isFunction(W,O):-regulator(N,W),function(N,O), not isTemp(O).
7476
isFunction(W,O):-regulator(N,W),function(N,V),isTemp(V), V!=O,isFunction(V,O).
7577

@@ -87,7 +89,7 @@ edge(V,temporary(regulator(N,V))):- repaired(N,V), not functionNot(N,_).
8789
repair_functionNot(N,V):-functionNot(N,V), repaired(N,W),regulator(N,W).
8890

8991
{ repair(R) : pos(R) }.
90-
#show repair/1.
92+
%#show repair/1.
9193
vertex(V):-edge(V,_).
9294
vertex(V):-edge(_,V).
9395
isTemp(temporary(V)):-vertex(temporary(V)).

function/vertex.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ vertex::vertex() {
3838
}
3939

4040

41+

0 commit comments

Comments
 (0)