Post expression
| 76 | } |
| 77 | /// Post expression |
| 78 | virtual IntVar post(Home home, IntVar* ret, |
| 79 | const IntPropLevels& ipls) const { |
| 80 | IntVar y; |
| 81 | switch (t) { |
| 82 | case ANLE_ABS: |
| 83 | { |
| 84 | IntVar x = a[0].post(home, ipls); |
| 85 | if (x.min() >= 0) |
| 86 | y = result(home,ret,x); |
| 87 | else { |
| 88 | y = result(home,ret); |
| 89 | abs(home, x, y, ipls.abs()); |
| 90 | } |
| 91 | } |
| 92 | break; |
| 93 | case ANLE_MIN: |
| 94 | if (n==1) { |
| 95 | y = result(home,ret, a[0].post(home, ipls)); |
| 96 | } else if (n==2) { |
| 97 | IntVar x0 = a[0].post(home, ipls); |
| 98 | IntVar x1 = a[1].post(home, ipls); |
| 99 | if (x0.max() <= x1.min()) |
| 100 | y = result(home,ret,x0); |
| 101 | else if (x1.max() <= x0.min()) |
| 102 | y = result(home,ret,x1); |
| 103 | else { |
| 104 | y = result(home,ret); |
| 105 | min(home, x0, x1, y, ipls.min2()); |
| 106 | } |
| 107 | } else { |
| 108 | IntVarArgs x(n); |
| 109 | for (int i=n; i--;) |
| 110 | x[i] = a[i].post(home, ipls); |
| 111 | y = result(home,ret); |
| 112 | min(home, x, y, ipls.min()); |
| 113 | } |
| 114 | break; |
| 115 | case ANLE_MAX: |
| 116 | if (n==1) { |
| 117 | y = result(home,ret,a[0].post(home, ipls)); |
| 118 | } else if (n==2) { |
| 119 | IntVar x0 = a[0].post(home, ipls); |
| 120 | IntVar x1 = a[1].post(home, ipls); |
| 121 | if (x0.max() <= x1.min()) |
| 122 | y = result(home,ret,x1); |
| 123 | else if (x1.max() <= x0.min()) |
| 124 | y = result(home,ret,x0); |
| 125 | else { |
| 126 | y = result(home,ret); |
| 127 | max(home, x0, x1, y, ipls.max2()); |
| 128 | } |
| 129 | } else { |
| 130 | IntVarArgs x(n); |
| 131 | for (int i=n; i--;) |
| 132 | x[i] = a[i].post(home, ipls); |
| 133 | y = result(home,ret); |
| 134 | max(home, x, y, ipls.max()); |
| 135 | } |