more indexing op [] tests

more indexing op [] tests

:- use_module(library(debug)).
:- use_module(library(plunit)).

:- use_module(library(lists)).
:- use_module(library(assoc)).

:- use_module('../lib/classad_parser.pl').
:- use_module('../lib/classad_eval.pl').

:- begin_tests(classad_eval_ut).

test('error 1') :-
    parse("[a = error;]", C),
    eval(a, C, R),
    R == error.

test('undefined 1') :-
    parse("[a = undefined;]", C),
    eval(a, C, R),
    R == undefined.

test('true 1') :-
    parse("[a = true;]", C),
    eval(a, C, R),
    R == true.

test('false 1') :-
    parse("[a = false;]", C),
    eval(a, C, R),
    R == false.

test('number 1') :-
    parse("[a = 0;]", C),
    eval(a, C, R),
    R == 0.

test('string 1') :-
    parse("[a = \"fred and wilma\";]", C),
    eval(a, C, R),
    R == '[str]'('fred and wilma').

test('classad 1') :-
    parse("[a = [b=0;];]", C),
    eval(a, C, R),
    functor(R,'[classad]',1),
    eval(b, R, R2),
    R2 == 0.

test('list 0') :-
    parse("[a = {};]", C),
    eval(a, C, R),
    R == [].

test('list 1') :-
    parse("[a = {0};]", C),
    eval(a, C, R),
    R == [0].

test('list 2') :-
    parse("[a = {0, true};]", C),
    eval(a, C, R),
    R == [0, true].

test('list 3') :-
    parse("[x = 42; a = {0, true, x};]", C),
    eval(a, C, R),
    R == [0, true, 42].

test('undefined var 1') :-
    parse("[]", C),
    eval(a, C, R),
    R == undefined.

test('select 1') :-
    parse("[a = [b=0;];]", C),
    eval(as_expr "a.b", C, R),
    R == 0.

test('select 2') :-
    parse("[a = [b=[c=42;];];]", C),
    eval(as_expr "a.b.c", C, R),
    R == 42.

test('select 3') :-
    parse("[a = [b=[c=42;];];]", C),
    eval(as_expr "a.z.c", C, R),
    R == undefined.

test('select 4') :-
    parse("[a = [z=0; b=[c=42;];];]", C),
    eval(as_expr "a.z.c", C, R),
    R == error.

test('parent 1') :-
    parse("[a = [b=parent.x; x=4;]; x = 42;]", C),
    eval(as_expr "a.b", C, R),
    R == 42.

test('parent 2') :-
    parse("[a = [b=[c=parent.parent.x; x=4;]; x=2;]; x = 42;]", C),
    eval(as_expr "a.b.c", C, R),
    R == 42.

test('parent 3') :-
    parse("[a = [b=parent.parent.x; x=4;]; x = 42;]", C),
    eval(as_expr "a.b", C, R),
    R == undefined.

test('parent 4') :-
    parse("[a = [b=parent.parent.parent.x; x=4;]; x = 42;]", C),
    eval(as_expr "a.b", C, R),
    R == undefined.

test('var context pop 1') :-
    parse("[a = [b=x;]; x = 42;]", C),
    eval(as_expr "a.b", C, R),
    R == 42.

test('var cyclic 1') :-
    parse("[a = b; b = a;]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('var cyclic 2') :-
    parse("[a = b+c; b = 1; c = 2 * d; d = a;]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('add 1') :-
    parse("[a = 1 + 2;]", C),
    eval(as_expr "a", C, R),
    R == 3.

test('add 2') :-
    parse("[a = 1 + x; x=3.0;]", C),
    eval(as_expr "a", C, R),
    R == 4.0.

test('add 3') :-
    parse("[a = 1 + x; x=3.0;]", C),
    eval(as_expr "a", C, R),
    R == 4.0.

test('add 4') :-
    parse("[a = 1 + x;]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('add 5') :-
    parse("[a = 1 + x; x = true;]", C),
    eval(as_expr "a", C, R),
    R == 2.

test('add 6') :-
    parse("[a = 1 + x; x = \"s\";]", C),
    eval(as_expr "a", C, R),
    R == error.

test('sub 1') :-
    parse("[a = 3 - 2;]", C),
    eval(as_expr "a", C, R),
    R == 1.

test('mul 1') :-
    parse("[a = 3.0 * 2;]", C),
    eval(as_expr "a", C, R),
    R == 6.0.

test('mul 2') :-
    parse("[a = 3 * 2;]", C),
    eval(as_expr "a", C, R),
    R == 6.

test('divide 1') :-
    parse("[a = 10 / 2;]", C),
    eval(as_expr "a", C, R),
    R == 5.

test('divide 2') :-
    parse("[a = 10 / 2.0;]", C),
    eval(as_expr "a", C, R),
    R == 5.0.

test('divide 3') :-
    parse("[a = 10 / 0;]", C),
    eval(as_expr "a", C, R),
    R == error.

test('divide 4') :-
    parse("[a = 10 / 0.0;]", C),
    eval(as_expr "a", C, R),
    R == error.

test('mod 1') :-
    parse("[a = 5 % 3;]", C),
    eval(as_expr "a", C, R),
    R == 2.

test('mod 2') :-
    parse("[a = 5 % -3;]", C),
    eval(as_expr "a", C, R),
    R == -1.

test('mod 3') :-
    parse("[a = -5 % 3;]", C),
    eval(as_expr "a", C, R),
    R == 1.

test('mod 4') :-
    parse("[a = -5 % -3;]", C),
    eval(as_expr "a", C, R),
    R == -2.

test('mod 5') :-
    parse("[a = 5.0 % 3;]", C),
    eval(as_expr "a", C, R),
    R == 2.0.

test('mod 6') :-
    parse("[a = 5 % -3.0;]", C),
    eval(as_expr "a", C, R),
    R == -1.0.

test('mod 7') :-
    parse("[a = -5 % 3.0;]", C),
    eval(as_expr "a", C, R),
    R == 1.0.

test('mod 8') :-
    parse("[a = -5.0 % -3;]", C),
    eval(as_expr "a", C, R),
    R == -2.0.

test('mod 9') :-
    parse("[a = 5 % 0;]", C),
    eval(as_expr "a", C, R),
    R == error.

test('mod 10') :-
    parse("[a = 5 % 0.0;]", C),
    eval(as_expr "a", C, R),
    R == error.

test('&& 1') :-
    parse("[a = true && true;]", C),
    eval(as_expr "a", C, R),
    R == true.

test('&& 2') :-
    parse("[a = false && b;]", C),
    eval(as_expr "a", C, R),
    R == false.

test('&& 3') :-
    parse("[a = 0 && \"z\";]", C),
    eval(as_expr "a", C, R),
    R == false.

test('&& 4') :-
    parse("[a = 1 && \"z\";]", C),
    eval(as_expr "a", C, R),
    R == error.

test('&& 5') :-
    parse("[a = \"z\" && false;]", C),
    eval(as_expr "a", C, R),
    R == error.

test('&& 6') :-
    parse("[a = 1.0 && b;]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('&& 7') :-
    parse("[a = b && 1.0;]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('&& 8') :-
    parse("[a = b && 0;]", C),
    eval(as_expr "a", C, R),
    R == false.

test('|| 1') :-
    parse("[a = false || false;]", C),
    eval(as_expr "a", C, R),
    R == false.

test('|| 2') :-
    parse("[a = true || b;]", C),
    eval(as_expr "a", C, R),
    R == true.

test('|| 3') :-
    parse("[a = 1 || \"z\";]", C),
    eval(as_expr "a", C, R),
    R == true.

test('|| 4') :-
    parse("[a = 0 || \"z\";]", C),
    eval(as_expr "a", C, R),
    R == error.

test('|| 5') :-
    parse("[a = \"z\" || true;]", C),
    eval(as_expr "a", C, R),
    R == error.

test('|| 6') :-
    parse("[a = 0.0 || b;]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('|| 7') :-
    parse("[a = b || 0.0;]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('|| 8') :-
    parse("[a = b || 1;]", C),
    eval(as_expr "a", C, R),
    R == true.

test('promotion 1') :-
    parse("[a = true + true]", C),
    eval(as_expr "a", C, R),
    R == 2.

test('promotion 2') :-
    parse("[a = 4.0 * true]", C),
    eval(as_expr "a", C, R),
    R == 4.0.

test('promotion 3') :-
    parse("[a = 4.0 * false]", C),
    eval(as_expr "a", C, R),
    R == 0.0.

test('! op 1') :-
    parse("[a = !true]", C),
    eval(as_expr "a", C, R),
    R == false.

test('! op 2') :-
    parse("[a = !false]", C),
    eval(as_expr "a", C, R),
    R == true.

test('! op 3') :-
    parse("[a = !0]", C),
    eval(as_expr "a", C, R),
    R == true.

test('! op 4') :-
    parse("[a = !1]", C),
    eval(as_expr "a", C, R),
    R == false.

test('! op 5') :-
    parse("[a = !\"z\"]", C),
    eval(as_expr "a", C, R),
    R == error.

test('! op 6') :-
    parse("[a = !b]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('?: op 1') :-
    parse("[a = (true) ? 2.0 : true]", C),
    eval(as_expr "a", C, R),
    R == 2.0.

test('?: op 2') :-
    parse("[a = (false) ? 2.0 : true]", C),
    eval(as_expr "a", C, R),
    R == true.

test('?: op 3') :-
    parse("[a = (b) ? 2.0 : true]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('?: op 4') :-
    parse("[a = (\"z\") ? 2.0 : true]", C),
    eval(as_expr "a", C, R),
    R == error.

test('?: op 5') :-
    parse("[r = [a = ((true) ? parent : q).z; q = [z=42]]; z=69]", C),
    eval(as_expr "r.a", C, R),
    R == 69.

test('?: op 6') :-
    parse("[r = [a = ((false) ? parent : q).z; q = [z=42]]; z=69]", C),
    eval(as_expr "r.a", C, R),
    R == 42.

test('op== 1') :-
    parse("[a = 7 == 7]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op== 2') :-
    parse("[a = 6 == 7]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op== 3') :-
    parse("[a = 7.0 == 7]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op== 4') :-
    parse("[a = \"z\" == \"z\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op== 5') :-
    parse("[a = \"a\" == \"z\"]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op== 6') :-
    parse("[a = \"z\" == 1]", C),
    eval(as_expr "a", C, R),
    R == error.

test('op== 7') :-
    parse("[a = \"z\" == \"z\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op== 8') :-
    parse("[a = \"z\" == b]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('op!= 1') :-
    parse("[a =  1 != 0]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op!= 2') :-
    parse("[a =  1 != 1.0]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op!= 3') :-
    parse("[a =  \"a\" != \"b\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op!= 4') :-
    parse("[a =  \"a\" != \"a\"]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op< 1') :-
    parse("[a =  1 < 2]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op< 2') :-
    parse("[a =  1 < 1.0]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op< 3') :-
    parse("[a =  \"a\" < \"b\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op< 4') :-
    parse("[a =  \"a\" < \"a\"]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op> 1') :-
    parse("[a =  1 > 0]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op> 2') :-
    parse("[a =  1 > 1.0]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op> 3') :-
    parse("[a =  \"b\" > \"a\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op> 4') :-
    parse("[a =  \"a\" > \"a\"]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op<= 1') :-
    parse("[a =  1 <= 2]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op<= 2') :-
    parse("[a =  1 <= 1.0]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op<= 3') :-
    parse("[a =  2 <= 1.0]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op<= 4') :-
    parse("[a =  \"a\" <= \"b\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op<= 5') :-
    parse("[a =  \"a\" <= \"a\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op<= 6') :-
    parse("[a =  \"b\" <= \"a\"]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op>= 1') :-
    parse("[a =  1 >= 2]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op>= 2') :-
    parse("[a =  1 >= 1.0]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op>= 3') :-
    parse("[a =  2 >= 1.0]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op>= 4') :-
    parse("[a =  \"a\" >= \"b\"]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op>= 5') :-
    parse("[a =  \"a\" >= \"a\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op>= 6') :-
    parse("[a =  \"b\" >= \"a\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op=?= 1') :-
    parse("[a = 1 =?= 1]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op=?= 2') :-
    parse("[a = 1 =?= b]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op=?= 3') :-
    parse("[a = 1 =?= 2]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op=!= 1') :-
    parse("[a = 1 =!= 1]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op=!= 2') :-
    parse("[a = 1 =!= b]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op=!= 3') :-
    parse("[a = 1 =!= 2]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op[] 1') :-
    parse("[a = {1}[0]]", C),
    eval(as_expr "a", C, R),
    R == 1.

test('op[] 2') :-
    parse("[a = [z=42][\"z\"]; z=69]", C),
    eval(as_expr "a", C, R),
    R == 42.

test('op[] 3') :-
    parse("[a = {1}[3]]", C),
    eval(as_expr "a", C, R),
    R == error.

test('op[] 4') :-
    parse("[a = {[z=42]}[\"z\"]; z=69]", C),
    eval(as_expr "a", C, R),
    R == [42].

test('op[] 5') :-
    parse("[a = {}[\"z\"]; z=69]", C),
    eval(as_expr "a", C, R),
    R == [].

test('op[] 6') :-
    parse("[a = {1}[\"z\"]]", C),
    eval(as_expr "a", C, R),
    R == [error].

test('op[] 7') :-
    parse("[a = {[x=1]}[\"z\"]]", C),
    eval(as_expr "a", C, R),
    R == [undefined].

test('op[] 8') :-
    parse("[a = {}[0]]", C),
    eval(as_expr "a", C, R),
    R == error.

test('op[] 9') :-
    parse("[a = {0}[-1]]", C),
    eval(as_expr "a", C, R),
    R == error.

test('op[] 10') :-
    parse("[a = b[0]]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('op[] 11') :-
    parse("[a = {1}[b]]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('op[] 12') :-
    parse("[a = {{3},{4}}[1][0]]", C),
    eval(as_expr "a", C, R),
    R == 4.

test('op[] 13') :-
    parse("[a = [b=[c=55];c=44]; c=33; d=a[\"b\"][\"c\"]]", C),
    eval(as_expr "d", C, R),
    R == 55.

test('op[] 14') :-
    parse("[a = [b=[c=parent.c];c=44]; c=33; d=a[\"b\"][\"c\"]]", C),
    eval(as_expr "d", C, R),
    R == 44.

test('op[] 15') :-
    parse("[a = [b=[c=parent.c];c=44]; c=33; d=a[\"parent\"][\"c\"]]", C),
    eval(as_expr "d", C, R),
    R == 33.

test('op[] 16') :-
    parse("[a = {0,[],[z=77],[z=\"zz\"]}[\"z\"]]", C),
    eval(as_expr "a", C, R),
    R == [error, undefined, 77, '[str]'(zz)].

test('op[] 17') :-
    parse("[a = {0,[],[z=77],[z=\"zz\"]}[\"z\"][2]]", C),
    eval(as_expr "a", C, R),
    R == 77.

test('op[] 18') :-
    parse("[a = {66, 88, 77}; b = [z=1]; c=a[b[\"z\"]]]", C),
    eval(as_expr "c", C, R),
    R == 88.

:- end_tests(classad_eval_ut).

:- use_module(library(debug)).
:- use_module(library(plunit)).

:- use_module(library(lists)).
:- use_module(library(assoc)).

:- use_module('../lib/classad_parser.pl').
:- use_module('../lib/classad_eval.pl').

:- begin_tests(classad_eval_ut).

test('error 1') :-
    parse("[a = error;]", C),
    eval(a, C, R),
    R == error.

test('undefined 1') :-
    parse("[a = undefined;]", C),
    eval(a, C, R),
    R == undefined.

test('true 1') :-
    parse("[a = true;]", C),
    eval(a, C, R),
    R == true.

test('false 1') :-
    parse("[a = false;]", C),
    eval(a, C, R),
    R == false.

test('number 1') :-
    parse("[a = 0;]", C),
    eval(a, C, R),
    R == 0.

test('string 1') :-
    parse("[a = \"fred and wilma\";]", C),
    eval(a, C, R),
    R == '[str]'('fred and wilma').

test('classad 1') :-
    parse("[a = [b=0;];]", C),
    eval(a, C, R),
    functor(R,'[classad]',1),
    eval(b, R, R2),
    R2 == 0.

test('list 0') :-
    parse("[a = {};]", C),
    eval(a, C, R),
    R == [].

test('list 1') :-
    parse("[a = {0};]", C),
    eval(a, C, R),
    R == [0].

test('list 2') :-
    parse("[a = {0, true};]", C),
    eval(a, C, R),
    R == [0, true].

test('list 3') :-
    parse("[x = 42; a = {0, true, x};]", C),
    eval(a, C, R),
    R == [0, true, 42].

test('undefined var 1') :-
    parse("[]", C),
    eval(a, C, R),
    R == undefined.

test('select 1') :-
    parse("[a = [b=0;];]", C),
    eval(as_expr "a.b", C, R),
    R == 0.

test('select 2') :-
    parse("[a = [b=[c=42;];];]", C),
    eval(as_expr "a.b.c", C, R),
    R == 42.

test('select 3') :-
    parse("[a = [b=[c=42;];];]", C),
    eval(as_expr "a.z.c", C, R),
    R == undefined.

test('select 4') :-
    parse("[a = [z=0; b=[c=42;];];]", C),
    eval(as_expr "a.z.c", C, R),
    R == error.

test('parent 1') :-
    parse("[a = [b=parent.x; x=4;]; x = 42;]", C),
    eval(as_expr "a.b", C, R),
    R == 42.

test('parent 2') :-
    parse("[a = [b=[c=parent.parent.x; x=4;]; x=2;]; x = 42;]", C),
    eval(as_expr "a.b.c", C, R),
    R == 42.

test('parent 3') :-
    parse("[a = [b=parent.parent.x; x=4;]; x = 42;]", C),
    eval(as_expr "a.b", C, R),
    R == undefined.

test('parent 4') :-
    parse("[a = [b=parent.parent.parent.x; x=4;]; x = 42;]", C),
    eval(as_expr "a.b", C, R),
    R == undefined.

test('var context pop 1') :-
    parse("[a = [b=x;]; x = 42;]", C),
    eval(as_expr "a.b", C, R),
    R == 42.

test('var cyclic 1') :-
    parse("[a = b; b = a;]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('var cyclic 2') :-
    parse("[a = b+c; b = 1; c = 2 * d; d = a;]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('add 1') :-
    parse("[a = 1 + 2;]", C),
    eval(as_expr "a", C, R),
    R == 3.

test('add 2') :-
    parse("[a = 1 + x; x=3.0;]", C),
    eval(as_expr "a", C, R),
    R == 4.0.

test('add 3') :-
    parse("[a = 1 + x; x=3.0;]", C),
    eval(as_expr "a", C, R),
    R == 4.0.

test('add 4') :-
    parse("[a = 1 + x;]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('add 5') :-
    parse("[a = 1 + x; x = true;]", C),
    eval(as_expr "a", C, R),
    R == 2.

test('add 6') :-
    parse("[a = 1 + x; x = \"s\";]", C),
    eval(as_expr "a", C, R),
    R == error.

test('sub 1') :-
    parse("[a = 3 - 2;]", C),
    eval(as_expr "a", C, R),
    R == 1.

test('mul 1') :-
    parse("[a = 3.0 * 2;]", C),
    eval(as_expr "a", C, R),
    R == 6.0.

test('mul 2') :-
    parse("[a = 3 * 2;]", C),
    eval(as_expr "a", C, R),
    R == 6.

test('divide 1') :-
    parse("[a = 10 / 2;]", C),
    eval(as_expr "a", C, R),
    R == 5.

test('divide 2') :-
    parse("[a = 10 / 2.0;]", C),
    eval(as_expr "a", C, R),
    R == 5.0.

test('divide 3') :-
    parse("[a = 10 / 0;]", C),
    eval(as_expr "a", C, R),
    R == error.

test('divide 4') :-
    parse("[a = 10 / 0.0;]", C),
    eval(as_expr "a", C, R),
    R == error.

test('mod 1') :-
    parse("[a = 5 % 3;]", C),
    eval(as_expr "a", C, R),
    R == 2.

test('mod 2') :-
    parse("[a = 5 % -3;]", C),
    eval(as_expr "a", C, R),
    R == -1.

test('mod 3') :-
    parse("[a = -5 % 3;]", C),
    eval(as_expr "a", C, R),
    R == 1.

test('mod 4') :-
    parse("[a = -5 % -3;]", C),
    eval(as_expr "a", C, R),
    R == -2.

test('mod 5') :-
    parse("[a = 5.0 % 3;]", C),
    eval(as_expr "a", C, R),
    R == 2.0.

test('mod 6') :-
    parse("[a = 5 % -3.0;]", C),
    eval(as_expr "a", C, R),
    R == -1.0.

test('mod 7') :-
    parse("[a = -5 % 3.0;]", C),
    eval(as_expr "a", C, R),
    R == 1.0.

test('mod 8') :-
    parse("[a = -5.0 % -3;]", C),
    eval(as_expr "a", C, R),
    R == -2.0.

test('mod 9') :-
    parse("[a = 5 % 0;]", C),
    eval(as_expr "a", C, R),
    R == error.

test('mod 10') :-
    parse("[a = 5 % 0.0;]", C),
    eval(as_expr "a", C, R),
    R == error.

test('&& 1') :-
    parse("[a = true && true;]", C),
    eval(as_expr "a", C, R),
    R == true.

test('&& 2') :-
    parse("[a = false && b;]", C),
    eval(as_expr "a", C, R),
    R == false.

test('&& 3') :-
    parse("[a = 0 && \"z\";]", C),
    eval(as_expr "a", C, R),
    R == false.

test('&& 4') :-
    parse("[a = 1 && \"z\";]", C),
    eval(as_expr "a", C, R),
    R == error.

test('&& 5') :-
    parse("[a = \"z\" && false;]", C),
    eval(as_expr "a", C, R),
    R == error.

test('&& 6') :-
    parse("[a = 1.0 && b;]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('&& 7') :-
    parse("[a = b && 1.0;]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('&& 8') :-
    parse("[a = b && 0;]", C),
    eval(as_expr "a", C, R),
    R == false.

test('|| 1') :-
    parse("[a = false || false;]", C),
    eval(as_expr "a", C, R),
    R == false.

test('|| 2') :-
    parse("[a = true || b;]", C),
    eval(as_expr "a", C, R),
    R == true.

test('|| 3') :-
    parse("[a = 1 || \"z\";]", C),
    eval(as_expr "a", C, R),
    R == true.

test('|| 4') :-
    parse("[a = 0 || \"z\";]", C),
    eval(as_expr "a", C, R),
    R == error.

test('|| 5') :-
    parse("[a = \"z\" || true;]", C),
    eval(as_expr "a", C, R),
    R == error.

test('|| 6') :-
    parse("[a = 0.0 || b;]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('|| 7') :-
    parse("[a = b || 0.0;]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('|| 8') :-
    parse("[a = b || 1;]", C),
    eval(as_expr "a", C, R),
    R == true.

test('promotion 1') :-
    parse("[a = true + true]", C),
    eval(as_expr "a", C, R),
    R == 2.

test('promotion 2') :-
    parse("[a = 4.0 * true]", C),
    eval(as_expr "a", C, R),
    R == 4.0.

test('promotion 3') :-
    parse("[a = 4.0 * false]", C),
    eval(as_expr "a", C, R),
    R == 0.0.

test('! op 1') :-
    parse("[a = !true]", C),
    eval(as_expr "a", C, R),
    R == false.

test('! op 2') :-
    parse("[a = !false]", C),
    eval(as_expr "a", C, R),
    R == true.

test('! op 3') :-
    parse("[a = !0]", C),
    eval(as_expr "a", C, R),
    R == true.

test('! op 4') :-
    parse("[a = !1]", C),
    eval(as_expr "a", C, R),
    R == false.

test('! op 5') :-
    parse("[a = !\"z\"]", C),
    eval(as_expr "a", C, R),
    R == error.

test('! op 6') :-
    parse("[a = !b]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('?: op 1') :-
    parse("[a = (true) ? 2.0 : true]", C),
    eval(as_expr "a", C, R),
    R == 2.0.

test('?: op 2') :-
    parse("[a = (false) ? 2.0 : true]", C),
    eval(as_expr "a", C, R),
    R == true.

test('?: op 3') :-
    parse("[a = (b) ? 2.0 : true]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('?: op 4') :-
    parse("[a = (\"z\") ? 2.0 : true]", C),
    eval(as_expr "a", C, R),
    R == error.

test('?: op 5') :-
    parse("[r = [a = ((true) ? parent : q).z; q = [z=42]]; z=69]", C),
    eval(as_expr "r.a", C, R),
    R == 69.

test('?: op 6') :-
    parse("[r = [a = ((false) ? parent : q).z; q = [z=42]]; z=69]", C),
    eval(as_expr "r.a", C, R),
    R == 42.

test('op== 1') :-
    parse("[a = 7 == 7]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op== 2') :-
    parse("[a = 6 == 7]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op== 3') :-
    parse("[a = 7.0 == 7]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op== 4') :-
    parse("[a = \"z\" == \"z\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op== 5') :-
    parse("[a = \"a\" == \"z\"]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op== 6') :-
    parse("[a = \"z\" == 1]", C),
    eval(as_expr "a", C, R),
    R == error.

test('op== 7') :-
    parse("[a = \"z\" == \"z\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op== 8') :-
    parse("[a = \"z\" == b]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('op!= 1') :-
    parse("[a =  1 != 0]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op!= 2') :-
    parse("[a =  1 != 1.0]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op!= 3') :-
    parse("[a =  \"a\" != \"b\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op!= 4') :-
    parse("[a =  \"a\" != \"a\"]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op< 1') :-
    parse("[a =  1 < 2]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op< 2') :-
    parse("[a =  1 < 1.0]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op< 3') :-
    parse("[a =  \"a\" < \"b\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op< 4') :-
    parse("[a =  \"a\" < \"a\"]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op> 1') :-
    parse("[a =  1 > 0]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op> 2') :-
    parse("[a =  1 > 1.0]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op> 3') :-
    parse("[a =  \"b\" > \"a\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op> 4') :-
    parse("[a =  \"a\" > \"a\"]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op<= 1') :-
    parse("[a =  1 <= 2]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op<= 2') :-
    parse("[a =  1 <= 1.0]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op<= 3') :-
    parse("[a =  2 <= 1.0]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op<= 4') :-
    parse("[a =  \"a\" <= \"b\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op<= 5') :-
    parse("[a =  \"a\" <= \"a\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op<= 6') :-
    parse("[a =  \"b\" <= \"a\"]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op>= 1') :-
    parse("[a =  1 >= 2]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op>= 2') :-
    parse("[a =  1 >= 1.0]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op>= 3') :-
    parse("[a =  2 >= 1.0]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op>= 4') :-
    parse("[a =  \"a\" >= \"b\"]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op>= 5') :-
    parse("[a =  \"a\" >= \"a\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op>= 6') :-
    parse("[a =  \"b\" >= \"a\"]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op=?= 1') :-
    parse("[a = 1 =?= 1]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op=?= 2') :-
    parse("[a = 1 =?= b]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op=?= 3') :-
    parse("[a = 1 =?= 2]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op=!= 1') :-
    parse("[a = 1 =!= 1]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op=!= 2') :-
    parse("[a = 1 =!= b]", C),
    eval(as_expr "a", C, R),
    R == false.

test('op=!= 3') :-
    parse("[a = 1 =!= 2]", C),
    eval(as_expr "a", C, R),
    R == true.

test('op[] 1') :-
    parse("[a = {1}[0]]", C),
    eval(as_expr "a", C, R),
    R == 1.

test('op[] 2') :-
    parse("[a = [z=42][\"z\"]; z=69]", C),
    eval(as_expr "a", C, R),
    R == 42.

test('op[] 3') :-
    parse("[a = {1}[3]]", C),
    eval(as_expr "a", C, R),
    R == error.

test('op[] 4') :-
    parse("[a = {[z=42]}[\"z\"]; z=69]", C),
    eval(as_expr "a", C, R),
    R == [42].

test('op[] 5') :-
    parse("[a = {}[\"z\"]; z=69]", C),
    eval(as_expr "a", C, R),
    R == [].

test('op[] 6') :-
    parse("[a = {1}[\"z\"]]", C),
    eval(as_expr "a", C, R),
    R == [error].

test('op[] 7') :-
    parse("[a = {[x=1]}[\"z\"]]", C),
    eval(as_expr "a", C, R),
    R == [undefined].

test('op[] 8') :-
    parse("[a = {}[0]]", C),
    eval(as_expr "a", C, R),
    R == error.

test('op[] 9') :-
    parse("[a = {0}[-1]]", C),
    eval(as_expr "a", C, R),
    R == error.

test('op[] 10') :-
    parse("[a = b[0]]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('op[] 11') :-
    parse("[a = {1}[b]]", C),
    eval(as_expr "a", C, R),
    R == undefined.

test('op[] 12') :-
    parse("[a = {{3},{4}}[1][0]]", C),
    eval(as_expr "a", C, R),
    R == 4.

test('op[] 13') :-
    parse("[a = [b=[c=55];c=44]; c=33; d=a[\"b\"][\"c\"]]", C),
    eval(as_expr "d", C, R),
    R == 55.

test('op[] 14') :-
    parse("[a = [b=[c=parent.c];c=44]; c=33; d=a[\"b\"][\"c\"]]", C),
    eval(as_expr "d", C, R),
    R == 44.

test('op[] 15') :-
    parse("[a = [b=[c=parent.c];c=44]; c=33; d=a[\"parent\"][\"c\"]]", C),
    eval(as_expr "d", C, R),
    R == 33.

:- end_tests(classad_eval_ut).


Set graph title

Set graph title

#!/usr/bin/gnuplot

# graph of TMP36

# ******************************************************* General settings *****
set datafile separator ';'
set datafile missing "NaN"   # Ignore missing values
set grid
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.

# ************************************************************* Statistics *****
# stats to be calculated here
fname = "/tmp/sql22.csv"
stats fname using 2 name "T2" nooutput

T2_min = T2_min + utc_offset - 946684800
T2_max = T2_max + utc_offset - 946684800

# ****************************************************************** Title *****
set title "DHT22 measurements"
#"-".utc_offset."-"

# ***************************************************************** X-axis *****
set xlabel "Date/Time"       # X-axis label
set xdata time               # Define that data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xtics rotate by 45 right
set xrange [ T2_min : T2_max ]

# ***************************************************************** Y-axis *****
set ylabel "Temperature [degC]" # Title for Y-axis
#set yrange [10:20]
set autoscale y

# **************************************************************** Y2-axis *****
set y2label "Humidity [%]" # Title for Y2-axis
set autoscale y2
set y2tics border         # place ticks on second Y2-axis

# ***************************************************************** Legend *****
# generate a legend which is placed underneath the plot
set key outside bottom center box title "-=legend=-"

# ***************************************************************** Output *****
set terminal png large
set output "/tmp/bonediagd/plot2.png"

# ***** PLOT *****
plot "/tmp/sql22.csv"  using ($2+utc_offset):4 title "Temperature [degC]"      with points pt 5 ps 0.2\
    ,"/tmp/sql22.csv"  using ($2+utc_offset):3 title "Humidity [%]" axes x1y2  with points pt 5 ps 0.2\

#!/usr/bin/gnuplot

# graph of TMP36

# ******************************************************* General settings *****
set datafile separator ';'
set datafile missing "NaN"   # Ignore missing values
set grid
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.

# ************************************************************* Statistics *****
# stats to be calculated here
fname = "/tmp/sql22.csv"
stats fname using 2 name "T2" nooutput

T2_min = T2_min + utc_offset - 946684800
T2_max = T2_max + utc_offset - 946684800

# ****************************************************************** Title *****
#set title "Test graph -".utc_offset."-"

# ***************************************************************** X-axis *****
set xlabel "Date/Time"       # X-axis label
set xdata time               # Define that data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xtics rotate by 45 right
set xrange [ T2_min : T2_max ]

# ***************************************************************** Y-axis *****
set ylabel "Temperature [degC]" # Title for Y-axis
#set yrange [10:20]
set autoscale y

# **************************************************************** Y2-axis *****
set y2label "Humidity [%]" # Title for Y2-axis
set autoscale y2
set y2tics border         # place ticks on second Y2-axis

# ***************************************************************** Legend *****
# generate a legend which is placed underneath the plot
set key outside bottom center box title "-=legend=-"

# ***************************************************************** Output *****
set terminal png large
set output "/tmp/bonediagd/plot2.png"

# ***** PLOT *****
plot "/tmp/sql22.csv"  using ($2+utc_offset):4 title "Temperature [degC]"      with points pt 5 ps 0.2\
    ,"/tmp/sql22.csv"  using ($2+utc_offset):3 title "Humidity [%]" axes x1y2  with points pt 5 ps 0.2\


Pressure graph improved

Pressure graph improved

#!/usr/bin/gnuplot

# graph of DHT22 data

# ******************************************************* General settings *****
set terminal png font "Helvetica" 11
set datafile separator ';'
set datafile missing "NaN"   # Ignore missing values
set grid
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.

# ************************************************************* Statistics *****
# stats to be calculated here
fname = "/tmp/sql23.csv"
stats fname using 2 name "T2" nooutput

T2_min = T2_min + utc_offset - 946684800
T2_max = T2_max + utc_offset - 946684800

# ****************************************************************** Title *****
set title "Air Pressure (BMP183) @ NAP+12.1m"
# groundlevel = +8.5m
# sensor at +3.5 above groundlevel
#"-".utc_offset."-"

# ***************************************************************** X-axis *****
set xlabel "Date/Time"       # X-axis label
set xdata time               # Define that data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xtics rotate by 40 right
set xrange [ T2_min : T2_max ]

# ***************************************************************** Y-axis *****
set ylabel "Pressure [mbar]"
#set yrange [10:20]
set autoscale y

# **************************************************************** Y2-axis *****
set y2label "Temperature [degC]"
set autoscale y2
set y2tics border

# ***************************************************************** Legend *****
# generate a legend which is placed underneath the plot
#set key outside bottom center box title "-=legend=-"
set key default
set key box
set key samplen .2
set key inside vertical
set key left top

# ***************************************************************** Output *****
set output "/tmp/bonediagd/plot3.png"

# ***** PLOT *****
plot "/tmp/sql23.csv"  using ($2+utc_offset):3 title " Pressure [mbar]"      with points pt 5 ps 0.2\
    ,"/tmp/sql23.csv"  using ($2+utc_offset):4 title " Temperature [degC]" axes x1y2  with dots\

#!/usr/bin/gnuplot

# graph of DHT22 data

# ******************************************************* General settings *****
set terminal png font "Helvetica" 11
set datafile separator ';'
set datafile missing "NaN"   # Ignore missing values
set grid
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.

# ************************************************************* Statistics *****
# stats to be calculated here
fname = "/tmp/sql23.csv"
stats fname using 2 name "T2" nooutput

T2_min = T2_min + utc_offset - 946684800
T2_max = T2_max + utc_offset - 946684800

# ****************************************************************** Title *****
set title "BMP183 measurements"
#"-".utc_offset."-"

# ***************************************************************** X-axis *****
set xlabel "Date/Time"       # X-axis label
set xdata time               # Define that data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xtics rotate by 40 right
set xrange [ T2_min : T2_max ]

# ***************************************************************** Y-axis *****
set ylabel "Temperature [degC]"
#set yrange [10:20]
set autoscale y

# **************************************************************** Y2-axis *****
set y2label "Pressure [mbar]"
set autoscale y2
set y2tics border

# ***************************************************************** Legend *****
# generate a legend which is placed underneath the plot
#set key outside bottom center box title "-=legend=-"
set key default
set key box
set key samplen .2
set key inside vertical
set key left top

# ***************************************************************** Output *****
set output "/tmp/bonediagd/plot3.png"

# ***** PLOT *****
plot "/tmp/sql23.csv"  using ($2+utc_offset):4 title " Temperature [degC]"      with points pt 5 ps 0.2\
    ,"/tmp/sql23.csv"  using ($2+utc_offset):3 title " Pressure [mbar]" axes x1y2  with points pt 5 ps 0.2\


Add third point to uniquely identify line.

set terminal png transparent nointerlace \
    font "lucon.ttf,20" \
    size 1920,1080 nocrop \
    noenhanced \
    background '#FFFFFF'

set output "quadratic-2.png"
set encoding utf8

set style line 101 linetype 1 linewidth 5 linecolor rgbcolor '#000000'
set style line 102 linetype 2 linewidth 4 linecolor rgbcolor '#999999'
set style line 103 linetype 3 linewidth 4 linecolor rgbcolor '#A00000'
set style line 104 linetype 4 linewidth 4 linecolor rgbcolor '#FF0000'
set style line 105 linetype 5 linewidth 4 linecolor rgbcolor '#007000'
set style line 106 linetype 6 linewidth 6 linecolor rgbcolor '#00FF00'
set style line 107 linetype 7 linewidth 4 linecolor rgbcolor '#0000A0'
set style line 108 linetype 8 linewidth 4 linecolor rgbcolor '#1E90FF'
set style line 109 linetype 9 linewidth 4 linecolor rgbcolor '#A020F0'

set key off

# TODO: set origin and size as options or calculate.
set origin 0.02,0
set size 0.98,1
set ytics
set xtics
set border
set colorbox
set xrange [1.5:5.5]
set grid xtics
set mxtics
set xlabel "x" font "lucon.ttf,30"

set grid ytics
set mytics
set my2tics
set ylabel "f(x)" font "lucon.ttf,30"
#set ytics nomirror
#set y2tics nomirror
set label 1 "2005-2017 © eigenholser" \
    at screen 0.99,0.014 right font "times.ttf,12"
set label 2 "f(x) = 7x^2 - 3x + 42" at screen 0.21,0.865 left font "times.ttf,30"
set label 3 "f(x) = α(x^2 - 7x + 10) + 46x - 28" at screen 0.21,0.830 left font "times.ttf,30"
set title "Quadratic polynomials passing through points (2,64) and (5,202)" font "lucon.ttf,30"

# Greek α symbol is U03B1
f(x) = 7.0*x**2 - 3.0*x + 42
x1 = 2
x2 = 5
x3 = 3.5
set style line 1 pointtype 7 linecolor rgb '#000000' pointsize 4
plot \
    (-89.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (-55.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (-34.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (-21.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (-8.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (13.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (21.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (34.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (55.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (89.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (120.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (144.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    f(x) axes x1y1 not with lines linestyle 106, \
    '+' using ($0 == 0 ? x1 : NaN):(f(x1)):(sprintf('(%.1d,%.1d)', x1, f(x1))) \
    with labels offset char -2,2.5 left textcolor rgb 'blue' \
    point linestyle 1 notitle, \
    '+' using ($0 == 0 ? x2 : NaN):(f(x2)):(sprintf('(%.1d,%.1d)', x2, f(x2))) \
    with labels offset char -4.0,3.0 left textcolor rgb 'blue' \
    point linestyle 1 notitle, \
    '+' using ($0 == 0 ? x3 : NaN):(f(x3)):(sprintf('(%.1d,%.1d)', x3, f(x3))) \
    with labels offset char -1.0,0.5 left textcolor rgb 'blue' \
    point linestyle 1 notitle

set terminal png transparent nointerlace \
    font "lucon.ttf,20" \
    size 1920,1080 nocrop \
    noenhanced \
    background '#FFFFFF'

set output "quadratic-2.png"
set encoding utf8

set style line 101 linetype 1 linewidth 5 linecolor rgbcolor '#000000'
set style line 102 linetype 2 linewidth 4 linecolor rgbcolor '#999999'
set style line 103 linetype 3 linewidth 4 linecolor rgbcolor '#A00000'
set style line 104 linetype 4 linewidth 4 linecolor rgbcolor '#FF0000'
set style line 105 linetype 5 linewidth 4 linecolor rgbcolor '#007000'
set style line 106 linetype 6 linewidth 6 linecolor rgbcolor '#00FF00'
set style line 107 linetype 7 linewidth 4 linecolor rgbcolor '#0000A0'
set style line 108 linetype 8 linewidth 4 linecolor rgbcolor '#1E90FF'
set style line 109 linetype 9 linewidth 4 linecolor rgbcolor '#A020F0'

set key off

# TODO: set origin and size as options or calculate.
set origin 0.02,0
set size 0.98,1
set ytics
set xtics
set border
set colorbox
set xrange [1.5:5.5]
set grid xtics
set mxtics
set xlabel "x" font "lucon.ttf,30"

set grid ytics
set mytics
set my2tics
set ylabel "f(x)" font "lucon.ttf,30"
#set ytics nomirror
#set y2tics nomirror
set label 1 "2005-2017 © eigenholser" \
    at screen 0.99,0.014 right font "times.ttf,12"
set label 2 "f(x) = 7x^2 - 3x + 42" at screen 0.21,0.865 left font "times.ttf,30"
set label 3 "f(x) = α(x^2 - 7x + 10) + 46x - 28" at screen 0.21,0.830 left font "times.ttf,30"
set title "Quadratic polynomials passing through points (2,64) and (5,202)" font "lucon.ttf,30"

# Greek α symbol is U03B1
f(x) = 7.0*x**2 - 3.0*x + 42
x1 = 2
x2 = 5
set style line 1 pointtype 7 linecolor rgb '#000000' pointsize 4
plot \
    (-89.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (-55.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (-34.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (-21.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (-8.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (13.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (21.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (34.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (55.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (89.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (120.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    (144.0*(x**2 - 7.0*x + 10.0) + 46.0*x - 28.0) axes x1y1 not with lines linestyle 102, \
    f(x) axes x1y1 not with lines linestyle 106, \
    '+' using ($0 == 0 ? x1 : NaN):(f(x1)):(sprintf('(%.1d,%.1d)', x1, f(x1))) \
    with labels offset char -2,2.5 left textcolor rgb 'blue' \
    point linestyle 1 notitle, \
    '+' using ($0 == 0 ? x2 : NaN):(f(x2)):(sprintf('(%.1d,%.1d)', x2, f(x2))) \
    with labels offset char -4.0,3.0 left textcolor rgb 'blue' \
    point linestyle 1 notitle


cropped grpah was too cropped, didn't notice before that gnuplot won't show errorbars if data falls outside of graph

# expects 'fieldtype' variable to be defined on command line
#
# example: gnuplot -e 'fieldtype="long"' plot.gnuplot

set terminal png size 800,600 enhanced font "Helvetica,12"
set key top left

# same style for every line, just diff colors
set style line 1 pointtype 1
set style line 2 pointtype 1
set style line 3 pointtype 1
set style line 4 pointtype 1
set style line 5 pointtype 1
set style line 6 pointtype 1

x3(x) = (3 * x)
relerr(expected,observed) = abs(expected - observed) / expected
datafile(base) = "output/".base.".plotdata.tsv"

### plot the (real) value counts

set output 'output/'.fieldtype.'_num_values.png'

set xlabel "Num Values Expected (# Docs * 3)"
set ylabel "Num Values"

set title "Number of Values Found (".fieldtype." field)" noenhanced

plot datafile(fieldtype."_countdistinct") using (x3($1)):2 title "countDistinct" ls 1, \
     datafile(fieldtype."_cardinality=7") using (x3($1)):2 title "cardinality=0.7" ls 2, \
     datafile(fieldtype."_cardinality=5") using (x3($1)):2 title "cardinality=0.5" ls 3, \
     datafile(fieldtype."_cardinality=true") using (x3($1)):2 title "cardinality=true (0.3)" ls 4

### plot the relative error of the value counts

set output 'output/'.fieldtype.'_rel_error.png'

set xlabel "Num Values Expected (# Docs * 3)"
set ylabel "Relative Error"

set title "Compared to Expected: Relative Error of Value Counts (".fieldtype." field)" noenhanced

plot datafile(fieldtype."_countdistinct") using (x3($1)):(relerr(x3($1), $2)) title "countDistinct" ls 1, \
     datafile(fieldtype."_cardinality=7") using (x3($1)):(relerr(x3($1), $2)) title "cardinality=0.7" ls 2, \
     datafile(fieldtype."_cardinality=5") using (x3($1)):(relerr(x3($1), $2)) title "cardinality=0.5" ls 3, \
     datafile(fieldtype."_cardinality=true") using (x3($1)):(relerr(x3($1), $2)) title "cardinality=true (0.3)" ls 4

### plot the the timing data

set output 'output/'.fieldtype.'_timing.png'

set xlabel "Num Values Expected (# Docs * 3)"
set ylabel "Req Time (sec)"

set title "Request Time (".fieldtype." field)" noenhanced

plot datafile(fieldtype."_countdistinct") using (x3($1)):3:4 with errorbars title "countDistinct" ls 1, \
     datafile(fieldtype."_cardinality=7") using (x3($1)):3:4 with errorbars title "cardinality=0.7" ls 2, \
     datafile(fieldtype."_cardinality=5") using (x3($1)):3:4 with errorbars title "cardinality=0.5" ls 3, \
     datafile(fieldtype."_cardinality=true") using (x3($1)):3:4 with errorbars title "cardinality=true (0.3)" ls 4

# crop some of the really noisy data so detail is more clear
set xrange [20000:]
set yrange [0:4]
set output 'output/'.fieldtype.'_timing_cropped.png'

set title "Request Time (".fieldtype." field, cropped)" noenhanced
replot

# expects 'fieldtype' variable to be defined on command line
#
# example: gnuplot -e 'fieldtype="long"' plot.gnuplot

set terminal png size 800,600 enhanced font "Helvetica,12"
set key top left

# same style for every line, just diff colors
set style line 1 pointtype 1
set style line 2 pointtype 1
set style line 3 pointtype 1
set style line 4 pointtype 1
set style line 5 pointtype 1
set style line 6 pointtype 1

x3(x) = (3 * x)
relerr(expected,observed) = abs(expected - observed) / expected
datafile(base) = "output/".base.".plotdata.tsv"

### plot the (real) value counts

set output 'output/'.fieldtype.'_num_values.png'

set xlabel "Num Values Expected (# Docs * 3)"
set ylabel "Num Values"

set title "Number of Values Found (".fieldtype." field)" noenhanced

plot datafile(fieldtype."_countdistinct") using (x3($1)):2 title "countDistinct" ls 1, \
     datafile(fieldtype."_cardinality=7") using (x3($1)):2 title "cardinality=0.7" ls 2, \
     datafile(fieldtype."_cardinality=5") using (x3($1)):2 title "cardinality=0.5" ls 3, \
     datafile(fieldtype."_cardinality=true") using (x3($1)):2 title "cardinality=true (0.3)" ls 4

### plot the relative error of the value counts

set output 'output/'.fieldtype.'_rel_error.png'

set xlabel "Num Values Expected (# Docs * 3)"
set ylabel "Relative Error"

set title "Compared to Expected: Relative Error of Value Counts (".fieldtype." field)" noenhanced

plot datafile(fieldtype."_countdistinct") using (x3($1)):(relerr(x3($1), $2)) title "countDistinct" ls 1, \
     datafile(fieldtype."_cardinality=7") using (x3($1)):(relerr(x3($1), $2)) title "cardinality=0.7" ls 2, \
     datafile(fieldtype."_cardinality=5") using (x3($1)):(relerr(x3($1), $2)) title "cardinality=0.5" ls 3, \
     datafile(fieldtype."_cardinality=true") using (x3($1)):(relerr(x3($1), $2)) title "cardinality=true (0.3)" ls 4

### plot the the timing data

# crop some of the really noisy data (not enough warming in particular) so detail is more clear
set yrange [0:2]

set output 'output/'.fieldtype.'_timing.png'

set xlabel "Num Values Expected (# Docs * 3)"
set ylabel "Req Time (sec)"

set title "Request Time (".fieldtype." field)" noenhanced

plot datafile(fieldtype."_countdistinct") using (x3($1)):3:4 with errorbars title "countDistinct" ls 1, \
     datafile(fieldtype."_cardinality=7") using (x3($1)):3:4 with errorbars title "cardinality=0.7" ls 2, \
     datafile(fieldtype."_cardinality=5") using (x3($1)):3:4 with errorbars title "cardinality=0.5" ls 3, \
     datafile(fieldtype."_cardinality=true") using (x3($1)):3:4 with errorbars title "cardinality=true (0.3)" ls 4


improve readability of date/time in title


Add more db_singleton_v (keypolicy) tests

:- begin_tests(vd).

:- use_module(u(v)).
:- use_module(u(vd)).
:- use_module(u(internal/db_i)).
:- use_module(u(util/lambda)).

test(clear_test_db, [fail, setup(db_clear(people))]) :-

	db_recorded(people, _).

test(db_copy, [setup(model_db), N =:= 3]) :-

   db_copy(people, people2),
   findall('.', db_recorded(people2, _), L),
   length(L, N).

test(db_erase, [setup(model_db)]) :-

   (  named_args_unify(people, _,
                       [weight, surname], [73, _], X),
      db_erase(X),
      fail ; true
   ),

   findall(Y,
           db_recorded(people, Y),
           LY),
   assertion(LY = [man_v(_, _, _, _, 'Eva', woman, _, _)]).

test(db_iterate1, [setup(model_db), N =:= 3]) :-

   findall('.', db_iterate(people, true, _), L),
   length(L, N).

test(db_iterate2, [setup(model_db), N =:= 2]) :-

   findall(O, db_iterate(people, sex(man), O), L),
   length(L, N).

test(db_iterate3, [setup(model_db), fail]) :-

   db_iterate(people, unexisting_name(man_v), _).

test(db_iterate4, [setup(model_db), N =:= 2]) :-

   findall(O, db_iterate(people, functor(man_v), O), L),
   length(L, N).

test(db_iterate4, [setup(model_db), N =:= 3]) :-

   findall(O, db_iterate(people, functor(_), O), L),
   length(L, N).

test(db_to_list, [setup(model_db)]) :-

   db_to_list(people, man_v, L1),
   length(L1, N1),
   assertion(N1 =:= 2),

   db_to_list(people, citizen_v, L2),
   length(L2, N2),
   assertion(N2 =:= 1),

   db_to_list(people, _, L3),
   length(L3, N3),
   assertion(N3 =:= 3).

test(db_put_object1, [setup(model_db)]) :-

   obj_construct(man_v, [name], ['Moses'], Man),
   db_put_object(people, Man).

test(db_put_object2, [setup(model_db)]) :-

   obj_construct(man_v, [name], ['Moses'], Man0),
   obj_rebase((object_v -> db_object_v), Man0, Man),
   db_put_object(people, Man).

test(db_put_object3,
     [setup(model_db),
      error(db_obj_replace_protector(people2, Man))]) :-

   db_construct(people2, man_v, [name], ['Moses']),
   db_recorded(people2, Man), !,
   db_put_object(people2, Man).

test(db_put_object4, [setup(model_db)]) :-
% replacing

   db_construct(people2, man_v, [name], ['Moses']),
   db_recorded(people2, Man0), !,
   obj_rewrite(Man0, [name], ['Moses'], [_], Man1),
   db_put_object(people2, throw, Man1, Man2, Replaced),
   named_args_unify(Man2,
                    [name, db_key, db_ref],
                    [New_Name, DB_Key, DB_Ref]),
   assertion(New_Name =@= _),
   assertion(Replaced == replaced),
   assertion(nonvar(DB_Ref)),
   assertion(DB_Key == people2),

   db_size(people2, N),
   assertion(N =:= 1).

test(db_put_object5,
     [setup(model_db),
      error(domain_error(unbound_db_ref, DB_Ref))]) :-

   db_construct(people, man_v, [name], ['Moses']),
   db_construct(people2, man_v, [name], ['Moses']),
   db_recorded(people2, Man0), !,
   obj_field(Man0, db_ref, DB_Ref),
   db_put_object(people, throw, Man0, _, _).

test(db_put_object6,
     [setup(model_db),
      error(domain_error(unbound_or_same_db_key, people2))]) :-

   db_construct(people, man_v, [name], ['Moses']),
   db_construct(people2, man_v, [name], ['Moses']),
   db_recorded(people2, Man0), !,
   obj_reset_fields([db_ref], Man0, Man),
   db_put_object(people, throw, Man, _, _).

test(db_put_objects,
    [setup(db_clear(people)),
     DB_Size =:= 3]
    ) :-

	maplist(obj_construct(man_v, [name]),
		[['Valera'], ['Vika'], ['Yura']],
		Men),

	db_put_objects(people,
		       Men+\El^member(El, Men),
		       fail),

	db_size(people, DB_Size).

test(db_recorded_bug1, [setup(model_db), N =:= 3]) :-

   findall('.', db_recorded(people, _), L),
   length(L, N).

test(db_recorded1,
     [setup(model_db),
      error(domain_error(db_object_v_descendant, X))]) :-

   obj_construct(man_v, [sex], [man], X),
   db_recorded(people, X).

test(db_recorded2, [setup(model_db)]) :-

   findall('.',
           (obj_construct(man_v, [sex], [man], X0),
            obj_rebase((object_v -> db_object_v), X0, X),
            db_recorded(people, X)),
           L2),
   length(L2, N2),
   assertion(N2 =:= 1).

test(db_recorded3, [setup(model_db)]) :-

   findall('.',
           (obj_construct(man_v, [], [], X0),
            obj_rebase((object_v -> db_object_v), X0, X),
            db_recorded(people, X)),
           L2),
   length(L2, N2),
   assertion(N2 =:= 2).

test(db_recorded4, [setup(model_db)]) :-

   findall('.',
           (obj_construct(man_v, [height], [1.76], X0),
            obj_rebase((object_v -> db_object_v), X0, X),
            db_recorded(people, X)),
           L2),
   length(L2, N2),
   assertion(N2 =:= 2).

test(db_recorded5, [setup(db_clear(people))]) :-

   db_construct(people, man_v, [], []),
   db_recorded(people, X), !,
   db_recorded(people, X).

test(named_args_unify1, [setup(model_db)]) :-

   findall('.',
           named_args_unify(people, _, [sex], [man], _),
           ['.', '.']).

test(named_args_unify2, [setup(model_db)]) :-

   findall('.',
           named_args_unify(people, _, [sex, sex], [man, man], _),
           ['.', '.']).

test(named_args_unify_bug1, [setup(model_db)]) :-

   findall('.',
           named_args_unify(people, citizen_v, [sex], [man], _),
           ['.']).

test(named_args_unify_bug2, [setup(model_db)]) :-

   findall('.',
           named_args_unify(people, _, [], [], _),
           ['.', '.', '.']).

test(store_and_retrieve1,
    [setup(db_clear(people)),
     man(Sex, Name, Surname, Weight, Height) ==
     man(man, 'Adam', 'Adamov', 1, 3)]
    ) :-

	obj_construct(man_v,
		      [sex, name, surname, weight, height],
		      [man, 'Adam', 'Adamov', 1, 3],
		      Man),

	db_put_object(people, Man, Man1),

	assertion(obj_is_descendant(Man1, db_object_v)),
	assertion(\+ obj_is_descendant(Man1, man_v)),
	assertion(\+ obj_is_descendant(Man, db_object_v)),

	obj_field(Man1, sex, Sex),
	obj_field(Man1, name, Name),
	obj_field(Man1, surname, Surname),
	obj_field(Man1, weight, Weight),
	obj_field(Man1, height, Height).

test(key_rule1,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Lodyagin']),
   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Lodyagin']).

test(key_rule2,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v, [], []),
   db_construct(people, man_v, [], []).

test(key_rule3,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v, [name], ['Sergei']),
   db_construct(people, man_v, [], []).

test(key_rule4,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v, [], []),
   db_construct(people, man_v, [name], ['Sergei']).

test(key_rule5, [setup(db_clear(people))]) :-

   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Lodyagin']),

   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Sikorsky']).

test(key_rule6,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v,
                [name], ['Sergei']),

   db_construct(people, man_v,
                [name], ['Sergei']).

test(key_rule7,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v,
                [name], ['Sergei']),

   db_construct(people, man_v,
                [surname], ['Lodyagin']).

test(key_rule8, [setup(db_clear(people))]) :-

   db_construct(people, man_v,
                [name], ['Sergei']),

   db_construct(people, man_v,
                [name], ['Artem']).

test(key_rule9,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Sysoev']),

   db_construct(people, man_v,
                [name], ['Sergei']).

test(key_rule10,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v,
                [name], ['Sergei']),

   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Sysoev']).

test(key_rule11,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, citizen_v, [id], [4]),
   db_construct(people, citizen_v, [], []).

test(key_rule12, [setup(db_clear(people))]) :-

   db_construct(people, citizen_v, [id], [4]),
   db_construct(people, man_v, [], []).

test(key_rule13, [setup(db_clear(people))]) :-

   db_construct(people, citizen_v, [id], [4]),
   db_construct(people, man_v, [name], ['James']).

test(key_rule14,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, citizen_v, [id], [4]),
   db_construct(people, man_v, [], []),
   db_construct(people, citizen_v, [id], [5]).

test(key_rule15, [setup(db_clear(people))]) :-

   db_construct(people, citizen_v, [id], [4]),
   db_construct(people, man_v,
                [name, surname], ['James', 'Crick']),
   db_construct(people, citizen_v,
                [name, surname, id], ['Adam', 'Adamovitch', 5]).

test(key_rule16,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v, [name], ['James']),
   db_construct(people, citizen_v, [id], [4]).

test(db_singleton_v1_overwrite, [setup(db_clear(people))]) :-

   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Lodyagin']),
   db_construct(people, db_singleton_v,
                [key_policy], [overwrite]),
   db_construct(people, man_v, [surname], ['Lodyagin']),

   findall([Name, Surname],
           named_args_unify(people, _, [name, surname],
                            [Name, Surname], _),
           List1),
   assertion(List1 =@= [[_, 'Lodyagin']]).

test(db_singleton_v2_throw,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Lodyagin']),
   db_construct(people, db_singleton_v,
                [key_policy], [overwrite]),
   db_construct(people, man_v, [surname], ['Lodyagin']),
   db_construct(people, db_singleton_v,
                [key_policy], [throw]),
   db_construct(people, man_v, [name], ['Sergei']).

   %named_args_unify(people, db_singleton_v, [], _, Singl1),
   %db_put_object(people, _, Singl1, _, replaced),

model_db :-

	db_clear(people),
	db_clear(people2),

        db_construct(people, man_v,
                     [sex, name, weight], [man, 'Adam', 73]),
        db_construct(people, man_v,
                     [sex, name, weight], [woman, 'Eva', 64]),

        db_construct(people, citizen_v,
                      [sex, name, surname, country],
                      [man, 'Vladimir', 'Mayakovsky',
                       ['Soviet Union']]).

:- end_tests(vd).

:- begin_tests(vd).

:- use_module(u(v)).
:- use_module(u(vd)).
:- use_module(u(internal/db_i)).
:- use_module(u(util/lambda)).

test(clear_test_db, [fail, setup(db_clear(people))]) :-

	db_recorded(people, _).

test(db_copy, [setup(model_db), N =:= 3]) :-

   db_copy(people, people2),
   findall('.', db_recorded(people2, _), L),
   length(L, N).

test(db_erase, [setup(model_db)]) :-

   (  named_args_unify(people, _,
                       [weight, surname], [73, _], X),
      db_erase(X),
      fail ; true
   ),

   findall(Y,
           db_recorded(people, Y),
           LY),
   assertion(LY = [man_v(_, _, _, _, 'Eva', woman, _, _)]).

test(db_iterate1, [setup(model_db), N =:= 3]) :-

   findall('.', db_iterate(people, true, _), L),
   length(L, N).

test(db_iterate2, [setup(model_db), N =:= 2]) :-

   findall(O, db_iterate(people, sex(man), O), L),
   length(L, N).

test(db_iterate3, [setup(model_db), fail]) :-

   db_iterate(people, unexisting_name(man_v), _).

test(db_iterate4, [setup(model_db), N =:= 2]) :-

   findall(O, db_iterate(people, functor(man_v), O), L),
   length(L, N).

test(db_iterate4, [setup(model_db), N =:= 3]) :-

   findall(O, db_iterate(people, functor(_), O), L),
   length(L, N).

test(db_to_list, [setup(model_db)]) :-

   db_to_list(people, man_v, L1),
   length(L1, N1),
   assertion(N1 =:= 2),

   db_to_list(people, citizen_v, L2),
   length(L2, N2),
   assertion(N2 =:= 1),

   db_to_list(people, _, L3),
   length(L3, N3),
   assertion(N3 =:= 3).

test(db_put_object1, [setup(model_db)]) :-

   obj_construct(man_v, [name], ['Moses'], Man),
   db_put_object(people, Man).

test(db_put_object2, [setup(model_db)]) :-

   obj_construct(man_v, [name], ['Moses'], Man0),
   obj_rebase((object_v -> db_object_v), Man0, Man),
   db_put_object(people, Man).

test(db_put_object3,
     [setup(model_db),
      error(db_obj_replace_protector(people2, Man))]) :-

   db_construct(people2, man_v, [name], ['Moses']),
   db_recorded(people2, Man), !,
   db_put_object(people2, Man).

test(db_put_object4, [setup(model_db)]) :-
% replacing

   db_construct(people2, man_v, [name], ['Moses']),
   db_recorded(people2, Man0), !,
   obj_rewrite(Man0, [name], ['Moses'], [_], Man1),
   db_put_object(people2, throw, Man1, Man2, Replaced),
   named_args_unify(Man2,
                    [name, db_key, db_ref],
                    [New_Name, DB_Key, DB_Ref]),
   assertion(New_Name =@= _),
   assertion(Replaced == replaced),
   assertion(nonvar(DB_Ref)),
   assertion(DB_Key == people2),

   db_size(people2, N),
   assertion(N =:= 1).

test(db_put_object5,
     [setup(model_db),
      error(domain_error(unbound_db_ref, DB_Ref))]) :-

   db_construct(people, man_v, [name], ['Moses']),
   db_construct(people2, man_v, [name], ['Moses']),
   db_recorded(people2, Man0), !,
   obj_field(Man0, db_ref, DB_Ref),
   db_put_object(people, throw, Man0, _, _).

test(db_put_object6,
     [setup(model_db),
      error(domain_error(unbound_or_same_db_key, people2))]) :-

   db_construct(people, man_v, [name], ['Moses']),
   db_construct(people2, man_v, [name], ['Moses']),
   db_recorded(people2, Man0), !,
   obj_reset_fields([db_ref], Man0, Man),
   db_put_object(people, throw, Man, _, _).

test(db_put_objects,
    [setup(db_clear(people)),
     DB_Size =:= 3]
    ) :-

	maplist(obj_construct(man_v, [name]),
		[['Valera'], ['Vika'], ['Yura']],
		Men),

	db_put_objects(people,
		       Men+\El^member(El, Men),
		       fail),

	db_size(people, DB_Size).

test(db_recorded_bug1, [setup(model_db), N =:= 3]) :-

   findall('.', db_recorded(people, _), L),
   length(L, N).

test(db_recorded1,
     [setup(model_db),
      error(domain_error(db_object_v_descendant, X))]) :-

   obj_construct(man_v, [sex], [man], X),
   db_recorded(people, X).

test(db_recorded2, [setup(model_db)]) :-

   findall('.',
           (obj_construct(man_v, [sex], [man], X0),
            obj_rebase((object_v -> db_object_v), X0, X),
            db_recorded(people, X)),
           L2),
   length(L2, N2),
   assertion(N2 =:= 1).

test(db_recorded3, [setup(model_db)]) :-

   findall('.',
           (obj_construct(man_v, [], [], X0),
            obj_rebase((object_v -> db_object_v), X0, X),
            db_recorded(people, X)),
           L2),
   length(L2, N2),
   assertion(N2 =:= 2).

test(db_recorded4, [setup(model_db)]) :-

   findall('.',
           (obj_construct(man_v, [height], [1.76], X0),
            obj_rebase((object_v -> db_object_v), X0, X),
            db_recorded(people, X)),
           L2),
   length(L2, N2),
   assertion(N2 =:= 2).

test(db_recorded5, [setup(db_clear(people))]) :-

   db_construct(people, man_v, [], []),
   db_recorded(people, X), !,
   db_recorded(people, X).

test(named_args_unify1, [setup(model_db)]) :-

   findall('.',
           named_args_unify(people, _, [sex], [man], _),
           ['.', '.']).

test(named_args_unify2, [setup(model_db)]) :-

   findall('.',
           named_args_unify(people, _, [sex, sex], [man, man], _),
           ['.', '.']).

test(named_args_unify_bug1, [setup(model_db)]) :-

   findall('.',
           named_args_unify(people, citizen_v, [sex], [man], _),
           ['.']).

test(named_args_unify_bug2, [setup(model_db)]) :-

   findall('.',
           named_args_unify(people, _, [], [], _),
           ['.', '.', '.']).

test(store_and_retrieve1,
    [setup(db_clear(people)),
     man(Sex, Name, Surname, Weight, Height) ==
     man(man, 'Adam', 'Adamov', 1, 3)]
    ) :-

	obj_construct(man_v,
		      [sex, name, surname, weight, height],
		      [man, 'Adam', 'Adamov', 1, 3],
		      Man),

	db_put_object(people, Man, Man1),

	assertion(obj_is_descendant(Man1, db_object_v)),
	assertion(\+ obj_is_descendant(Man1, man_v)),
	assertion(\+ obj_is_descendant(Man, db_object_v)),

	obj_field(Man1, sex, Sex),
	obj_field(Man1, name, Name),
	obj_field(Man1, surname, Surname),
	obj_field(Man1, weight, Weight),
	obj_field(Man1, height, Height).

test(key_rule1,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Lodyagin']),
   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Lodyagin']).

test(key_rule2,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v, [], []),
   db_construct(people, man_v, [], []).

test(key_rule3,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v, [name], ['Sergei']),
   db_construct(people, man_v, [], []).

test(key_rule4,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v, [], []),
   db_construct(people, man_v, [name], ['Sergei']).

test(key_rule5, [setup(db_clear(people))]) :-

   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Lodyagin']),

   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Sikorsky']).

test(key_rule6,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v,
                [name], ['Sergei']),

   db_construct(people, man_v,
                [name], ['Sergei']).

test(key_rule7,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v,
                [name], ['Sergei']),

   db_construct(people, man_v,
                [surname], ['Lodyagin']).

test(key_rule8, [setup(db_clear(people))]) :-

   db_construct(people, man_v,
                [name], ['Sergei']),

   db_construct(people, man_v,
                [name], ['Artem']).

test(key_rule9,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Sysoev']),

   db_construct(people, man_v,
                [name], ['Sergei']).

test(key_rule10,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v,
                [name], ['Sergei']),

   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Sysoev']).

test(key_rule11,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, citizen_v, [id], [4]),
   db_construct(people, citizen_v, [], []).

test(key_rule12, [setup(db_clear(people))]) :-

   db_construct(people, citizen_v, [id], [4]),
   db_construct(people, man_v, [], []).

test(key_rule13, [setup(db_clear(people))]) :-

   db_construct(people, citizen_v, [id], [4]),
   db_construct(people, man_v, [name], ['James']).

test(key_rule14,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, citizen_v, [id], [4]),
   db_construct(people, man_v, [], []),
   db_construct(people, citizen_v, [id], [5]).

test(key_rule15, [setup(db_clear(people))]) :-

   db_construct(people, citizen_v, [id], [4]),
   db_construct(people, man_v,
                [name, surname], ['James', 'Crick']),
   db_construct(people, citizen_v,
                [name, surname, id], ['Adam', 'Adamovitch', 5]).

test(key_rule16,
     [setup(db_clear(people)),
      error(db_key_exists(people, _, _))]) :-

   db_construct(people, man_v, [name], ['James']),
   db_construct(people, citizen_v, [id], [4]).

test(db_singleton_v1, [setup(db_clear(people))]) :-

   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Lodyagin']),
   db_construct(people, db_singleton_v,
                [key_policy], [overwrite]),
   db_construct(people, man_v, [surname], ['Lodyagin']),

   findall([Name, Surname],
           named_args_unify(people, _, [name, surname],
                            [Name, Surname], _),
           List1),
   assertion(List1 =@= [_, 'Lodyagin']).

model_db :-

	db_clear(people),
	db_clear(people2),

        db_construct(people, man_v,
                     [sex, name, weight], [man, 'Adam', 73]),
        db_construct(people, man_v,
                     [sex, name, weight], [woman, 'Eva', 64]),

        db_construct(people, citizen_v,
                      [sex, name, surname, country],
                      [man, 'Vladimir', 'Mayakovsky',
                       ['Soviet Union']]).

:- end_tests(vd).


[FEATURE] Expand the averages gnuplot file to expand range to 160 concurrent.

set terminal 'pngcairo' size 1920, 1080
set output 'averages.png'
set datafile separator ','
set title 'Average response time versus concurrency level'
set xlabel 'Concurrency level (number of simultaneous users)'
set ylabel 'Average response time (ms.)'
set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 pi -1 ps 1.5
set pointintervalbox 3
set grid
set xrange [0:160]
set yrange [0:5000]
set xtics (0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160)
set ytics 500
plot "averages.csv" using 2:1 with linespoints ls 1 title 'Response time'

set terminal 'pngcairo' size 1920, 1080
set output 'averages.png'
set datafile separator ','
set title 'Average response time versus concurrency level'
set xlabel 'Concurrency level (number of simultaneous users)'
set ylabel 'Average response time (ms.)'
set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 pi -1 ps 1.5
set pointintervalbox 3
set grid
set xrange [0:100]
set yrange [0:5000]
set xtics (0,10,20,30,40,50,60,70,80,90,100)
set ytics 500
plot "averages.csv" using 2:1 with linespoints ls 1 title 'Response time'


done prolt script

done prolt script

set term postscript enhanced color solid 20
set out 'result/benchmark.eps'
set log x
set grid
set xlabel 'Problem Size (NX)'
set ylabel 'Flop/s'
set yrange [0:]
set key left top
set format y "%2.1t{/Symbol \327}10^{%L}"
set format x "10^{%L}"

set label "N_{T}=8"  at 16,1.3e9 rotate by 75 right
set label "N_{T}=16"  at 32,1.6e9 rotate by 75 right
set label "N_{T}=32"  at 64,1.6e9 rotate by 75 right
set label "N_{T}=64"  at 128,1.8e9 rotate by 75 right
set label "N_{T}=128"  at 256,2.0e9 rotate by 75 right
set label "N_{T}=256"  at 512,1.9e9 rotate by 75 right

plot \
     '< grep PiTCH-256 result/analyzed.txt' u 2:3:4:5 w yerr pt 0 lc rgb "#ff0000" t 'PiTCH' , \
     '< grep PiTCH-128 result/analyzed.txt' u 2:3:4:5 w yerr pt 0 lc rgb "#df0000" t '' , \
     '< grep PiTCH-64 result/analyzed.txt'  u 2:3:4:5 w yerr pt 0 lc rgb "#bf0000" t '' , \
     '< grep PiTCH-32 result/analyzed.txt'  u 2:3:4:5 w yerr pt 0 lc rgb "#9f0000" t '' , \
     '< grep PiTCH-16 result/analyzed.txt'  u 2:3:4:5 w yerr pt 0 lc rgb "#7f0000" t '' , \
     '< grep PiTCH-8 result/analyzed.txt'   u 2:3:4:5 w yerr pt 0 lc rgb "#5f0000" t '' , \
     '< grep PiTCH-256 result/analyzed.txt' u 2:3 w l lc rgb "#ff0000" t '' , \
     '< grep PiTCH-128 result/analyzed.txt' u 2:3 w l lc rgb "#df0000" t '' , \
     '< grep PiTCH-64 result/analyzed.txt'  u 2:3 w l lc rgb "#bf0000" t '' , \
     '< grep PiTCH-32 result/analyzed.txt'  u 2:3 w l lc rgb "#9f0000" t '' , \
     '< grep PiTCH-16 result/analyzed.txt'  u 2:3 w l lc rgb "#7f0000" t '' , \
     '< grep PiTCH-8 result/analyzed.txt'   u 2:3 w l lc rgb "#5f0000" t '' , \
     '< grep PiTCHOpt-256 result/analyzed.txt' u 2:3:4:5 w yerr pt 0 lc rgb "#00ff00" t 'Optimized PiTCH' , \
     '< grep PiTCHOpt-128 result/analyzed.txt' u 2:3:4:5 w yerr pt 0 lc rgb "#00df00" t '' , \
     '< grep PiTCHOpt-64 result/analyzed.txt'  u 2:3:4:5 w yerr pt 0 lc rgb "#00bf00" t '' , \
     '< grep PiTCHOpt-32 result/analyzed.txt'  u 2:3:4:5 w yerr pt 0 lc rgb "#009f00" t '' , \
     '< grep PiTCHOpt-16 result/analyzed.txt'  u 2:3:4:5 w yerr pt 0 lc rgb "#007f00" t '' , \
     '< grep PiTCHOpt-8 result/analyzed.txt'   u 2:3:4:5 w yerr pt 0 lc rgb "#005f00" t '' , \
     '< grep PiTCHOpt-256 result/analyzed.txt' u 2:3 w l lc rgb "#00ff00" t '' , \
     '< grep PiTCHOpt-128 result/analyzed.txt' u 2:3 w l lc rgb "#00df00" t '' , \
     '< grep PiTCHOpt-64 result/analyzed.txt'  u 2:3 w l lc rgb "#00bf00" t '' , \
     '< grep PiTCHOpt-32 result/analyzed.txt'  u 2:3 w l lc rgb "#009f00" t '' , \
     '< grep PiTCHOpt-16 result/analyzed.txt'  u 2:3 w l lc rgb "#007f00" t '' , \
     '< grep PiTCHOpt-8 result/analyzed.txt'   u 2:3 w l lc rgb "#005f00" t '' , \
     '< grep NoTB result/analyzed.txt'         u 2:3:4:5 w yerr pt 0 lc rgb "blue" t 'No Blocking' ,\
     '< grep NoTB result/analyzed.txt'         u 2:3 w l lc rgb "blue" t ''

set term postscript enhanced color solid 20
set out 'result/benchmark.eps'
set log x
set grid
set xlabel 'Problem Size (NX^2)'
set ylabel 'Flop/s'
set yrange [0:]
set key left top
set format y "%2.1t{/Symbol \327}10^{%L}"
set format x "10^{%L}"
plot '< grep "PiTCH-" result/benchmark.txt' u ($3**2):8 t 'PiTCH', \
     '< grep PiTCHOpt result/benchmark.txt' u ($3**2):8 t 'Optimized PiTCH' , \
     '< grep NoTB result/benchmark.txt'     u ($3**2):8 t 'No Blocking'


decimate y-axis

decimate y-axis

#!/usr/bin/env gnuplot

# graph of power usage history

# datafiles
ifnameh = "/tmp/kamstrupd/mysql/kamh2.csv"
ifnamed = "/tmp/kamstrupd/mysql/kamd2.csv"
set output "/tmp/kamstrupd/site/img/kamstrup12.png"

# ******************************************************* General settings *****
set terminal png enhanced font "Vera,9" size 1280,320
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid front
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
if (GPVAL_VERSION == 4.6) {epoch_compensate = 946684800} else {if (GPVAL_VERSION == 5.0) {epoch_compensate = 0}}
# Positions of split between graphs
LMARG = 0.06
LMPOS = 0.40
MRPOS = 0.73
RMARG = 0.94

# ************************************************************* Functions ******
# determine delta data
delta(x) = ( xD = x - old_x, old_x = x, xD <= 0 ? 0.1 : xD)
# lg(x)    = ( xL = x, xL == NaN ? NaN : log(xL) )
old_x = NaN

min(x,y) = (x < y) ? x : y
max(x,y) = (x > y) ? x : y

# ********************************************************* Statistics (R) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnameh using 1 name "X" nooutput

Xh_min = X_min + utc_offset - epoch_compensate
Xh_max = X_max + utc_offset - epoch_compensate

# ********************************************************* Statistics (L) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamed using 1 name "X" nooutput
Xw_min = X_min + utc_offset - epoch_compensate
Xw_max = X_max + utc_offset - epoch_compensate

set multiplot layout 1, 2 title "Actueel Verbruik ".strftime("( %Y-%m-%dT%H:%M:%S )", time(0)+utc_offset)

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       LEFT PLOT: past week
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past day"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xw_min : Xw_max ]

# ***************************************************************** Y-axis *****
set ylabel "Verbruik [kWh]"
set yrange [ 0 : 1.6 ]

# ***************************************************************** Legend *****
set key opaque box inside top left
set key samplen 0.1
set key reverse horizontal Left
set key maxcols 2

# ***************************************************************** Output *****
# set arrow from graph 0,graph 0 to graph 0,graph 1 nohead lc rgb "red" front
# set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
#set object 1 rect from screen 0,0 to screen 1,1 behind
#set object 1 rect fc rgb "#eeeeee" fillstyle solid 1.0 noborder
#set object 2 rect from graph 0,0 to graph 1,1 behind
#set object 2 rect fc rgb "#ffffff" fillstyle solid 1.0 noborder

set lmargin at screen LMARG
set rmargin at screen MRPOS

# ***** PLOT *****
set style data boxes
set style fill solid noborder

plot ifnamed \
      using ($1+utc_offset):(delta($2+$3)/1000)  title "T1"  fc "green"  \
  ,'' using ($1+utc_offset):(delta($3)/1000)     title "T2"  fc "yellow"

old_x = NaN

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      RIGHT PLOT: past hour
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past hour"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xh_min : Xh_max ]
set xtics textcolor rgb "red"

# ***************************************************************** Y-axis *****
set ylabel " "
set yrange [ 0 : 0.16 ]
set ytics format " "

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set lmargin at screen MRPOS+0.001
set rmargin at screen RMARG

# ***** PLOT *****
plot ifnameh \
      using ($1+utc_offset):(delta($2+$3)/1000)  title "T1"  fc "green"  \
  ,'' using ($1+utc_offset):(delta($3)/1000)     title "T2"  fc "yellow"

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                 FINALIZING
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

unset multiplot

#!/usr/bin/env gnuplot

# graph of power usage history

# datafiles
ifnameh = "/tmp/kamstrupd/mysql/kamh2.csv"
ifnamed = "/tmp/kamstrupd/mysql/kamd2.csv"
set output "/tmp/kamstrupd/site/img/kamstrup12.png"

# ******************************************************* General settings *****
set terminal png enhanced font "Vera,9" size 1280,320
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid front
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
if (GPVAL_VERSION == 4.6) {epoch_compensate = 946684800} else {if (GPVAL_VERSION == 5.0) {epoch_compensate = 0}}
# Positions of split between graphs
LMARG = 0.06
LMPOS = 0.40
MRPOS = 0.73
RMARG = 0.94

# ************************************************************* Functions ******
# determine delta data
delta(x) = ( xD = x - old_x, old_x = x, xD <= 0 ? 0.1 : xD)
# lg(x)    = ( xL = x, xL == NaN ? NaN : log(xL) )
old_x = NaN

min(x,y) = (x < y) ? x : y
max(x,y) = (x > y) ? x : y

# ********************************************************* Statistics (R) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnameh using 1 name "X" nooutput

Xh_min = X_min + utc_offset - epoch_compensate
Xh_max = X_max + utc_offset - epoch_compensate

# ********************************************************* Statistics (L) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamed using 1 name "X" nooutput
Xw_min = X_min + utc_offset - epoch_compensate
Xw_max = X_max + utc_offset - epoch_compensate

set multiplot layout 1, 2 title "Actueel Verbruik ".strftime("( %Y-%m-%dT%H:%M:%S )", time(0)+utc_offset)

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       LEFT PLOT: past week
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past day"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xw_min : Xw_max ]

# ***************************************************************** Y-axis *****
set ylabel "Verbruik [kWh]"
set yrange [ 0 : 1.6 ]

# ***************************************************************** Legend *****
set key opaque box inside top left
set key samplen 0.1
set key reverse horizontal Left
set key maxcols 2

# ***************************************************************** Output *****
# set arrow from graph 0,graph 0 to graph 0,graph 1 nohead lc rgb "red" front
# set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
#set object 1 rect from screen 0,0 to screen 1,1 behind
#set object 1 rect fc rgb "#eeeeee" fillstyle solid 1.0 noborder
#set object 2 rect from graph 0,0 to graph 1,1 behind
#set object 2 rect fc rgb "#ffffff" fillstyle solid 1.0 noborder

set lmargin at screen LMARG
set rmargin at screen MRPOS

# ***** PLOT *****
set style data boxes
set style fill solid noborder

plot ifnamed \
      using ($1+utc_offset):(delta($2+$3)/1000)  title "T1"  fc "green"  \
  ,'' using ($1+utc_offset):(delta($3)/1000)     title "T2"  fc "yellow"

old_x = NaN

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      RIGHT PLOT: past hour
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past hour"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xh_min : Xh_max ]
set xtics textcolor rgb "red"

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set lmargin at screen MRPOS+0.001
set rmargin at screen RMARG

# ***** PLOT *****
plot ifnameh \
      using ($1+utc_offset):(delta($2+$3)/1000)  title "T1"  fc "green"  \
  ,'' using ($1+utc_offset):(delta($3)/1000)     title "T2"  fc "yellow"

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                 FINALIZING
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

unset multiplot


Update gnuplot file for platform folders

#! /usr/bin/env gnuplot

set terminal svg

set style line 1 lc rgb '#dd181f' lt 1 lw 0.1 pt 5 ps 0.2   # --- red
set style line 2 lc rgb '#0060ad' lt 1 lw 0.1 pt 7 ps 0.2   # --- blue

set xlabel 'Index of HTTP request'
set ylabel 'Time required for completion in nanoseconds'

set yrange [0:300000]

cd 'results'
results = system('ls */*.dat')
do for [result in results] {
	set output sprintf('%s.svg', result[:strlen(result)-4])
	plot result index 0 t 'AsyncSocket' with linespoints ls 1, \
	     result index 1 t 'AsyncTCPConnection' with linespoints ls 2
}

#! /usr/bin/env gnuplot

set terminal svg

set style line 1 lc rgb '#dd181f' lt 1 lw 0.1 pt 5 ps 0.2   # --- red
set style line 2 lc rgb '#0060ad' lt 1 lw 0.1 pt 7 ps 0.2   # --- blue

set xlabel 'Index of HTTP request'
set ylabel 'Time required for completion in nanoseconds'

set yrange [0:300000]

cd 'results'
results = system('ls *.dat')
do for [result in results] {
	set output sprintf('%s.svg', result[:strlen(result)-4])
	plot result index 0 t 'AsyncSocket' with linespoints ls 1, \
	     result index 1 t 'AsyncTCPConnection' with linespoints ls 2
}


rrepair, eval: add a column definition for the expected_delta added by 2b818c3f83

col_id = 1
col_nodes = 2
col_dbsize = 3
col_fprob = 4
col_round = 5
col_recon_p1e = 6
col_merkle_bucket = 7
col_merkle_branch = 8
col_art_corr_factor = 9
col_art_leaf_fpr = 10
col_art_inner_fpr = 11
col_missing = 12
col_regen = 13
col_outdated = 14
col_updated = 15
col_bw_rc_size = 16
col_bw_rc_msg = 17
col_bw_rc2_size = 18
col_bw_rc2_msg = 19
col_bw_rs_size = 20
col_bw_rs_msg = 21
col_bw_rs_kvv = 22
col_sd_missing = 23
col_sd_regen = 24
col_sd_outdated = 25
col_sd_updated = 26
col_sd_bw_rc_size = 27
col_sd_bw_rc_msg = 28
col_sd_bw_rc2_size = 29
col_sd_bw_rc2_msg = 30
col_sd_bw_rs_size = 31
col_sd_bw_rs_msg = 32
col_sd_bw_rs_kvv = 33
col_min_missing = 34
col_max_missing = 35
col_min_regen = 36
col_max_regen = 37
col_min_outdated = 38
col_max_outdated = 39
col_min_updated = 40
col_max_updated = 41
col_min_bw_rc_size = 42
col_max_bw_rc_size = 43
col_min_rc_msg = 44
col_max_rc_msg = 45
col_min_bw_rc2_size = 46
col_max_bw_rc2_size = 47
col_min_rc2_msg = 48
col_max_rc2_msg = 49
col_min_bw_rs_size = 50
col_max_bw_rs_size = 51
col_min_bw_rs_msg = 52
col_max_bw_rs_msg = 53
col_min_bw_rs_kvv = 54
col_max_bw_rs_kvv = 55
col_rc_method = 56
col_ring_type = 57
col_ddist = 58
col_ftype = 59
col_fdist = 60
col_dtype = 61
col_tprob = 62
col_merkle_num_trees = 63
col_p1e_p1 = 64
col_sd_p1e_p1 = 65
col_min_p1e_p1 = 66
col_max_p1e_p1 = 67
col_p1e_p2 = 68
col_sd_p1e_p2 = 69
col_min_p1e_p2 = 70
col_max_p1e_p2 = 71
col_p1e = 72
col_sd_p1e = 73
col_min_p1e = 74
col_max_p1e = 75
col_exp_delta = 76


new mods to mp stuff changed file size

new mods to mp stuff changed file size

git-svn-id: 0ef30dc7da0b07cedfa074587325a6c153c0ae55@6819 fdbf22ae-c210-0410-be80-ca943da6b8f8