gecoder-with-gecode 0.8.3 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,67 @@
1
+ require File.dirname(__FILE__) + '/../property_helper'
2
+
3
+ Gecode::Util::SET_OPERATION_TYPES.each_pair do |operation, type|
4
+ describe Gecode::FixnumEnum::Operation, " (#{operation} with set variable)" do
5
+ before do
6
+ @model = Gecode::Model.new
7
+ @constant_lhs = @model.wrap_enum [0, 4, 7]
8
+ @set = @model.set_var([1], 0..20)
9
+ @constant_set = [2, 3, 5]
10
+ @rhs = @model.set_var([], 0..20)
11
+ @model.branch_on @model.wrap_enum([@set, @rhs])
12
+
13
+ @property_types = [:fixnum_enum, :set]
14
+ @select_property = lambda do |fixnum_enum, set|
15
+ fixnum_enum.method(operation).call(set)
16
+ end
17
+ @selected_property = @constant_lhs.method(operation).call(@set)
18
+ @constraint_class =
19
+ Gecode::Set::Operation::OperationConstraint
20
+ end
21
+
22
+ it "should translate #{operation} into an operation constraint" do
23
+ @model.allow_space_access do
24
+ Gecode::Raw.should_receive(:rel).once.with(
25
+ an_instance_of(Gecode::Raw::Space),
26
+ an_instance_of(Gecode::Raw::IntSet), type, @set.bind,
27
+ Gecode::Raw::SRT_EQ, @rhs.bind)
28
+ end
29
+ @constant_lhs.method(operation).call(@set).must == @rhs
30
+ @model.solve!
31
+ end
32
+
33
+ it "should constrain the #{operation} of the sets with variable rhs" do
34
+ @constant_lhs.method(operation).call(@set).must == @rhs
35
+ @model.solve!
36
+
37
+ s1 = @constant_lhs
38
+ s2 = @set.value.to_a
39
+ rhs = @rhs.value.to_a
40
+ case operation
41
+ when :union
42
+ (s1 | s2).sort.should == rhs.sort
43
+ when :disjoint_union
44
+ (s1 | s2 - (s1 & s2)).sort.should == rhs.sort
45
+ when :intersection
46
+ (s1 & s2).should == rhs
47
+ when :minus
48
+ (s1 - s2).should == rhs
49
+ end
50
+ end
51
+
52
+ it 'should not allow constant sets to be given as argument' do
53
+ lambda do
54
+ @constant_lhs.method(operation).call(@constant_set).must == @rhs
55
+ end.should raise_error(TypeError)
56
+ end
57
+
58
+ it 'should not allow all three parameters to be constant sets' do
59
+ lambda do
60
+ @constant_lhs.method(operation).call(@constant_set).must == [0]
61
+ end.should raise_error(TypeError)
62
+ end
63
+
64
+ it_should_behave_like(
65
+ 'property that produces set operand by short circuiting set relations')
66
+ end
67
+ end
@@ -0,0 +1,149 @@
1
+ require File.dirname(__FILE__) + '/../property_helper'
2
+
3
+ class ArithmeticSampleProblem < Gecode::Model
4
+ attr :var
5
+ attr :var2
6
+
7
+ def initialize
8
+ @var = int_var(-9..9)
9
+ @var2 = int_var(0..9)
10
+ branch_on wrap_enum([@var, @var2])
11
+ end
12
+ end
13
+
14
+ describe Gecode::Int::Arithmetic, ' (abs)' do
15
+ before do
16
+ @model = ArithmeticSampleProblem.new
17
+ @var = @model.var
18
+
19
+ @property_types = [:int]
20
+ @select_property = lambda do |int|
21
+ int.abs
22
+ end
23
+ @selected_property = @var.abs
24
+ @constraint_class = Gecode::BlockConstraint
25
+ end
26
+
27
+ it 'should constrain the absolute value' do
28
+ @var.must < 0
29
+ @var.abs.must == 5
30
+ @model.solve!.var.value.should == -5
31
+ end
32
+
33
+ it 'should translate into an abs constraint' do
34
+ Gecode::Raw.should_receive(:abs)
35
+ @var.abs.must == 5
36
+ @model.solve!
37
+ end
38
+
39
+ it_should_behave_like(
40
+ 'property that produces int operand by short circuiting equality')
41
+ end
42
+
43
+ describe Gecode::Int::Arithmetic, ' (multiplication)' do
44
+ before do
45
+ @model = ArithmeticSampleProblem.new
46
+ @var = @model.var
47
+ @var2 = @model.var2
48
+
49
+ @property_types = [:int, :int]
50
+ @select_property = lambda do |int1, int2|
51
+ int1 * int2
52
+ end
53
+ @selected_property = @var * @var2
54
+ @constraint_class = Gecode::BlockConstraint
55
+ end
56
+
57
+ it 'should constrain the value of the multiplication' do
58
+ (@var * @var2).must == 56
59
+ sol = @model.solve!
60
+ [sol.var.value, sol.var2.value].sort.should == [7, 8]
61
+ end
62
+
63
+ it 'should translate into a mult constraint' do
64
+ Gecode::Raw.should_receive(:mult)
65
+ (@var * @var2).must == 56
66
+ @model.solve!
67
+ end
68
+
69
+ it_should_behave_like(
70
+ 'property that produces int operand by short circuiting equality')
71
+ end
72
+
73
+ describe Gecode::Int::Arithmetic, ' (squared)' do
74
+ before do
75
+ @model = ArithmeticSampleProblem.new
76
+ @var = @model.var
77
+
78
+ @property_types = [:int]
79
+ @select_property = lambda do |int|
80
+ int.squared
81
+ end
82
+ @selected_property = @var.squared
83
+ @constraint_class = Gecode::BlockConstraint
84
+ end
85
+
86
+ it 'should constrain the value of the variable squared' do
87
+ @var.squared.must == 9
88
+ sol = @model.solve!
89
+ sol.var.value.abs.should == 3
90
+ end
91
+
92
+ it 'should translate into a squared constraint' do
93
+ Gecode::Raw.should_receive(:sqr)
94
+ @var.squared.must == 4
95
+ @model.solve!
96
+ end
97
+
98
+ it_should_behave_like(
99
+ 'property that produces int operand by short circuiting equality')
100
+ end
101
+
102
+ describe Gecode::Int::Arithmetic, ' (square root)' do
103
+ before do
104
+ @model = ArithmeticSampleProblem.new
105
+ @var = @model.var
106
+
107
+ @property_types = [:int]
108
+ @select_property = lambda do |int|
109
+ int.sqrt
110
+ end
111
+ @selected_property = @var.sqrt
112
+ @constraint_class = Gecode::BlockConstraint
113
+ end
114
+
115
+ it 'should constrain the square root of the variable' do
116
+ @var.square_root.must == 3
117
+ sol = @model.solve!
118
+ Math.sqrt(sol.var.value).floor.should == 3
119
+ end
120
+
121
+ it 'should constrain the square root of the variable (2)' do
122
+ @var.square_root.must == 0
123
+ sol = @model.solve!
124
+ Math.sqrt(sol.var.value).floor.should == 0
125
+ end
126
+
127
+ it 'should constrain the square root of the variable (3)' do
128
+ @var.must < 0
129
+ @var.square_root.must == 0
130
+ lambda{ @model.solve! }.should raise_error(Gecode::NoSolutionError)
131
+ end
132
+
133
+ it 'should round down the square root' do
134
+ @var.must > 4
135
+ @var.square_root.must == 2
136
+ sol = @model.solve!
137
+ sol.var.value.should be_between(5,8)
138
+ end
139
+
140
+ it 'should translate into a square root constraint' do
141
+ Gecode::Raw.should_receive(:sqrt)
142
+ @var.sqrt.must == 2
143
+ @model.solve!
144
+ end
145
+
146
+ it_should_behave_like(
147
+ 'property that produces int operand by short circuiting equality')
148
+ end
149
+
@@ -0,0 +1,101 @@
1
+ require File.dirname(__FILE__) + '/../constraint_helper'
2
+
3
+ class BoolChannelSampleProblem < Gecode::Model
4
+ attr :bool_enum
5
+ attr :bool
6
+ attr :int
7
+
8
+ def initialize
9
+ @bool_enum = bool_var_array(4)
10
+ @int = int_var(0..3)
11
+ @bool = bool_var
12
+
13
+ branch_on @int
14
+ end
15
+ end
16
+
17
+ describe Gecode::Int::Channel, ' (one int and one bool variable)' do
18
+ before do
19
+ @model = BoolChannelSampleProblem.new
20
+ @bool = @model.bool_var
21
+ @int = @model.int_var
22
+
23
+ @types = [:int, :bool]
24
+ @invoke = lambda do |receiver, bool, hash|
25
+ receiver.equal(bool, hash)
26
+ @model.solve!
27
+ end
28
+ @expect = lambda do |var1, var2, opts, reif_var|
29
+ Gecode::Raw.should_receive(:channel).once.with(
30
+ an_instance_of(Gecode::Raw::Space),
31
+ var1, var2, *opts)
32
+ end
33
+ end
34
+
35
+ it 'should not shadow linear boolean constraints' do
36
+ lambda do
37
+ (@bool + @bool).must == @bool
38
+ @model.solve!
39
+ end.should_not raise_error
40
+ end
41
+
42
+ it 'should constrain the int variable to be 1 when the boolean variable is true' do
43
+ @bool.must_be.true
44
+ @int.must == @bool
45
+ @model.solve!
46
+ @int.value.should == 1
47
+ end
48
+
49
+ it 'should constrain the int variable to be 0 when the boolean variable is false' do
50
+ @bool.must_be.false
51
+ @int.must == @bool
52
+ @model.solve!
53
+ @int.value.should == 0
54
+ end
55
+
56
+ it_should_behave_like 'non-reifiable constraint'
57
+ it_should_behave_like 'non-negatable constraint'
58
+ end
59
+
60
+ describe Gecode::Int::Channel, ' (one bool and one int variable)' do
61
+ before do
62
+ @model = BoolChannelSampleProblem.new
63
+ @bool = @model.bool_var
64
+ @int = @model.int_var
65
+
66
+ @types = [:bool, :int]
67
+ @invoke = lambda do |receiver, int, hash|
68
+ receiver.equal(int, hash)
69
+ @model.solve!
70
+ end
71
+ @expect = lambda do |var1, var2, opts, reif_var|
72
+ Gecode::Raw.should_receive(:channel).once.with(
73
+ an_instance_of(Gecode::Raw::Space),
74
+ var2, var1, *opts)
75
+ end
76
+ end
77
+
78
+ it 'should not shadow linear boolean constraints' do
79
+ lambda do
80
+ @bool.must == @bool + @bool
81
+ @model.solve!
82
+ end.should_not raise_error
83
+ end
84
+
85
+ it 'should constrain the int variable to be 1 when the boolean variable is true' do
86
+ @bool.must_be.true
87
+ @bool.must == @int
88
+ @model.solve!
89
+ @int.value.should == 1
90
+ end
91
+
92
+ it 'should constrain the int variable to be 0 when the boolean variable is false' do
93
+ @bool.must_be.false
94
+ @bool.must == @int
95
+ @model.solve!
96
+ @int.value.should == 0
97
+ end
98
+
99
+ it_should_behave_like 'non-reifiable constraint'
100
+ it_should_behave_like 'non-negatable constraint'
101
+ end
@@ -0,0 +1,106 @@
1
+ require File.dirname(__FILE__) + '/../constraint_helper'
2
+
3
+ describe Gecode::Int::Domain, ' (non-range)' do
4
+ before do
5
+ @model = Gecode::Model.new
6
+ @domain = 0..3
7
+ @x = @model.int_var(@domain)
8
+ @non_range_domain = [1, 3]
9
+
10
+ @types = [:int]
11
+ @invoke = lambda do |receiver, hash|
12
+ receiver.in(@non_range_domain, hash)
13
+ @model.solve!
14
+ end
15
+ @expect = lambda do |var, opts, reif_var|
16
+ if reif_var.nil?
17
+ Gecode::Raw.should_receive(:dom).once.with(
18
+ an_instance_of(Gecode::Raw::Space),
19
+ var, an_instance_of(Gecode::Raw::IntSet),
20
+ *opts)
21
+ else
22
+ Gecode::Raw.should_receive(:dom).once.with(
23
+ an_instance_of(Gecode::Raw::Space),
24
+ var, an_instance_of(Gecode::Raw::IntSet),
25
+ reif_var, *opts)
26
+ end
27
+ end
28
+ end
29
+
30
+ it 'should constrain the domain of the variable' do
31
+ @x.must_be.in @non_range_domain
32
+ @model.solve!
33
+
34
+ @x.should have_domain(@non_range_domain)
35
+ end
36
+
37
+ it 'should handle negation' do
38
+ @x.must_not_be.in @non_range_domain
39
+ @model.solve!
40
+
41
+ @x.should have_domain(@domain.to_a - @non_range_domain.to_a)
42
+ end
43
+
44
+ it_should_behave_like 'reifiable constraint'
45
+ end
46
+
47
+ describe Gecode::Int::Domain, ' (range)' do
48
+ before do
49
+ @model = Gecode::Model.new
50
+ @domain = 0..3
51
+ @operand = @x = @model.int_var(@domain)
52
+ @range_domain = 1..2
53
+ @three_dot_range_domain = 1...2
54
+
55
+ @types = [:int]
56
+ @invoke = lambda do |receiver, hash|
57
+ receiver.in(@range_domain, hash)
58
+ @model.solve!
59
+ end
60
+ @expect = lambda do |var, opts, reif_var|
61
+ @model.allow_space_access do
62
+ if reif_var.nil?
63
+ Gecode::Raw.should_receive(:dom).once.with(
64
+ an_instance_of(Gecode::Raw::Space),
65
+ var, @range_domain.first, @range_domain.last,
66
+ *opts)
67
+ else
68
+ Gecode::Raw.should_receive(:dom).once.with(
69
+ an_instance_of(Gecode::Raw::Space),
70
+ var, @range_domain.first, @range_domain.last,
71
+ reif_var, *opts)
72
+ end
73
+ end
74
+ end
75
+ end
76
+
77
+ it 'should constrain the domain of the variable' do
78
+ @x.must_be.in @range_domain
79
+ @model.solve!
80
+
81
+ @x.should have_domain(@range_domain)
82
+ end
83
+
84
+ it 'should handle negation' do
85
+ @x.must_not_be.in @range_domain
86
+ @model.solve!
87
+
88
+ @x.should have_domain(@domain.to_a - @range_domain.to_a)
89
+ end
90
+
91
+ it 'should treat three dot ranges correctly' do
92
+ @x.must_be.in @three_dot_range_domain
93
+ @model.solve!
94
+
95
+ @x.should have_domain(@three_dot_range_domain)
96
+ end
97
+
98
+ it 'should handle three dot range with negation' do
99
+ @x.must_not_be.in @three_dot_range_domain
100
+ @model.solve!
101
+
102
+ @x.should have_domain(@domain.to_a - @three_dot_range_domain.to_a)
103
+ end
104
+
105
+ it_should_behave_like 'reifiable constraint'
106
+ end
@@ -0,0 +1,183 @@
1
+ require File.dirname(__FILE__) + '/../constraint_helper'
2
+
3
+ # This is neither an operand or a constraint spec. It is mostly a sanity
4
+ # check.
5
+
6
+ class LinearSampleProblem < Gecode::Model
7
+ attr :x
8
+ attr :y
9
+ attr :z
10
+
11
+ def initialize(x_dom, y_dom, z_dom)
12
+ @x = self.int_var(x_dom)
13
+ @y = self.int_var(y_dom)
14
+ @z = self.int_var(z_dom)
15
+ branch_on wrap_enum([@x, @y, @z])
16
+ end
17
+ end
18
+
19
+ describe Gecode::Int::Linear do
20
+ before do
21
+ @x_dom = 0..2
22
+ @y_dom = -3..3
23
+ @z_dom = 0..10
24
+ @model = LinearSampleProblem.new(@x_dom, @y_dom, @z_dom)
25
+ @x = @model.x
26
+ @y = @model.y
27
+ @z = @model.z
28
+ @operand = @x + @y
29
+ end
30
+
31
+ it 'should handle addition with a variable' do
32
+ (@x + @y).must == 0
33
+ sol = @model.solve!
34
+ x = sol.x.value
35
+ y = sol.y.value
36
+ (x + y).should be_zero
37
+ end
38
+
39
+ it 'should handle reification (1)' do
40
+ bool = @model.bool_var
41
+ (@x + @y).must.equal(0, :reify => bool)
42
+ bool.must_be.false
43
+ sol = @model.solve!
44
+ x = sol.x.value
45
+ y = sol.y.value
46
+ (x + y).should_not be_zero
47
+ end
48
+
49
+ it 'should handle reification (2)' do
50
+ bool = @model.bool_var
51
+ (@x + @y).must.equal(0, :reify => bool)
52
+ bool.must_be.true
53
+ sol = @model.solve!
54
+ x = sol.x.value
55
+ y = sol.y.value
56
+ (x + y).should be_zero
57
+ end
58
+
59
+ it 'should handle addition with multiple variables' do
60
+ (@x + @y + @z).must == 0
61
+ sol = @model.solve!
62
+ x = sol.x.value
63
+ y = sol.y.value
64
+ z = sol.z.value
65
+ (x + y + z).should be_zero
66
+ end
67
+
68
+ it 'should handle subtraction with a variable' do
69
+ (@x - @y).must == 0
70
+ sol = @model.solve!
71
+ x = sol.x.value
72
+ y = sol.y.value
73
+ (x - y).should be_zero
74
+ end
75
+
76
+ it 'should handle non-zero constants as right hand side' do
77
+ (@x + @y).must == 1
78
+ sol = @model.solve!
79
+ x = sol.x.value
80
+ y = sol.y.value
81
+ (x + y).should equal(1)
82
+ end
83
+
84
+ it 'should handle variables as right hand side' do
85
+ (@x + @y).must == @z
86
+ sol = @model.solve!
87
+ x = sol.x.value
88
+ y = sol.y.value
89
+ z = sol.z.value
90
+ (x + y).should equal(z)
91
+ end
92
+
93
+ it 'should handle linear expressions as right hand side' do
94
+ (@x + @y).must == @z + @y
95
+ sol = @model.solve!
96
+ x = sol.x.value
97
+ y = sol.y.value
98
+ z = sol.z.value
99
+ (x + y).should equal(z + y)
100
+ end
101
+
102
+ it 'should handle linear expressions as right hand side with variable as left hand side' do
103
+ @x.must == @z + @y
104
+ sol = @model.solve!
105
+ x = sol.x.value
106
+ y = sol.y.value
107
+ z = sol.z.value
108
+ x.should equal(z + y)
109
+ end
110
+
111
+ it 'should raise error on invalid right hand sides' do
112
+ lambda{ ((@x + @y).must == 'z') }.should raise_error(TypeError)
113
+ end
114
+
115
+ it 'should handle coefficients other than 1' do
116
+ (@x * 2 + @y).must == 0
117
+ sol = @model.solve!
118
+ x = sol.x.value
119
+ y = sol.y.value
120
+ (2*x + y).should equal(0)
121
+ end
122
+
123
+ it 'should handle addition with constants' do
124
+ (@y + 2).must == 1
125
+ sol = @model.solve!
126
+ y = sol.y.value
127
+ (y + 2).should equal(1)
128
+ end
129
+
130
+ it 'should handle subtraction with a constant' do
131
+ (@x - 2).must == 0
132
+ sol = @model.solve!
133
+ x = sol.x.value
134
+ (x - 2).should be_zero
135
+ end
136
+
137
+ it 'should a single variable as left hande side' do
138
+ @x.must == @y + @z
139
+ sol = @model.solve!
140
+ x = sol.x.value
141
+ y = sol.y.value
142
+ z = sol.z.value
143
+ x.should equal(y + z)
144
+ end
145
+
146
+ it 'should handle parenthesis' do
147
+ (@x - (@y + @z)).must == 1
148
+ sol = @model.solve!
149
+ x = sol.x.value
150
+ y = sol.y.value
151
+ z = sol.z.value
152
+ (x - (y + z)).should equal(1)
153
+ end
154
+
155
+ it 'should handle multiplication of parenthesis' do
156
+ (((@x + @y*10)*10 + @z)*10).must == 0
157
+ sol = @model.solve!
158
+ x = sol.x.value
159
+ y = sol.y.value
160
+ z = sol.z.value
161
+ (((x + y*10)*10 + z)*10).should equal(0)
162
+ end
163
+
164
+ relations = ['>', '>=', '<', '<=', '==']
165
+
166
+ relations.each do |relation|
167
+ it "should handle #{relation} with constant integers" do
168
+ (@x + @y).must.send(relation, 1)
169
+ sol = @model.solve!
170
+ sol.should_not be_nil
171
+ (sol.x.value + sol.y.value).should.send(relation, 1)
172
+ end
173
+ end
174
+
175
+ relations.each do |relation|
176
+ it "should handle negated #{relation} with constant integers" do
177
+ (@x + @y).must_not.send(relation, 1)
178
+ sol = @model.solve!
179
+ sol.should_not be_nil
180
+ (sol.x.value + sol.y.value).should_not.send(relation, 1)
181
+ end
182
+ end
183
+ end
@@ -0,0 +1,97 @@
1
+ require File.dirname(__FILE__) + '/../property_helper'
2
+
3
+ class LinearPropertySampleProblem < Gecode::Model
4
+ attr :x
5
+ attr :y
6
+ attr :z
7
+
8
+ def initialize
9
+ @x = self.int_var(0..2)
10
+ @y = self.int_var(-3..3)
11
+ @z = self.int_var(0..10)
12
+ branch_on wrap_enum([@x, @y, @z])
13
+ end
14
+ end
15
+
16
+ describe Gecode::Int::Linear, ' (+ property)' do
17
+ before do
18
+ @model = LinearPropertySampleProblem.new
19
+ @x = @model.x
20
+ @y = @model.y
21
+ @z = @model.z
22
+
23
+ # For int operand producing property spec.
24
+ @property_types = [:int, :int]
25
+ @select_property = lambda do |int1, int2|
26
+ int1 + int2
27
+ end
28
+ @selected_property = @x + @y
29
+ @constraint_class =
30
+ Gecode::Int::Linear::LinearRelationConstraint
31
+ end
32
+
33
+ it 'should constrain the sum' do
34
+ (@x + @y).must == 5
35
+ @model.solve!
36
+ (@x.value + @y.value).should == 5
37
+ end
38
+
39
+ it_should_behave_like(
40
+ 'property that produces int operand by short circuiting relations')
41
+ end
42
+
43
+ describe Gecode::Int::Linear, ' (- property)' do
44
+ before do
45
+ @model = LinearPropertySampleProblem.new
46
+ @x = @model.x
47
+ @y = @model.y
48
+ @z = @model.z
49
+
50
+ # For int operand producing property spec.
51
+ @property_types = [:int, :int]
52
+ @select_property = lambda do |int1, int2|
53
+ int1 - int2
54
+ end
55
+ @selected_property = @x - @y
56
+ @constraint_class =
57
+ Gecode::Int::Linear::LinearRelationConstraint
58
+ end
59
+
60
+ it 'should constrain the difference' do
61
+ (@x - @y).must == 1
62
+ @model.solve!
63
+ (@x.value - @y.value).should == 1
64
+ end
65
+
66
+ it_should_behave_like(
67
+ 'property that produces int operand by short circuiting relations')
68
+ end
69
+
70
+ describe Gecode::Int::Linear, ' (* property)' do
71
+ before do
72
+ @model = LinearPropertySampleProblem.new
73
+ @x = @model.x
74
+ @y = @model.y
75
+ @z = @model.z
76
+
77
+ # For int operand producing property spec.
78
+ @property_types = [:int]
79
+ @select_property = lambda do |int|
80
+ int * 17
81
+ end
82
+ @selected_property = @x * 2
83
+ @constraint_class =
84
+ Gecode::Int::Linear::LinearRelationConstraint
85
+ end
86
+
87
+ it 'should constrain the value times a constant' do
88
+ (@x * 2).must == 4
89
+ @model.solve!
90
+ (@x.value * 2).should == 4
91
+ end
92
+
93
+ it_should_behave_like(
94
+ 'property that produces int operand by short circuiting relations')
95
+ end
96
+
97
+