From 8b9c056d78933b5e046c8edd983a299f5a98a211 Mon Sep 17 00:00:00 2001 From: someone Date: Tue, 5 Jun 2012 17:20:19 +0200 Subject: [PATCH] controller --- c.dl | 56 ++++++++++++++++++++++++-------------------------------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/c.dl b/c.dl index db7db55..2e0cf92 100644 --- a/c.dl +++ b/c.dl @@ -2,6 +2,16 @@ % o1: psh, o2:w, o3:f, o4:s, o5:scharge % und jetzt alle komponenten-maxima-abfragen schön hardcoden -.- +%windfail: returns c_max(w) if the wind is good, 0 otherwise. +c_max_w(Wind,WM) :- c_max(w,WMAX), Wind >= 5, Wind <= 40, WM = WMAX, #int(WM), #int(WMAX), #int(Wind). +c_max_w(Wind,WM) :- Wind < 5, WM = 0, #int(WM), #int(WMAX), #int(Wind). +c_max_w(Wind,WM) :- Wind > 40, WM = 0, #int(WM), #int(WMAX), #int(Wind). + +%oow: out of water exception: returns c_max(psh) if the waterstate is good, 0 otherwise. +c_max_p(State,PM) :- c_max(psh,PMAX), State = full, PM = PMAX, #int(PM), #int(PMAX). +c_max_p(State,PM) :- c_max(psh,PMAX), State = half_full, PM = PMAX, #int(PM), #int(PMAX). +c_max_p(State,PM) :- State = empty, PM = 0, #int(PM). + % noop 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). 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). @@ -23,45 +33,27 @@ p(C,o5,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), Idem > Icur, OP % Treq = to request is <= c_max(w). request o2 = Treq. -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,WMAX), Iw >= 5, Iw <= 40, Treq <= WMAX, OP = Treq, #int(OP). -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,WMAX), Iw >= 5, Iw <= 40, Treq <= WMAX, OP = 0, #int(OP). -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,WMAX), Iw >= 5, Iw <= 40, Treq <= WMAX, OP = 0, #int(OP). +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). +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). +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). % Treq > c_max(w). request o2 = c_max(w) + other -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,WMAX), Iw >= 5, Iw <= 40, Treq > WMAX, OP = WMAX, #int(OP). +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). -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,WMAX), Iw >= 5, Iw <= 40, Treq > WMAX, Treqw = Treq - WMAX, - not c(C,i3,empty), c_max(psh,PMAX), Treqw <= PMAX, OP = Treqw, #int(OP). +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, + c(C,i3,IS), c_max_p(IS,PMAX), Treqw <= PMAX, OP = Treqw, #int(OP). -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,WMAX), Iw >= 5, Iw <= 40, Treq > WMAX, Treqw = Treq - WMAX, - not c(C,i3,empty), c_max(psh,PMAX), Treqw <= PMAX, OP = 0, #int(OP). +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, + c(C,i3,IS), c_max_p(IS,PMAX), Treqw <= PMAX, OP = 0, #int(OP). % Treq > c_max(w) + c_max(psh). -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,WMAX), Iw >= 5, Iw <= 40, Treq > WMAX, Treqw = Treq - WMAX, - not c(C,i3,empty), c_max(psh,PMAX), Treqw > PMAX, OP = PMAX, #int(OP). +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, + c(C,i3,IS), c_max_p(IS,PMAX), Treqw > PMAX, OP = PMAX, #int(OP). -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,WMAX), Iw >= 5, Iw <= 40, Treq > WMAX, Treqw = Treq - WMAX, - not c(C,i3,empty), c_max(psh,PMAX), Treqw > PMAX, Treqwp = Treqw - PMAX, c_max(f,FMAX), Treqwp <= FMAX, OP = Treqwp, #int(OP). +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, + c(C,i3,IS), c_max_p(IS,PMAX), Treqw > PMAX, Treqwp = Treqw - PMAX, c_max(f,FMAX), Treqwp <= FMAX, OP = Treqwp, #int(OP). % Treq hopelessly over our capacity -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,WMAX), Iw >= 5, Iw <= 40, Treq > WMAX, Treqw = Treq - WMAX, - not c(C,i3,empty), c_max(psh,PMAX), Treqw > PMAX, Treqwp = Treqw - PMAX, c_max(f,FMAX), Treqwp > FMAX, OP = FMAX, #int(OP). - - -%windfail -%p(C,o2,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i4,Iw), Idem > Icur, not Iw >= 5, not Iw <= 40, OP = 0, #int(OP). - -%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, not Iw >= 5, not Iw <= 40, -% not c(C,i3,empty), c_max(psh,PMAX), Treq <= PMAX, OP = Treq, #int(OP). - -%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, not Iw >= 5, not Iw <= 40, -% not c(C,i3,empty), c_max(psh,PMAX), Treq <= PMAX, OP = 0, #int(OP). - - - - -%windfail -c_max_w(Wind,WM) :- c_max(w,WMAX), Wind >= 5, Wind <= 40, WM = WMAX, #int(WM), #int(WMAX), #int(Wind). -c_max_w(Wind,WM) :- c_max(w,WMAX), not Wind >= 5, not Wind <= 40, WM = 0, #int(WM), #int(WMAX), #int(Wind). - +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, + c(C,i3,IS), c_max_p(IS,PMAX), Treqw > PMAX, Treqwp = Treqw - PMAX, c_max(f,FMAX), Treqwp > FMAX, OP = FMAX, #int(OP). -- 2.43.0