From df490a593762f5745ef99ca327546859a0b24351 Mon Sep 17 00:00:00 2001 From: someone Date: Tue, 5 Jun 2012 16:30:53 +0200 Subject: [PATCH] c new test: over all bounds --- c.dl | 43 ++++++++++++++++++++++++++-------------- c.test9.dl | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ chk.sh | 2 +- test.sh | 2 +- 4 files changed, 88 insertions(+), 17 deletions(-) create mode 100644 c.test9.dl diff --git a/c.dl b/c.dl index 1514c01..aac62da 100644 --- a/c.dl +++ b/c.dl @@ -1,6 +1,6 @@ % control definition. % o1: psh, o2:w, o3:f, o4:s, o5:scharge -% uns jetzt schön alle komponenten-maxima-abfragen hardcoden -.- +% und jetzt alle komponenten-maxima-abfragen schön hardcoden -.- % 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). @@ -17,21 +17,34 @@ p(C,o4,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), not c(C,i3,full 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). 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). +% Produce energy. +p(C,o4,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), Idem > Icur, OP = 1, #int(OP). +p(C,o5,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), Idem > Icur, OP = 0, #int(OP). % Treq = to request is <= c_max(w). request o2 = Treq. -%p(C,o1,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i3,Istor), c(C,i4,Iwind), Treq = Idem - Icur, -% c_max(w,WMAX), Iwind >= 5, Iwind <= 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,i3,Istor), c(C,i4,Iwind), Treq = Idem - Icur, -% c_max(w,WMAX), Iwind >= 5, Iwind <= 40, Treq <= WMAX, OP = Treq, #int(OP). -% -%p(C,o3,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i3,Istor), c(C,i4,Iwind), Treq = Idem - Icur, -% c_max(w,WMAX), Iwind >= 5, Iwind <= 40, Treq <= WMAX, OP = 0, #int(OP). -% -%p(C,o4,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i3,Istor), c(C,i4,Iwind), Treq = Idem - Icur, -% c_max(w,WMAX), Iwind >= 5, Iwind <= 40, Treq <= WMAX, OP = 1, #int(OP). -% -%p(C,o5,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i3,Istor), c(C,i4,Iwind), Treq = Idem - Icur, -% c_max(w,WMAX), Iwind >= 5, Iwind <= 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), 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), 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), Treq = Idem - Icur, c_max(w,WMAX), Iw >= 5, Iw <= 40, 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), Treq = Idem - Icur, c_max(w,WMAX), Iw >= 5, Iw <= 40, 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), 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,o3,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i4,Iw), 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). + +% 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), 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,o3,OP) :- not ab(C), control(C), c(C,i1,Icur), c(C,i2,Idem), c(C,i4,Iw), 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). + +% 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), 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). diff --git a/c.test9.dl b/c.test9.dl new file mode 100644 index 0000000..fd140cd --- /dev/null +++ b/c.test9.dl @@ -0,0 +1,58 @@ +% testing a control center +% normal operation: windmill + pumpspeicherkraftwerk + fuel plant over MAX +% In case that L cur < L demand, the control station uses plants with the following priority with respect to their maximal capacity C x with x 2 fpsh; w; fg: +% 1. windmill w, +% 2. pumped-storage hydropower plant psh, and +% 3. fossil-fuel power station f. +% The pumped-storage hydropower plant psh can only be used if its storage (indicated via the input i3) is not empty. +% The windmill w can only be used under certain circumstances; namely, when the wind speed (which is received on input i4) is between 5 and 40. + +% our plant's types +caloric_plant(f). windmill(w). storage_plant(psh). + +% our plant's max values +c_max(f,60). c_max(w,15). c_max(psh,20). charge_max(psh,30). + +control(c). + +% define control i1/L_cur to 10KW +c(c,i1,10). + +% define control i2/L_demand to 110KW +c(c,i2,110). + +% define control i3/Sstorage to half_full +c(c,i3,half_full). + +% define control i4/Swind to 10 +c(c,i4,10). + + +% test definition. +% expecting i1 to be 10 +expect_c(c,i1,10). + +% expecting i2 to be 110 +expect_c(c,i2,110). + +% expecting i3 to be half_full +expect_c(c,i3,half_full). + +% expecting i4 to be 10 +expect_c(c,i4,10). + +% and request 20KW +expect_p(c,o1,20). + +% and request 15KW +expect_p(c,o2,15). + +% and request 15KW +expect_p(c,o3,60). + +% do we enable the switching station? +expect_p(c,o4,1). + +% and we charge out pumpspeicherkraftwerk with 0KW +expect_p(c,o5,0). + diff --git a/chk.sh b/chk.sh index 99e2209..958cfb4 100755 --- a/chk.sh +++ b/chk.sh @@ -13,7 +13,7 @@ fi for component in $(echo ${COMPONENTS}) ; do for test in $(echo ${TESTS}) ; do if [ -e "${component}.test${test}.dl" ]; then - ret=`./dlv -silent ${component}.dl ${component}.test${test}.dl component.tester.dl -N=80 | egrep "UNCOMPUTED|UNEXPECTED|DUPLICATED"` + ret=`./dlv -silent ${component}.dl ${component}.test${test}.dl component.tester.dl -N=120 | egrep "UNCOMPUTED|UNEXPECTED|DUPLICATED"` if [[ $? != 1 ]]; then echo "Component ${component} failed at test ${test}:" echo ${ret} diff --git a/test.sh b/test.sh index af6e673..e864502 100755 --- a/test.sh +++ b/test.sh @@ -14,7 +14,7 @@ for component in $(echo ${COMPONENTS}) ; do for test in $(echo ${TESTS}) ; do if [ -e "${component}.test${test}.dl" ]; then echo "Running test ${test}:" - ./dlv -silent ${component}.dl ${component}.test${test}.dl component.tester.dl -N=80 + ./dlv -silent ${component}.dl ${component}.test${test}.dl component.tester.dl -N=120 fi done echo "" -- 2.43.0