From 1f51793a2ad7ef25567bb8666dd0c45253feaa02 Mon Sep 17 00:00:00 2001
From: someone <jan@jvales.net>
Date: Tue, 5 Jun 2012 15:54:54 +0200
Subject: [PATCH] c tests + comp

---
 c.dl       | 42 +++++++++++++++++++++++++++------------
 c.test6.dl | 12 +++++------
 c.test7.dl | 18 ++++++++---------
 c.test8.dl | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 102 insertions(+), 28 deletions(-)
 create mode 100644 c.test8.dl

diff --git a/c.dl b/c.dl
index c189894..1514c01 100644
--- a/c.dl
+++ b/c.dl
@@ -1,21 +1,37 @@
 % control definition.
 % o1: psh, o2:w, o3:f, o4:s, o5:scharge
+% uns jetzt schön alle komponenten-maxima-abfragen hardcoden -.-
 
-% 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).
+% 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).
+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).
+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).
+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).
 
-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).
+% charge psh (over max)
+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).
+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).
+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).
+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).
+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).
 
-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).
 
+% 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).
 
 
diff --git a/c.test6.dl b/c.test6.dl
index 016d6a3..a55030b 100644
--- a/c.test6.dl
+++ b/c.test6.dl
@@ -1,10 +1,10 @@
 % testing a control center
-% charge pumpspeicherkraftwerkfail
+% charge pumpspeicherkraftwerk
 % 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 pumped-storage hydropower plant psh can only be used if its storage (indicated via the input i3) is not half_full.
 % 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
@@ -21,8 +21,8 @@ c(c,i1,20).
 % define control i2/L_demand to 10KW
 c(c,i2,10).
 
-% define control i3/Sstorage to empty
-c(c,i3,empty).
+% define control i3/Sstorage to half_full
+c(c,i3,half_full).
 
 % define control i4/Swind to 0
 c(c,i4,0).
@@ -35,8 +35,8 @@ expect_c(c,i1,20).
 % expecting i2 to be 10
 expect_c(c,i2,10).
 
-% expecting i3 to be empty
-expect_c(c,i3,empty).
+% expecting i3 to be half_full
+expect_c(c,i3,half_full).
 
 % expecting i4 to be 0
 expect_c(c,i4,0).
diff --git a/c.test7.dl b/c.test7.dl
index 5aa8400..78c2f53 100644
--- a/c.test7.dl
+++ b/c.test7.dl
@@ -4,7 +4,7 @@
 %   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 pumped-storage hydropower plant psh can only be used if its storage (indicated via the input i3) is not half_full.
 % 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
@@ -21,22 +21,22 @@ c(c,i1,10).
 % define control i2/L_demand to 10KW
 c(c,i2,10).
 
-% define control i3/Sstorage to empty
-c(c,i3,empty).
+% define control i3/Sstorage to full
+c(c,i3,full).
 
 % define control i4/Swind to 0
 c(c,i4,0).
 
 
 % test definition.
-% expecting i1 to be 0
-expect_c(c,i1,0).
+% expecting i1 to be 10
+expect_c(c,i1,10).
 
-% expecting i2 to be 0
-expect_c(c,i2,0).
+% expecting i2 to be 10
+expect_c(c,i2,10).
 
-% expecting i3 to be empty
-expect_c(c,i3,empty).
+% expecting i3 to be full
+expect_c(c,i3,full).
 
 % expecting i4 to be 0
 expect_c(c,i4,0).
diff --git a/c.test8.dl b/c.test8.dl
new file mode 100644
index 0000000..b40bf94
--- /dev/null
+++ b/c.test8.dl
@@ -0,0 +1,58 @@
+% testing a control center
+% charge pumpspeicherkraftwerk 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 half_full.
+% 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: min + max wind hardcoded (5-40)
+c_max(f,60). c_max(w,15). c_max(psh,20). charge_max(psh,30).
+
+control(c).
+
+% define control i1/L_cur to 50KW
+c(c,i1,50).
+
+% define control i2/L_demand to 10KW
+c(c,i2,10).
+
+% define control i3/Sstorage to half_full
+c(c,i3,half_full).
+
+% define control i4/Swind to 0
+c(c,i4,0).
+
+
+% test definition.
+% expecting i1 to be 50
+expect_c(c,i1,50).
+
+% expecting i2 to be 10
+expect_c(c,i2,10).
+
+% expecting i3 to be half_full
+expect_c(c,i3,half_full).
+
+% expecting i4 to be 0
+expect_c(c,i4,0).
+
+% and request 0KW
+expect_p(c,o1,0).
+
+% and request 0KW
+expect_p(c,o2,0).
+
+% and request 0KW
+expect_p(c,o3,0).
+
+% do we enable the switching station?
+expect_p(c,o4,2).
+
+% and we charge out pumpspeicherkraftwerk with 30KW
+expect_p(c,o5,30).
+
-- 
2.43.0