gecoder-with-gecode 0.8.3 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (337) hide show
  1. data/CHANGES +15 -0
  2. data/README +6 -2
  3. data/example/equation_system.rb +15 -0
  4. data/example/magic_sequence.rb +7 -7
  5. data/example/money.rb +36 -0
  6. data/example/queens.rb +7 -8
  7. data/example/send_most_money.rb +1 -1
  8. data/example/square_tiling.rb +2 -2
  9. data/example/sudoku-set.rb +11 -12
  10. data/example/sudoku.rb +40 -45
  11. data/ext/extconf.rb +0 -0
  12. data/ext/gecode-2.1.1/LICENSE +0 -0
  13. data/ext/gecode-2.1.1/configure +0 -0
  14. data/ext/gecode-2.1.1/contribs/qecode/SDFVariableHeuristic.cc +0 -0
  15. data/ext/gecode-2.1.1/contribs/qecode/SDFVariableHeuristic.hh +0 -0
  16. data/ext/gecode-2.1.1/contribs/qecode/configure +0 -0
  17. data/ext/gecode-2.1.1/contribs/qecode/extensivecomparator.cc +0 -0
  18. data/ext/gecode-2.1.1/contribs/qecode/extensivecomparator.hh +0 -0
  19. data/ext/gecode-2.1.1/contribs/qecode/heap.cc +0 -0
  20. data/ext/gecode-2.1.1/contribs/qecode/implicative.cc +0 -0
  21. data/ext/gecode-2.1.1/contribs/qecode/implicative.hh +0 -0
  22. data/ext/gecode-2.1.1/contribs/qecode/myspace.cc +0 -0
  23. data/ext/gecode-2.1.1/contribs/qecode/myspace.hh +0 -0
  24. data/ext/gecode-2.1.1/contribs/qecode/qecore.cc +0 -0
  25. data/ext/gecode-2.1.1/contribs/qecode/qecore.hh +0 -0
  26. data/ext/gecode-2.1.1/contribs/qecode/warner.cc +0 -0
  27. data/ext/gecode-2.1.1/contribs/qecode/warner.hh +0 -0
  28. data/ext/gecode-2.1.1/gecode/cpltset/var-imp/cpltset.vis +0 -0
  29. data/ext/gecode-2.1.1/gecode/int/arithmetic/abs.icc +0 -0
  30. data/ext/gecode-2.1.1/gecode/int/arithmetic/max.icc +0 -0
  31. data/ext/gecode-2.1.1/gecode/int/arithmetic/mult.icc +0 -0
  32. data/ext/gecode-2.1.1/gecode/int/arithmetic/sqr.icc +0 -0
  33. data/ext/gecode-2.1.1/gecode/int/arithmetic/sqrt.icc +0 -0
  34. data/ext/gecode-2.1.1/gecode/int/array.cc +0 -0
  35. data/ext/gecode-2.1.1/gecode/int/array.icc +0 -0
  36. data/ext/gecode-2.1.1/gecode/int/bool/base.icc +0 -0
  37. data/ext/gecode-2.1.1/gecode/int/bool/eq.icc +0 -0
  38. data/ext/gecode-2.1.1/gecode/int/bool/eqv.icc +0 -0
  39. data/ext/gecode-2.1.1/gecode/int/bool/lq.icc +0 -0
  40. data/ext/gecode-2.1.1/gecode/int/bool/or.icc +0 -0
  41. data/ext/gecode-2.1.1/gecode/int/branch/select-val.icc +0 -0
  42. data/ext/gecode-2.1.1/gecode/int/branch/select-view.icc +0 -0
  43. data/ext/gecode-2.1.1/gecode/int/branch.cc +0 -0
  44. data/ext/gecode-2.1.1/gecode/int/branch.hh +0 -0
  45. data/ext/gecode-2.1.1/gecode/int/channel/base.icc +0 -0
  46. data/ext/gecode-2.1.1/gecode/int/channel/dom.icc +0 -0
  47. data/ext/gecode-2.1.1/gecode/int/channel/link-multi.cc +0 -0
  48. data/ext/gecode-2.1.1/gecode/int/channel/link-multi.icc +0 -0
  49. data/ext/gecode-2.1.1/gecode/int/channel/link-single.cc +0 -0
  50. data/ext/gecode-2.1.1/gecode/int/channel/link-single.icc +0 -0
  51. data/ext/gecode-2.1.1/gecode/int/channel/val.icc +0 -0
  52. data/ext/gecode-2.1.1/gecode/int/channel.cc +0 -0
  53. data/ext/gecode-2.1.1/gecode/int/channel.hh +0 -0
  54. data/ext/gecode-2.1.1/gecode/int/circuit/base.icc +0 -0
  55. data/ext/gecode-2.1.1/gecode/int/circuit/dom.icc +0 -0
  56. data/ext/gecode-2.1.1/gecode/int/circuit/val.icc +0 -0
  57. data/ext/gecode-2.1.1/gecode/int/circuit.cc +0 -0
  58. data/ext/gecode-2.1.1/gecode/int/circuit.hh +0 -0
  59. data/ext/gecode-2.1.1/gecode/int/count/int.icc +0 -0
  60. data/ext/gecode-2.1.1/gecode/int/count/rel.icc +0 -0
  61. data/ext/gecode-2.1.1/gecode/int/count/view.icc +0 -0
  62. data/ext/gecode-2.1.1/gecode/int/distinct/bilink.icc +0 -0
  63. data/ext/gecode-2.1.1/gecode/int/distinct/bnd.icc +0 -0
  64. data/ext/gecode-2.1.1/gecode/int/distinct/combptr.icc +0 -0
  65. data/ext/gecode-2.1.1/gecode/int/distinct/dom.icc +0 -0
  66. data/ext/gecode-2.1.1/gecode/int/distinct/edge.icc +0 -0
  67. data/ext/gecode-2.1.1/gecode/int/distinct/node.icc +0 -0
  68. data/ext/gecode-2.1.1/gecode/int/distinct/ter-dom.icc +0 -0
  69. data/ext/gecode-2.1.1/gecode/int/distinct/val.icc +0 -0
  70. data/ext/gecode-2.1.1/gecode/int/dom/range.icc +0 -0
  71. data/ext/gecode-2.1.1/gecode/int/dom/spec.icc +0 -0
  72. data/ext/gecode-2.1.1/gecode/int/dom.cc +0 -0
  73. data/ext/gecode-2.1.1/gecode/int/dom.hh +0 -0
  74. data/ext/gecode-2.1.1/gecode/int/element/int.icc +0 -0
  75. data/ext/gecode-2.1.1/gecode/int/element/view.icc +0 -0
  76. data/ext/gecode-2.1.1/gecode/int/element.cc +0 -0
  77. data/ext/gecode-2.1.1/gecode/int/element.hh +0 -0
  78. data/ext/gecode-2.1.1/gecode/int/exception.icc +0 -0
  79. data/ext/gecode-2.1.1/gecode/int/extensional/dfa.cc +0 -0
  80. data/ext/gecode-2.1.1/gecode/int/extensional/dfa.icc +0 -0
  81. data/ext/gecode-2.1.1/gecode/int/extensional/layered-graph.icc +0 -0
  82. data/ext/gecode-2.1.1/gecode/int/gcc/dom.icc +0 -0
  83. data/ext/gecode-2.1.1/gecode/int/gcc/gccbndsup.icc +0 -0
  84. data/ext/gecode-2.1.1/gecode/int/gcc/lbc.icc +0 -0
  85. data/ext/gecode-2.1.1/gecode/int/gcc/ubc.icc +0 -0
  86. data/ext/gecode-2.1.1/gecode/int/gcc.cc +0 -0
  87. data/ext/gecode-2.1.1/gecode/int/gcc.hh +0 -0
  88. data/ext/gecode-2.1.1/gecode/int/int-set.cc +0 -0
  89. data/ext/gecode-2.1.1/gecode/int/int-set.icc +0 -0
  90. data/ext/gecode-2.1.1/gecode/int/linear/bool-int.icc +0 -0
  91. data/ext/gecode-2.1.1/gecode/int/linear/bool-post.cc +0 -0
  92. data/ext/gecode-2.1.1/gecode/int/linear/bool-scale.icc +0 -0
  93. data/ext/gecode-2.1.1/gecode/int/linear/bool-view.icc +0 -0
  94. data/ext/gecode-2.1.1/gecode/int/linear/int-bin.icc +0 -0
  95. data/ext/gecode-2.1.1/gecode/int/linear/int-dom.icc +0 -0
  96. data/ext/gecode-2.1.1/gecode/int/linear/int-nary.icc +0 -0
  97. data/ext/gecode-2.1.1/gecode/int/linear/int-post.cc +0 -0
  98. data/ext/gecode-2.1.1/gecode/int/linear/int-ter.icc +0 -0
  99. data/ext/gecode-2.1.1/gecode/int/linear/post.icc +0 -0
  100. data/ext/gecode-2.1.1/gecode/int/propagator.icc +0 -0
  101. data/ext/gecode-2.1.1/gecode/int/rel/eq.icc +0 -0
  102. data/ext/gecode-2.1.1/gecode/int/rel/lex.icc +0 -0
  103. data/ext/gecode-2.1.1/gecode/int/rel/lq-le.icc +0 -0
  104. data/ext/gecode-2.1.1/gecode/int/rel/nq.icc +0 -0
  105. data/ext/gecode-2.1.1/gecode/int/unshare.cc +0 -0
  106. data/ext/gecode-2.1.1/gecode/int/var/bool.cc +0 -0
  107. data/ext/gecode-2.1.1/gecode/int/var-imp/bool.cc +0 -0
  108. data/ext/gecode-2.1.1/gecode/int/var-imp/bool.icc +0 -0
  109. data/ext/gecode-2.1.1/gecode/int/var-imp/bool.vis +0 -0
  110. data/ext/gecode-2.1.1/gecode/int/var-imp/delta.icc +0 -0
  111. data/ext/gecode-2.1.1/gecode/int/var-imp/int.icc +0 -0
  112. data/ext/gecode-2.1.1/gecode/int/var-imp/int.vis +0 -0
  113. data/ext/gecode-2.1.1/gecode/int/view/bool.icc +0 -0
  114. data/ext/gecode-2.1.1/gecode/int/view/constint.icc +0 -0
  115. data/ext/gecode-2.1.1/gecode/int/view/int.icc +0 -0
  116. data/ext/gecode-2.1.1/gecode/int/view/iter.icc +0 -0
  117. data/ext/gecode-2.1.1/gecode/int/view/minus.icc +0 -0
  118. data/ext/gecode-2.1.1/gecode/int/view/offset.icc +0 -0
  119. data/ext/gecode-2.1.1/gecode/int/view/print.cc +0 -0
  120. data/ext/gecode-2.1.1/gecode/int/view/rtest.icc +0 -0
  121. data/ext/gecode-2.1.1/gecode/int/view/scale.icc +0 -0
  122. data/ext/gecode-2.1.1/gecode/int/view/zero.icc +0 -0
  123. data/ext/gecode-2.1.1/gecode/int/view.icc +0 -0
  124. data/ext/gecode-2.1.1/gecode/iter/ranges-add.icc +0 -0
  125. data/ext/gecode-2.1.1/gecode/iter/ranges-append.icc +0 -0
  126. data/ext/gecode-2.1.1/gecode/iter/ranges-array.icc +0 -0
  127. data/ext/gecode-2.1.1/gecode/iter/ranges-cache.icc +0 -0
  128. data/ext/gecode-2.1.1/gecode/iter/ranges-compl.icc +0 -0
  129. data/ext/gecode-2.1.1/gecode/iter/ranges-diff.icc +0 -0
  130. data/ext/gecode-2.1.1/gecode/iter/ranges-empty.icc +0 -0
  131. data/ext/gecode-2.1.1/gecode/iter/ranges-inter.icc +0 -0
  132. data/ext/gecode-2.1.1/gecode/iter/ranges-minmax.icc +0 -0
  133. data/ext/gecode-2.1.1/gecode/iter/ranges-minus.icc +0 -0
  134. data/ext/gecode-2.1.1/gecode/iter/ranges-offset.icc +0 -0
  135. data/ext/gecode-2.1.1/gecode/iter/ranges-operations.icc +0 -0
  136. data/ext/gecode-2.1.1/gecode/iter/ranges-scale.icc +0 -0
  137. data/ext/gecode-2.1.1/gecode/iter/ranges-singleton-append.icc +0 -0
  138. data/ext/gecode-2.1.1/gecode/iter/ranges-singleton.icc +0 -0
  139. data/ext/gecode-2.1.1/gecode/iter/ranges-union.icc +0 -0
  140. data/ext/gecode-2.1.1/gecode/iter/ranges-values.icc +0 -0
  141. data/ext/gecode-2.1.1/gecode/iter/values-array.icc +0 -0
  142. data/ext/gecode-2.1.1/gecode/iter/values-minus.icc +0 -0
  143. data/ext/gecode-2.1.1/gecode/iter/values-offset.icc +0 -0
  144. data/ext/gecode-2.1.1/gecode/iter/values-ranges.icc +0 -0
  145. data/ext/gecode-2.1.1/gecode/iter/values-singleton.icc +0 -0
  146. data/ext/gecode-2.1.1/gecode/iter/values-unique.icc +0 -0
  147. data/ext/gecode-2.1.1/gecode/iter.hh +0 -0
  148. data/ext/gecode-2.1.1/gecode/kernel/advisor.icc +0 -0
  149. data/ext/gecode-2.1.1/gecode/kernel/array.icc +0 -0
  150. data/ext/gecode-2.1.1/gecode/kernel/branching.icc +0 -0
  151. data/ext/gecode-2.1.1/gecode/kernel/exception.icc +0 -0
  152. data/ext/gecode-2.1.1/gecode/kernel/macros.icc +0 -0
  153. data/ext/gecode-2.1.1/gecode/kernel/memory-manager.icc +0 -0
  154. data/ext/gecode-2.1.1/gecode/kernel/modevent.icc +0 -0
  155. data/ext/gecode-2.1.1/gecode/kernel/propagator.icc +0 -0
  156. data/ext/gecode-2.1.1/gecode/kernel/shared-array.icc +0 -0
  157. data/ext/gecode-2.1.1/gecode/kernel/var-traits.icc +0 -0
  158. data/ext/gecode-2.1.1/gecode/kernel/var.icc +0 -0
  159. data/ext/gecode-2.1.1/gecode/kernel/view.icc +0 -0
  160. data/ext/gecode-2.1.1/gecode/kernel.hh +0 -0
  161. data/ext/gecode-2.1.1/gecode/minimodel/arithmetic.cc +0 -0
  162. data/ext/gecode-2.1.1/gecode/minimodel/bool-expr.cc +0 -0
  163. data/ext/gecode-2.1.1/gecode/minimodel/bool-expr.icc +0 -0
  164. data/ext/gecode-2.1.1/gecode/minimodel/bool-rel.icc +0 -0
  165. data/ext/gecode-2.1.1/gecode/minimodel/lin-expr.icc +0 -0
  166. data/ext/gecode-2.1.1/gecode/minimodel/lin-rel.icc +0 -0
  167. data/ext/gecode-2.1.1/gecode/minimodel/reg.cc +0 -0
  168. data/ext/gecode-2.1.1/gecode/minimodel.hh +0 -0
  169. data/ext/gecode-2.1.1/gecode/search/bab.cc +0 -0
  170. data/ext/gecode-2.1.1/gecode/search/bab.icc +0 -0
  171. data/ext/gecode-2.1.1/gecode/search/dfs.cc +0 -0
  172. data/ext/gecode-2.1.1/gecode/search/dfs.icc +0 -0
  173. data/ext/gecode-2.1.1/gecode/search/engine-ctrl.icc +0 -0
  174. data/ext/gecode-2.1.1/gecode/search/lds.cc +0 -0
  175. data/ext/gecode-2.1.1/gecode/search/lds.icc +0 -0
  176. data/ext/gecode-2.1.1/gecode/search/options.cc +0 -0
  177. data/ext/gecode-2.1.1/gecode/search/options.icc +0 -0
  178. data/ext/gecode-2.1.1/gecode/search/reco-stack.icc +0 -0
  179. data/ext/gecode-2.1.1/gecode/search/restart.icc +0 -0
  180. data/ext/gecode-2.1.1/gecode/search/statistics.icc +0 -0
  181. data/ext/gecode-2.1.1/gecode/search/stop.cc +0 -0
  182. data/ext/gecode-2.1.1/gecode/search/stop.icc +0 -0
  183. data/ext/gecode-2.1.1/gecode/set/var-imp/set.vis +0 -0
  184. data/ext/gecode-2.1.1/gecode/support/block-allocator.icc +0 -0
  185. data/ext/gecode-2.1.1/gecode/support/cast.icc +0 -0
  186. data/ext/gecode-2.1.1/gecode/support/exception.cc +0 -0
  187. data/ext/gecode-2.1.1/gecode/support/exception.icc +0 -0
  188. data/ext/gecode-2.1.1/gecode/support/macros.icc +0 -0
  189. data/ext/gecode-2.1.1/gecode/support/marked-pointer.icc +0 -0
  190. data/ext/gecode-2.1.1/gecode/support/memory.icc +0 -0
  191. data/ext/gecode-2.1.1/gecode/support/sentinel-stack.icc +0 -0
  192. data/ext/gecode-2.1.1/gecode/support/static-stack.icc +0 -0
  193. data/ext/gecode-2.1.1/gecode/support/symbol.cc +0 -0
  194. data/ext/gecode-2.1.1/gecode/support.hh +0 -0
  195. data/ext/gecode-2.1.1/install-sh +0 -0
  196. data/ext/gecode-2.1.1/misc/debian/rules +0 -0
  197. data/ext/gecode-2.1.1/misc/doxygen/back.png +0 -0
  198. data/ext/gecode-2.1.1/misc/doxygen/gecode-logo-100.png +0 -0
  199. data/ext/gecode-2.1.1/misc/genchangelog.perl +0 -0
  200. data/ext/gecode-2.1.1/misc/genlicense.perl +0 -0
  201. data/ext/gecode-2.1.1/misc/genstatistics.perl +0 -0
  202. data/ext/gecode-2.1.1/misc/genvariables.perl +0 -0
  203. data/ext/gecode-2.1.1/misc/getrevision.perl +0 -0
  204. data/ext/gecode-2.1.1/misc/makedepend.perl +0 -0
  205. data/ext/gecode-2.1.1/misc/svn-ignore.txt +0 -0
  206. data/ext/gecode-2.1.1/variables.vsl +0 -0
  207. data/lib/gecoder/bindings/bindings.rb +16 -0
  208. data/lib/gecoder/bindings.rb +42 -0
  209. data/lib/gecoder/interface/branch.rb +16 -9
  210. data/lib/gecoder/interface/constraints/bool/boolean.rb +205 -213
  211. data/lib/gecoder/interface/constraints/bool/channel.rb +4 -5
  212. data/lib/gecoder/interface/constraints/bool/linear.rb +192 -21
  213. data/lib/gecoder/interface/constraints/bool_enum/channel.rb +43 -39
  214. data/lib/gecoder/interface/constraints/bool_enum/extensional.rb +43 -49
  215. data/lib/gecoder/interface/constraints/bool_enum/relation.rb +38 -71
  216. data/lib/gecoder/interface/constraints/bool_enum_constraints.rb +73 -22
  217. data/lib/gecoder/interface/constraints/bool_var_constraints.rb +140 -61
  218. data/lib/gecoder/interface/constraints/extensional_regexp.rb +4 -4
  219. data/lib/gecoder/interface/constraints/fixnum_enum/element.rb +63 -0
  220. data/lib/gecoder/interface/constraints/fixnum_enum/operation.rb +65 -0
  221. data/lib/gecoder/interface/constraints/fixnum_enum_constraints.rb +42 -0
  222. data/lib/gecoder/interface/constraints/int/arithmetic.rb +131 -130
  223. data/lib/gecoder/interface/constraints/int/channel.rb +21 -31
  224. data/lib/gecoder/interface/constraints/int/domain.rb +45 -42
  225. data/lib/gecoder/interface/constraints/int/linear.rb +85 -239
  226. data/lib/gecoder/interface/constraints/int/relation.rb +141 -0
  227. data/lib/gecoder/interface/constraints/int_enum/arithmetic.rb +55 -64
  228. data/lib/gecoder/interface/constraints/int_enum/channel.rb +35 -37
  229. data/lib/gecoder/interface/constraints/int_enum/count.rb +53 -78
  230. data/lib/gecoder/interface/constraints/int_enum/distinct.rb +36 -46
  231. data/lib/gecoder/interface/constraints/int_enum/element.rb +39 -57
  232. data/lib/gecoder/interface/constraints/int_enum/equality.rb +15 -19
  233. data/lib/gecoder/interface/constraints/int_enum/extensional.rb +65 -72
  234. data/lib/gecoder/interface/constraints/int_enum/sort.rb +42 -45
  235. data/lib/gecoder/interface/constraints/int_enum_constraints.rb +79 -22
  236. data/lib/gecoder/interface/constraints/int_var_constraints.rb +215 -44
  237. data/lib/gecoder/interface/constraints/reifiable_constraints.rb +14 -14
  238. data/lib/gecoder/interface/constraints/selected_set/select.rb +120 -0
  239. data/lib/gecoder/interface/constraints/selected_set_constraints.rb +75 -0
  240. data/lib/gecoder/interface/constraints/set/cardinality.rb +43 -53
  241. data/lib/gecoder/interface/constraints/set/channel.rb +26 -29
  242. data/lib/gecoder/interface/constraints/set/connection.rb +89 -152
  243. data/lib/gecoder/interface/constraints/set/domain.rb +112 -65
  244. data/lib/gecoder/interface/constraints/set/include.rb +36 -0
  245. data/lib/gecoder/interface/constraints/set/operation.rb +96 -110
  246. data/lib/gecoder/interface/constraints/set/relation.rb +114 -137
  247. data/lib/gecoder/interface/constraints/set_elements/relation.rb +116 -0
  248. data/lib/gecoder/interface/constraints/set_elements_constraints.rb +97 -0
  249. data/lib/gecoder/interface/constraints/set_enum/channel.rb +23 -27
  250. data/lib/gecoder/interface/constraints/set_enum/distinct.rb +18 -19
  251. data/lib/gecoder/interface/constraints/set_enum/operation.rb +62 -53
  252. data/lib/gecoder/interface/constraints/set_enum/select.rb +79 -0
  253. data/lib/gecoder/interface/constraints/set_enum_constraints.rb +73 -23
  254. data/lib/gecoder/interface/constraints/set_var_constraints.rb +222 -57
  255. data/lib/gecoder/interface/constraints.rb +410 -451
  256. data/lib/gecoder/interface/enum_matrix.rb +4 -4
  257. data/lib/gecoder/interface/enum_wrapper.rb +71 -22
  258. data/lib/gecoder/interface/model.rb +167 -12
  259. data/lib/gecoder/interface/model_sugar.rb +84 -0
  260. data/lib/gecoder/interface/search.rb +30 -18
  261. data/lib/gecoder/interface/variables.rb +103 -33
  262. data/lib/gecoder/interface.rb +2 -1
  263. data/lib/gecoder/version.rb +2 -2
  264. data/specs/bool_var.rb +19 -12
  265. data/specs/constraints/{boolean.rb → bool/boolean.rb} +103 -28
  266. data/specs/constraints/bool/boolean_properties.rb +51 -0
  267. data/specs/constraints/bool/linear.rb +213 -0
  268. data/specs/constraints/bool_enum/bool_enum_relation.rb +117 -0
  269. data/specs/constraints/bool_enum/channel.rb +102 -0
  270. data/specs/constraints/{extensional.rb → bool_enum/extensional.rb} +32 -101
  271. data/specs/constraints/constraint_helper.rb +149 -179
  272. data/specs/constraints/constraint_receivers.rb +103 -0
  273. data/specs/constraints/constraints.rb +6 -63
  274. data/specs/constraints/fixnum_enum/element.rb +58 -0
  275. data/specs/constraints/fixnum_enum/operation.rb +67 -0
  276. data/specs/constraints/int/arithmetic.rb +149 -0
  277. data/specs/constraints/int/channel.rb +101 -0
  278. data/specs/constraints/int/domain.rb +106 -0
  279. data/specs/constraints/int/linear.rb +183 -0
  280. data/specs/constraints/int/linear_properties.rb +97 -0
  281. data/specs/constraints/int/relation.rb +84 -0
  282. data/specs/constraints/int_enum/arithmetic.rb +72 -0
  283. data/specs/constraints/int_enum/channel.rb +57 -0
  284. data/specs/constraints/int_enum/count.rb +72 -0
  285. data/specs/constraints/int_enum/distinct.rb +80 -0
  286. data/specs/constraints/int_enum/element.rb +61 -0
  287. data/specs/constraints/int_enum/equality.rb +29 -0
  288. data/specs/constraints/int_enum/extensional.rb +224 -0
  289. data/specs/constraints/int_enum/sort.rb +167 -0
  290. data/specs/constraints/operands.rb +264 -0
  291. data/specs/constraints/property_helper.rb +443 -0
  292. data/specs/constraints/reification_sugar.rb +4 -5
  293. data/specs/constraints/selected_set/select.rb +56 -0
  294. data/specs/constraints/selected_set/select_properties.rb +157 -0
  295. data/specs/constraints/set/cardinality.rb +58 -0
  296. data/specs/constraints/set/cardinality_properties.rb +46 -0
  297. data/specs/constraints/set/channel.rb +77 -0
  298. data/specs/constraints/set/connection.rb +176 -0
  299. data/specs/constraints/set/domain.rb +197 -0
  300. data/specs/constraints/set/include.rb +36 -0
  301. data/specs/constraints/set/operation.rb +132 -0
  302. data/specs/constraints/set/relation.rb +117 -0
  303. data/specs/constraints/set_elements/relation.rb +84 -0
  304. data/specs/constraints/set_enum/channel.rb +80 -0
  305. data/specs/constraints/set_enum/distinct.rb +59 -0
  306. data/specs/constraints/set_enum/operation.rb +111 -0
  307. data/specs/constraints/set_enum/select.rb +73 -0
  308. data/specs/enum_wrapper.rb +53 -3
  309. data/specs/int_var.rb +44 -25
  310. data/specs/model.rb +58 -1
  311. data/specs/model_sugar.rb +30 -0
  312. data/specs/search.rb +24 -5
  313. data/specs/selected_set.rb +39 -0
  314. data/specs/set_elements.rb +34 -0
  315. data/specs/set_var.rb +22 -8
  316. data/specs/spec_helper.rb +206 -6
  317. data/tasks/distribution.rake +22 -7
  318. data/tasks/svn.rake +3 -1
  319. metadata +219 -135
  320. data/lib/gecoder/interface/constraints/set_enum/selection.rb +0 -217
  321. data/specs/constraints/arithmetic.rb +0 -351
  322. data/specs/constraints/bool_enum_relation.rb +0 -160
  323. data/specs/constraints/cardinality.rb +0 -157
  324. data/specs/constraints/channel.rb +0 -454
  325. data/specs/constraints/connection.rb +0 -369
  326. data/specs/constraints/count.rb +0 -146
  327. data/specs/constraints/distinct.rb +0 -164
  328. data/specs/constraints/element.rb +0 -108
  329. data/specs/constraints/equality.rb +0 -31
  330. data/specs/constraints/int_domain.rb +0 -70
  331. data/specs/constraints/int_relation.rb +0 -82
  332. data/specs/constraints/linear.rb +0 -340
  333. data/specs/constraints/selection.rb +0 -292
  334. data/specs/constraints/set_domain.rb +0 -185
  335. data/specs/constraints/set_operation.rb +0 -285
  336. data/specs/constraints/set_relation.rb +0 -197
  337. data/specs/constraints/sort.rb +0 -179
@@ -1,108 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require File.dirname(__FILE__) + '/constraint_helper'
3
-
4
- class ElementSampleProblem < Gecode::Model
5
- attr :prices
6
- attr :store
7
- attr :price
8
- attr :fixnum_prices
9
-
10
- def initialize
11
- prices = [17, 63, 45, 63]
12
- @fixnum_prices = wrap_enum(prices)
13
- @prices = int_var_array(4, prices)
14
- @store = int_var(0...prices.size)
15
- @price = int_var(prices)
16
- branch_on wrap_enum([@store])
17
- end
18
- end
19
-
20
- describe Gecode::Constraints::IntEnum::Element do
21
- before do
22
- @model = ElementSampleProblem.new
23
- @prices = @model.prices
24
- @target = @price = @model.price
25
- @store = @model.store
26
- @fixnum_prices = @model.fixnum_prices
27
-
28
- # Creates an expectation corresponding to the specified input.
29
- @expect = lambda do |element, relation, target, strength, kind, reif_var, negated|
30
- @model.allow_space_access do
31
- target = an_instance_of(Gecode::Raw::IntVar) if target.respond_to? :bind
32
- element = an_instance_of(Gecode::Raw::IntVar) if element.respond_to? :bind
33
- if reif_var.nil?
34
- if !negated and relation == Gecode::Raw::IRT_EQ and
35
- !target.kind_of? Fixnum
36
- Gecode::Raw.should_receive(:element).once.with(
37
- an_instance_of(Gecode::Raw::Space),
38
- an_instance_of(Gecode::Raw::IntVarArray),
39
- element, target, strength, kind)
40
- else
41
- Gecode::Raw.should_receive(:element).once.with(
42
- an_instance_of(Gecode::Raw::Space),
43
- an_instance_of(Gecode::Raw::IntVarArray),
44
- element, an_instance_of(Gecode::Raw::IntVar), strength, kind)
45
- Gecode::Raw.should_receive(:rel).once.with(
46
- an_instance_of(Gecode::Raw::Space),
47
- an_instance_of(Gecode::Raw::IntVar),
48
- relation, target, strength, kind)
49
- end
50
- else
51
- Gecode::Raw.should_receive(:element).once.with(
52
- an_instance_of(Gecode::Raw::Space),
53
- an_instance_of(Gecode::Raw::IntVarArray),
54
- element, an_instance_of(Gecode::Raw::IntVar), strength, kind)
55
- Gecode::Raw.should_receive(:rel).once.with(
56
- an_instance_of(Gecode::Raw::Space),
57
- an_instance_of(Gecode::Raw::IntVar), relation, target,
58
- an_instance_of(Gecode::Raw::BoolVar), strength, kind)
59
- end
60
- end
61
- end
62
-
63
- # For constraint option spec.
64
- @invoke_options = lambda do |hash|
65
- @prices[@store].must_be.greater_than(@price, hash)
66
- @model.solve!
67
- end
68
- @expect_options = option_expectation do |strength, kind, reif_var|
69
- @expect.call(@store, Gecode::Raw::IRT_GR, @price, strength, kind,
70
- reif_var, false)
71
- end
72
-
73
- # For composite spec.
74
- @invoke_relation = lambda do |relation, target, negated|
75
- if negated
76
- @prices[@store].must_not.send(relation, target)
77
- else
78
- @prices[@store].must.send(relation, target)
79
- end
80
- @model.solve!
81
- end
82
- @expect_relation = lambda do |relation, target, negated|
83
- @expect.call(@store, relation, target, Gecode::Raw::ICL_DEF,
84
- Gecode::Raw::PK_DEF, nil, negated)
85
- end
86
- end
87
-
88
- it 'should not disturb normal array access' do
89
- @fixnum_prices[2].should_not be_nil
90
- @prices[2].should_not be_nil
91
- end
92
-
93
- it 'should handle fixnum enums as enumeration' do
94
- @fixnum_prices[@store].must == @fixnum_prices[2]
95
- @model.solve!.store.value.should equal(2)
96
- end
97
-
98
- it 'should translate reification when using equality' do
99
- bool_var = @model.bool_var
100
- @expect.call(@store, Gecode::Raw::IRT_EQ, @target, Gecode::Raw::ICL_DEF,
101
- Gecode::Raw::PK_DEF, bool_var, false)
102
- @prices[@store].must_be.equal_to(@target, :reify => bool_var)
103
- @model.solve!
104
- end
105
-
106
- it_should_behave_like 'composite constraint'
107
- it_should_behave_like 'reifiable constraint'
108
- end
@@ -1,31 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require File.dirname(__FILE__) + '/constraint_helper'
3
-
4
- describe Gecode::Constraints::IntEnum::Equality do
5
- before do
6
- @model = Gecode::Model.new
7
- @vars = @model.int_var_array(4, -2..2)
8
- @invoke_options = lambda do |hash|
9
- @vars.must_be.equal(hash)
10
- @model.solve!
11
- end
12
- @expect_options = option_expectation do |strength, kind, reif_var|
13
- Gecode::Raw.should_receive(:eq).once.with(
14
- an_instance_of(Gecode::Raw::Space),
15
- anything, strength, kind)
16
- end
17
- end
18
-
19
- it 'should translate equality constraints' do
20
- @expect_options.call({})
21
- @invoke_options.call({})
22
- @vars.must_be.equal
23
- end
24
-
25
- it 'should not allow negation' do
26
- lambda{ @vars.must_not_be.equal }.should raise_error(
27
- Gecode::MissingConstraintError)
28
- end
29
-
30
- it_should_behave_like 'non-reifiable constraint'
31
- end
@@ -1,70 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require File.dirname(__FILE__) + '/constraint_helper'
3
-
4
- describe Gecode::Constraints::Int::Domain do
5
- before do
6
- @model = Gecode::Model.new
7
- @domain = 0..3
8
- @x = @model.int_var(@domain)
9
- @range_domain = 1..2
10
- @three_dot_range_domain = 1...2
11
- @non_range_domain = [1, 3]
12
-
13
- @invoke_options = lambda do |hash|
14
- @x.must_be.in(@non_range_domain, hash)
15
- @model.solve!
16
- end
17
- @expect_options = option_expectation do |strength, kind, reif_var|
18
- @model.allow_space_access do
19
- if reif_var.nil?
20
- Gecode::Raw.should_receive(:dom).once.with(
21
- an_instance_of(Gecode::Raw::Space),
22
- an_instance_of(Gecode::Raw::IntVar),
23
- an_instance_of(Gecode::Raw::IntSet),
24
- strength, kind)
25
- else
26
- Gecode::Raw.should_receive(:dom).once.with(
27
- an_instance_of(Gecode::Raw::Space),
28
- an_instance_of(Gecode::Raw::IntVar),
29
- an_instance_of(Gecode::Raw::IntSet),
30
- reif_var, strength, kind)
31
- end
32
- end
33
- end
34
- end
35
-
36
- it 'should translate domain constraints with range domains' do
37
- Gecode::Raw.should_receive(:dom).once.with(
38
- an_instance_of(Gecode::Raw::Space),
39
- an_instance_of(Gecode::Raw::IntVar), @range_domain.first,
40
- @range_domain.last, Gecode::Raw::ICL_DEF, Gecode::Raw::PK_DEF)
41
- @x.must_be.in @range_domain
42
- @model.solve!
43
- end
44
-
45
- it 'should translate domain constraints with three dot range domains' do
46
- Gecode::Raw.should_receive(:dom).once.with(
47
- an_instance_of(Gecode::Raw::Space),
48
- an_instance_of(Gecode::Raw::IntVar), @three_dot_range_domain.first,
49
- @three_dot_range_domain.last, Gecode::Raw::ICL_DEF, Gecode::Raw::PK_DEF)
50
- @x.must_be.in @three_dot_range_domain
51
- @model.solve!
52
- end
53
-
54
- it 'should translate domain constraints with non-range domains' do
55
- @expect_options.call({})
56
- @invoke_options.call({})
57
- end
58
-
59
- it 'should handle negation' do
60
- @x.must_not_be.in @range_domain
61
- @model.solve!
62
- @x.should have_domain(@domain.to_a - @range_domain.to_a)
63
- end
64
-
65
- it 'should raise error if the right hand side is not an enumeration' do
66
- lambda{ @x.must_be.in 'hello' }.should raise_error(TypeError)
67
- end
68
-
69
- it_should_behave_like 'reifiable constraint'
70
- end
@@ -1,82 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require File.dirname(__FILE__) + '/constraint_helper'
3
-
4
- describe Gecode::Constraints::Int::Linear, ' (simple ones)' do
5
- before do
6
- @model = Gecode::Model.new
7
- @x = @model.int_var(1..2)
8
- @int = 4
9
- @y = @model.int_var(1..2)
10
-
11
- # For constraint option spec.
12
- @invoke_options = lambda do |hash|
13
- @x.must_be.greater_than(3, hash)
14
- @model.solve!
15
- end
16
- @expect_options = option_expectation do |strength, kind, reif_var|
17
- if reif_var.nil?
18
- Gecode::Raw.should_receive(:rel).once.with(
19
- an_instance_of(Gecode::Raw::Space),
20
- anything, Gecode::Raw::IRT_GR, anything,
21
- strength, kind)
22
- else
23
- Gecode::Raw.should_receive(:rel).once.with(
24
- an_instance_of(Gecode::Raw::Space),
25
- an_instance_of(Gecode::Raw::IntVar), Gecode::Raw::IRT_GR, anything,
26
- reif_var, strength, kind)
27
- end
28
- end
29
- end
30
-
31
- Gecode::Constraints::Util::RELATION_TYPES.each_pair do |relation, type|
32
- it "should translate #{relation} with constant to simple relation" do
33
- Gecode::Raw.should_receive(:rel).once.with(
34
- an_instance_of(Gecode::Raw::Space),
35
- an_instance_of(Gecode::Raw::IntVar),
36
- type, @int, Gecode::Raw::ICL_DEF, Gecode::Raw::PK_DEF)
37
- @x.must.send(relation, @int)
38
- @model.solve!
39
- end
40
- end
41
-
42
- Gecode::Constraints::Util::NEGATED_RELATION_TYPES.each_pair do |relation, type|
43
- it "should translate negated #{relation} with constant to simple relation" do
44
- Gecode::Raw.should_receive(:rel).once.with(
45
- an_instance_of(Gecode::Raw::Space),
46
- an_instance_of(Gecode::Raw::IntVar),
47
- type, @int, Gecode::Raw::ICL_DEF, Gecode::Raw::PK_DEF)
48
- @x.must_not.send(relation, @int)
49
- @model.solve!
50
- end
51
- end
52
-
53
- Gecode::Constraints::Util::RELATION_TYPES.each_pair do |relation, type|
54
- it "should translate #{relation} with variables to simple relation" do
55
- Gecode::Raw.should_receive(:rel).once.with(
56
- an_instance_of(Gecode::Raw::Space),
57
- an_instance_of(Gecode::Raw::IntVar), type,
58
- an_instance_of(Gecode::Raw::IntVar),
59
- Gecode::Raw::ICL_DEF, Gecode::Raw::PK_DEF)
60
- @x.must.send(relation, @y)
61
- @model.solve!
62
- end
63
- end
64
-
65
- Gecode::Constraints::Util::NEGATED_RELATION_TYPES.each_pair do |relation, type|
66
- it "should translate negated #{relation} with variable to simple relation" do
67
- Gecode::Raw.should_receive(:rel).once.with(
68
- an_instance_of(Gecode::Raw::Space),
69
- an_instance_of(Gecode::Raw::IntVar), type,
70
- an_instance_of(Gecode::Raw::IntVar),
71
- Gecode::Raw::ICL_DEF, Gecode::Raw::PK_DEF)
72
- @x.must_not.send(relation, @y)
73
- @model.solve!
74
- end
75
- end
76
-
77
- it 'should raise error on arguments of the wrong type' do
78
- lambda{ @x.must == 'hello' }.should raise_error(TypeError)
79
- end
80
-
81
- it_should_behave_like 'reifiable constraint'
82
- end
@@ -1,340 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require File.dirname(__FILE__) + '/constraint_helper'
3
-
4
- class LinearSampleProblem < Gecode::Model
5
- attr :x
6
- attr :y
7
- attr :z
8
-
9
- def initialize(x_dom, y_dom, z_dom)
10
- @x = self.int_var(x_dom)
11
- @y = self.int_var(y_dom)
12
- @z = self.int_var(z_dom)
13
- branch_on wrap_enum([@x, @y, @z])
14
- end
15
- end
16
-
17
- class BoolLinearSampleProblem < Gecode::Model
18
- attr :x
19
- attr :y
20
- attr :z
21
-
22
- def initialize
23
- @x = self.bool_var
24
- @y = self.bool_var
25
- @z = self.bool_var
26
- branch_on wrap_enum([@x, @y, @z])
27
- end
28
- end
29
-
30
- class TrueClass
31
- def to_i
32
- 1
33
- end
34
- end
35
-
36
- class FalseClass
37
- def to_i
38
- 0
39
- end
40
- end
41
-
42
- describe Gecode::Constraints::Int::Linear do
43
- before do
44
- @x_dom = 0..2
45
- @y_dom = -3..3
46
- @z_dom = 0..10
47
- @model = LinearSampleProblem.new(@x_dom, @y_dom, @z_dom)
48
- @x = @model.x
49
- @y = @model.y
50
- @z = @model.z
51
-
52
- # For constraint option spec.
53
- @invoke_options = lambda do |hash|
54
- (@x + @y).must_be.greater_than(@z, hash)
55
- @model.solve!
56
- end
57
- @expect_options = option_expectation do |strength, kind, reif_var|
58
- # TODO: this is hard to spec from this level.
59
- end
60
- end
61
-
62
- it 'should handle addition with a variable' do
63
- (@x + @y).must == 0
64
- sol = @model.solve!
65
- x = sol.x.value
66
- y = sol.y.value
67
- (x + y).should be_zero
68
- end
69
-
70
- it 'should handle addition with multiple variables' do
71
- (@x + @y + @z).must == 0
72
- sol = @model.solve!
73
- x = sol.x.value
74
- y = sol.y.value
75
- z = sol.z.value
76
- (x + y + z).should be_zero
77
- end
78
-
79
- it 'should handle subtraction with a variable' do
80
- (@x - @y).must == 0
81
- sol = @model.solve!
82
- x = sol.x.value
83
- y = sol.y.value
84
- (x - y).should be_zero
85
- end
86
-
87
- it 'should handle non-zero constants as right hand side' do
88
- (@x + @y).must == 1
89
- sol = @model.solve!
90
- x = sol.x.value
91
- y = sol.y.value
92
- (x + y).should equal(1)
93
- end
94
-
95
- it 'should handle variables as right hand side' do
96
- (@x + @y).must == @z
97
- sol = @model.solve!
98
- x = sol.x.value
99
- y = sol.y.value
100
- z = sol.z.value
101
- (x + y).should equal(z)
102
- end
103
-
104
- it 'should handle linear expressions as right hand side' do
105
- (@x + @y).must == @z + @y
106
- sol = @model.solve!
107
- x = sol.x.value
108
- y = sol.y.value
109
- z = sol.z.value
110
- (x + y).should equal(z + y)
111
- end
112
-
113
- it 'should raise error on invalid right hand sides' do
114
- lambda{ ((@x + @y).must == 'z') }.should raise_error(TypeError)
115
- end
116
-
117
- it 'should handle coefficients other than 1' do
118
- (@x * 2 + @y).must == 0
119
- sol = @model.solve!
120
- x = sol.x.value
121
- y = sol.y.value
122
- (2*x + y).should equal(0)
123
- end
124
-
125
- it 'should handle addition with constants' do
126
- (@y + 2).must == 1
127
- sol = @model.solve!
128
- y = sol.y.value
129
- (y + 2).should equal(1)
130
- end
131
-
132
- it 'should handle subtraction with a constant' do
133
- (@x - 2).must == 0
134
- sol = @model.solve!
135
- x = sol.x.value
136
- (x - 2).should be_zero
137
- end
138
-
139
- it 'should a single variable as left hande side' do
140
- @x.must == @y + @z
141
- sol = @model.solve!
142
- x = sol.x.value
143
- y = sol.y.value
144
- z = sol.z.value
145
- x.should equal(y + z)
146
- end
147
-
148
- it 'should handle parenthesis' do
149
- (@x - (@y + @z)).must == 1
150
- sol = @model.solve!
151
- x = sol.x.value
152
- y = sol.y.value
153
- z = sol.z.value
154
- (x - (y + z)).should equal(1)
155
- end
156
-
157
- it 'should handle multiplication of parenthesis' do
158
- (((@x + @y*10)*10 + @z)*10).must == 0
159
- sol = @model.solve!
160
- x = sol.x.value
161
- y = sol.y.value
162
- z = sol.z.value
163
- (((x + y*10)*10 + z)*10).should equal(0)
164
- end
165
-
166
- relations = ['>', '>=', '<', '<=', '==']
167
-
168
- relations.each do |relation|
169
- it "should handle #{relation} with constant integers" do
170
- (@x + @y).must.send(relation, 1)
171
- sol = @model.solve!
172
- sol.should_not be_nil
173
- (sol.x.value + sol.y.value).should.send(relation, 1)
174
- end
175
- end
176
-
177
- relations.each do |relation|
178
- it "should handle negated #{relation} with constant integers" do
179
- (@x + @y).must_not.send(relation, 1)
180
- sol = @model.solve!
181
- sol.should_not be_nil
182
- (sol.x.value + sol.y.value).should_not.send(relation, 1)
183
- end
184
- end
185
-
186
- it 'should not interfere with other defined multiplication methods' do
187
- (@x * :foo).should be_nil
188
- end
189
-
190
- it_should_behave_like 'reifiable constraint'
191
- end
192
-
193
- describe Gecode::Constraints::Int::Linear, '(with booleans)' do
194
- before do
195
- @model = BoolLinearSampleProblem.new
196
- @x = @model.x
197
- @y = @model.y
198
- @z = @model.z
199
-
200
- # For constraint option spec.
201
- @invoke_options = lambda do |hash|
202
- (@x + @y).must_be.greater_than(@z, hash)
203
- @model.solve!
204
- end
205
- @expect_options = option_expectation do |strength, kind, reif_var|
206
- # TODO: this is hard to spec from this level.
207
- end
208
- end
209
-
210
- it 'should handle addition with a variable' do
211
- (@x + @y).must == 0
212
- sol = @model.solve!
213
- x = sol.x.value.to_i
214
- y = sol.y.value.to_i
215
- (x + y).should be_zero
216
- end
217
-
218
- it 'should handle addition with multiple variables' do
219
- (@x + @y + @z).must == 0
220
- sol = @model.solve!
221
- x = sol.x.value.to_i
222
- y = sol.y.value.to_i
223
- z = sol.z.value.to_i
224
- (x + y + z).should be_zero
225
- end
226
-
227
- it 'should handle subtraction with a variable' do
228
- (@x - @y).must == 0
229
- sol = @model.solve!
230
- x = sol.x.value.to_i
231
- y = sol.y.value.to_i
232
- (x - y).should be_zero
233
- end
234
-
235
- it 'should handle non-zero constants as right hand side' do
236
- (@x + @y).must == 1
237
- sol = @model.solve!
238
- x = sol.x.value.to_i
239
- y = sol.y.value.to_i
240
- (x + y).should equal(1)
241
- end
242
-
243
- it 'should handle singe booleans as left hand side' do
244
- @x.must == @y + 1
245
- sol = @model.solve!
246
- x = sol.x.value.to_i
247
- y = sol.y.value.to_i
248
- x.should equal(y + 1)
249
- end
250
-
251
- it 'should handle variables as right hand side' do
252
- (@x + @y).must == @z
253
- sol = @model.solve!
254
- x = sol.x.value.to_i
255
- y = sol.y.value.to_i
256
- z = sol.z.value.to_i
257
- (x + y).should equal(z)
258
- end
259
-
260
- it 'should handle linear expressions as right hand side' do
261
- (@x + @y).must == @z + @y
262
- sol = @model.solve!
263
- x = sol.x.value.to_i
264
- y = sol.y.value.to_i
265
- z = sol.z.value.to_i
266
- (x + y).should equal(z + y)
267
- end
268
-
269
- it 'should raise error on invalid right hand sides' do
270
- lambda{ ((@x + @y).must == 'z') }.should raise_error(TypeError)
271
- end
272
-
273
- it 'should handle coefficients other than 1' do
274
- (@x * 2 + @y).must == 0
275
- sol = @model.solve!
276
- x = sol.x.value.to_i
277
- y = sol.y.value.to_i
278
- (2*x + y).should equal(0)
279
- end
280
-
281
- it 'should handle addition with constants' do
282
- (@y + 1).must == 1
283
- sol = @model.solve!
284
- y = sol.y.value.to_i
285
- (y + 1).should equal(1)
286
- end
287
-
288
- it 'should handle subtraction with a constant' do
289
- (@x - 1).must == 0
290
- sol = @model.solve!
291
- x = sol.x.value.to_i
292
- (x - 1).should be_zero
293
- end
294
-
295
- it 'should handle parenthesis' do
296
- (@x - (@y + @z)).must == 1
297
- sol = @model.solve!
298
- x = sol.x.value.to_i
299
- y = sol.y.value.to_i
300
- z = sol.z.value.to_i
301
- (x - (y + z)).should equal(1)
302
- end
303
-
304
- it 'should handle multiplication of parenthesis' do
305
- (((@x + @y*10)*10 + @z)*10).must == 0
306
- sol = @model.solve!
307
- x = sol.x.value.to_i
308
- y = sol.y.value.to_i
309
- z = sol.z.value.to_i
310
- (((x + y*10)*10 + z)*10).should equal(0)
311
- end
312
-
313
- relations = ['>', '>=', '<', '<=', '==']
314
-
315
- relations.each do |relation|
316
- it "should handle #{relation} with constant integers" do
317
- (@x + @y).must.send(relation, 1)
318
- sol = @model.solve!
319
- sol.should_not be_nil
320
- (sol.x.value.to_i + sol.y.value.to_i).should.send(relation, 1)
321
- end
322
- end
323
-
324
- relations.each do |relation|
325
- it "should handle negated #{relation} with constant integers" do
326
- (@x + @y).must_not.send(relation, 1)
327
- sol = @model.solve!
328
- sol.should_not be_nil
329
- (sol.x.value.to_i + sol.y.value.to_i).should_not.send(relation, 1)
330
- end
331
- end
332
-
333
- it 'should not interfere with other defined multiplication methods' do
334
- (@x * :foo).should be_nil
335
- end
336
-
337
- it_should_behave_like 'reifiable constraint'
338
- end
339
-
340
-