Debian Codegraph @

tests/spec/unit/general/test_rounding_b.mzn

raw
1 /***
2 !Test
3 check_against: []
4 expected:
5 - !Result
6 solution:
7 - !Solution
8 _output_item: 0.00, 0, 0, 0 OK
9 x: 0.0
10 - !Solution
11 _output_item: 0.25, 1, 0, 0 OK
12 x: 0.25
13 - !Solution
14 _output_item: 0.50, 1, 0, 1 OK
15 x: 0.5
16 - !Solution
17 _output_item: 0.75, 1, 0, 1 OK
18 x: 0.75
19 - !Solution
20 _output_item: 1.00, 1, 1, 1 OK
21 x: 1.0
22 - !Solution
23 _output_item: 1.25, 2, 1, 1 OK
24 x: 1.25
25 - !Solution
26 _output_item: 1.50, 2, 1, 2 OK
27 x: 1.5
28 - !Solution
29 _output_item: 1.75, 2, 1, 2 OK
30 x: 1.75
31 - !Solution
32 _output_item: 2.00, 2, 2, 2 OK
33 x: 2.0
34 status: ALL_SOLUTIONS
35 extra_files: []
36 markers: []
37 name: ''
38 options:
39 all_solutions: true
40 solvers:
41 - gecode
42 type: solve
43
44 ***/
45
46 var 0.0..2.0: x;
47 var int: c = ceil(x);
48 var int: f = floor(x);
49 var int: r = round(x);
50
51 constraint exists(i in [-2.0, -1.75, -1.5, -1.25, -1.0, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0])(x=i);
52
53 output [ format(2, 2, x) ++ ", \(c), \(f), \(r) " ++ let {
54 constraint assert(fix(c)=ceil(fix(x)), "incorrect ceil");
55 constraint assert(fix(f)=floor(fix(x)), "incorrect floor");
56 constraint assert(fix(r)=round(fix(x)), "incorrect round"); } in "OK" ];