2 % o1: psh, o2:w, o3:f, o4:s, o5:scharge
3 % und jetzt alle komponenten-maxima-abfragen schön hardcoden -.-
5 %windfail: returns c_max(w) if the wind is good, 0 otherwise.
6 c_max_w(Wind,WM) :- c_max(w,WMAX), Wind >= 5, Wind <= 40, WM = WMAX, #int(WM), #int(WMAX), #int(Wind).
7 c_max_w(Wind,WM) :- Wind < 5, WM = 0, #int(WM), #int(WMAX), #int(Wind).
8 c_max_w(Wind,WM) :- Wind > 40, WM = 0, #int(WM), #int(WMAX), #int(Wind).
10 %oow: out of water exception: returns c_max(psh) if the waterstate is good, 0 otherwise.
11 c_max_p(State,PM) :- c_max(psh,PMAX), State = full, PM = PMAX, #int(PM), #int(PMAX).
12 c_max_p(State,PM) :- c_max(psh,PMAX), State = half_full, PM = PMAX, #int(PM), #int(PMAX).
13 c_max_p(State,PM) :- State = empty, PM = 0, #int(PM).
16 p(C,o1,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i3,full), Idem <= Icur, OP = 0, #int(OP).
17 p(C,o2,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i3,full), Idem <= Icur, OP = 0, #int(OP).
18 p(C,o3,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i3,full), Idem <= Icur, OP = 0, #int(OP).
19 p(C,o4,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i3,full), Idem <= Icur, OP = 0, #int(OP).
20 p(C,o5,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i3,full), Idem <= Icur, OP = 0, #int(OP).
22 % charge psh (over max)
23 p(C,o1,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), not c(C,i3,full), charge_max(psh,IMAXpc), Idem <= Icur, OP = 0, #int(OP).
24 p(C,o2,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), not c(C,i3,full), charge_max(psh,IMAXpc), Idem <= Icur, OP = 0, #int(OP).
25 p(C,o3,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), not c(C,i3,full), charge_max(psh,IMAXpc), Idem <= Icur, OP = 0, #int(OP).
26 p(C,o4,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), not c(C,i3,full), charge_max(psh,IMAXpc), Idem <= Icur, OP = 2, #int(OP).
27 p(C,o5,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), not c(C,i3,full), charge_max(psh,IMAXpc), Idem <= Icur, Tava = Icur - Idem, Tava <= IMAXpc, OP = Tava, #int(OP).
28 p(C,o5,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), not c(C,i3,full), charge_max(psh,IMAXpc), Idem <= Icur, Tava = Icur - Idem, Tava > IMAXpc, OP = IMAXpc, #int(OP).
31 p(C,o4,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), Idem > Icur, OP = 1, #int(OP).
32 p(C,o5,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), Idem > Icur, OP = 0, #int(OP).
35 % Treq = to request is <= c_max(w). request o2 = Treq.
36 p(C,o2,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i4,Iw), Idem > Icur, Treq = Idem - Icur, c_max_w(Iw,WMAX), Treq <= WMAX, OP = Treq, #int(OP).
37 p(C,o1,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i4,Iw), Idem > Icur, Treq = Idem - Icur, c_max_w(Iw,WMAX), Treq <= WMAX, OP = 0, #int(OP).
38 p(C,o3,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i4,Iw), Idem > Icur, Treq = Idem - Icur, c_max_w(Iw,WMAX), Treq <= WMAX, OP = 0, #int(OP).
40 % Treq > c_max(w). request o2 = c_max(w) + other
41 p(C,o2,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i4,Iw), Idem > Icur, Treq = Idem - Icur, c_max_w(Iw,WMAX), Treq > WMAX, OP = WMAX, #int(OP).
43 p(C,o1,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i4,Iw), Idem > Icur, Treq = Idem - Icur, c_max_w(Iw,WMAX), Treq > WMAX, Treqw = Treq - WMAX,
44 c(C,i3,IS), c_max_p(IS,PMAX), Treqw <= PMAX, OP = Treqw, #int(OP).
46 p(C,o3,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i4,Iw), Idem > Icur, Treq = Idem - Icur, c_max_w(Iw,WMAX), Treq > WMAX, Treqw = Treq - WMAX,
47 c(C,i3,IS), c_max_p(IS,PMAX), Treqw <= PMAX, OP = 0, #int(OP).
49 % Treq > c_max(w) + c_max(psh).
50 p(C,o1,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i4,Iw), Idem > Icur, Treq = Idem - Icur, c_max_w(Iw,WMAX), Treq > WMAX, Treqw = Treq - WMAX,
51 c(C,i3,IS), c_max_p(IS,PMAX), Treqw > PMAX, OP = PMAX, #int(OP).
53 p(C,o3,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i4,Iw), Idem > Icur, Treq = Idem - Icur, c_max_w(Iw,WMAX), Treq > WMAX, Treqw = Treq - WMAX,
54 c(C,i3,IS), c_max_p(IS,PMAX), Treqw > PMAX, Treqwp = Treqw - PMAX, c_max(f,FMAX), Treqwp <= FMAX, OP = Treqwp, #int(OP).
56 % Treq hopelessly over our capacity
57 p(C,o3,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i4,Iw), Idem > Icur, Treq = Idem - Icur, c_max_w(Iw,WMAX), Treq > WMAX, Treqw = Treq - WMAX,
58 c(C,i3,IS), c_max_p(IS,PMAX), Treqw > PMAX, Treqwp = Treqw - PMAX, c_max(f,FMAX), Treqwp > FMAX, OP = FMAX, #int(OP).