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
@@ -1,7 +1,22 @@
1
- module Gecode::Constraints::Set
2
- class Expression
3
- # Adds a channel constraint on the set variable with the specified enum of
4
- # boolean variables.
1
+ module Gecode::Set
2
+ class SetConstraintReceiver
3
+ # Constrains this set to channel +bool_enum+. The set is constrained
4
+ # to include value i exactly when the operand at index i in the
5
+ # boolean enumeration is true.
6
+ #
7
+ # Neither reification nor negation is supported. The boolean enum and set
8
+ # can be interchanged.
9
+ #
10
+ # ==== Examples
11
+ #
12
+ # # Constrains the enumeration of boolean operands called +bools+ to at
13
+ # # least have the first and third operands set to true
14
+ # set.must_be.superset_of [0, 2]
15
+ # set.must.channel bools
16
+ #
17
+ # # An alternative way of writing the above.
18
+ # set.must_be.superset_of [0, 2]
19
+ # bools.must.channel set
5
20
  def channel(bool_enum, options = {})
6
21
  if @params[:negate]
7
22
  raise Gecode::MissingConstraintError, 'A negated channel constraint ' +
@@ -11,43 +26,25 @@ module Gecode::Constraints::Set
11
26
  raise ArgumentError, 'The channel constraint does not support the ' +
12
27
  'reification option.'
13
28
  end
14
- unless bool_enum.respond_to? :to_bool_var_array
15
- raise TypeError, 'Expected an enum of bool variables, ' +
29
+ unless bool_enum.respond_to? :to_bool_enum
30
+ raise TypeError, 'Expected an enum of bool operands, ' +
16
31
  "got #{bool_enum.class}."
17
32
  end
18
33
 
19
34
  @params.update(:rhs => bool_enum)
20
- @params.update Gecode::Constraints::Set::Util.decode_options(options)
35
+ @params.update Gecode::Set::Util.decode_options(options)
21
36
  @model.add_constraint Channel::ChannelConstraint.new(@model, @params)
22
37
  end
23
38
  end
24
39
 
25
40
  # A module that gathers the classes and modules used in channel constraints
26
- # involving one set variable and a boolean enum.
41
+ # involving one set operand and a boolean enum.
27
42
  module Channel #:nodoc:
28
- # Describes a channel constraint that "channels" a set variable and an
29
- # enumerations of boolean variables. This constrains the set variable to
30
- # include value i exactly when the variable at index i in the boolean
31
- # enumeration is true.
32
- #
33
- # Neither reification nor negation is supported. The boolean enum and set
34
- # can be interchanged.
35
- #
36
- # == Examples
37
- #
38
- # # Constrains the enumeration of boolean variables called +bools+ to at
39
- # # least have the first and third variables set to true
40
- # set.must_be.superset_of [0, 2]
41
- # set.must.channel bools
42
- #
43
- # # An alternative way of writing the above.
44
- # set.must_be.superset_of [0, 2]
45
- # bools.must.channel set
46
- class ChannelConstraint < Gecode::Constraints::Constraint
43
+ class ChannelConstraint < Gecode::Constraint #:nodoc:
47
44
  def post
48
45
  lhs, rhs = @params.values_at(:lhs, :rhs)
49
- Gecode::Raw::channel(@model.active_space, rhs.to_bool_var_array,
50
- lhs.bind)
46
+ Gecode::Raw::channel(@model.active_space, rhs.to_bool_enum.bind_array,
47
+ lhs.to_set_var.bind)
51
48
  end
52
49
  end
53
50
  end
@@ -1,193 +1,130 @@
1
- module Gecode
2
- class FreeSetVar
3
- # Starts a constraint on the minimum value of the set.
1
+ module Gecode::Set
2
+ module SetOperand
3
+ # Produces an IntOperand representing the minimum of the set.
4
+ #
5
+ # ==== Examples
6
+ #
7
+ # # The minimum of +set+.
8
+ # set.min
4
9
  def min
5
- params = {:lhs => self}
6
- Gecode::Constraints::Set::Connection::MinExpressionStub.new(@model, params)
10
+ Connection::SetMinOperand.new(@model, self)
7
11
  end
8
12
 
9
- # Starts a constraint on the maximum value of the set.
13
+ # Produces an IntOperand representing the maximum of the set.
14
+ #
15
+ # ==== Examples
16
+ #
17
+ # # The maximum of +set+.
18
+ # set.max
10
19
  def max
11
- params = {:lhs => self}
12
- Gecode::Constraints::Set::Connection::MaxExpressionStub.new(@model, params)
20
+ Connection::SetMaxOperand.new(@model, self)
13
21
  end
14
22
 
15
- # Starts a constraint on the sum of the set. The option :weights may
16
- # optionally be given with a hash of weights as value. If it is then the
17
- # weighted sum, using the hash as weight function, will be constrained. The
18
- # option :substitutions may also be given (with a hash as value), if it is
19
- # then the sum of the set with all elements replaced according to the hash
20
- # is constrained. Elements mapped to nil by the weights or substitutions
21
- # hash are removed from the upper bound of the set. Only one of the two
22
- # options may be given at the same time.
23
+ # Produces an IntOperand representing the sum of the values in the
24
+ # set. One of the following options may also be given:
25
+ # [:weights] Produces the weighted sum using the specified hash
26
+ # of weights. The hash should map each value to
27
+ # that value's weight.
28
+ # [:substitutions] Produces the sum of the set with all elements
29
+ # replaced according to the hash.
30
+ #
31
+ # Elements not included in the weights or substitutions hash are
32
+ # removed from the upper bound of the set.
33
+ #
34
+ # ==== Examples
35
+ #
36
+ # # The sum of +set+.
37
+ # set.sum
38
+ #
39
+ # # The sum of +set+ with primes < 10 given twice the weight.
40
+ # set.sum(:weights => {2 => 2, 3 => 2, 5 => 2, 7 => 2})
41
+ #
42
+ # # The sum of +set+ with odd values in [1,6] being counted as 1.
43
+ # set.sum(:substitutions => {1 => 1, 3 => 1, 5 => 1})
23
44
  def sum(options = {:weights => weights = Hash.new(1)})
24
45
  if options.empty? or options.keys.size > 1
25
- raise ArgumentError, 'One of the options :weights and :substitutions, ' +
26
- 'or neither, must be specified.'
27
- end
28
- params = {:lhs => self}
29
- unless options.empty?
30
- case options.keys.first
31
- when :substitutions: params.update(options)
32
- when :weights:
33
- weights = options[:weights]
34
- substitutions = Hash.new do |hash, key|
35
- if weights[key].nil?
36
- hash[key] = nil
37
- else
38
- hash[key] = key * weights[key]
39
- end
40
- end
41
- params.update(:substitutions => substitutions)
42
- else raise ArgumentError, "Unrecognized option #{options.keys.first}."
43
- end
46
+ raise ArgumentError, 'At most one of the options :weights and ' +
47
+ ':substitutions may be specified.'
44
48
  end
45
- Gecode::Constraints::Set::Connection::SumExpressionStub.new(@model, params)
46
- end
47
- end
48
- end
49
49
 
50
- module Gecode::Constraints::Set
51
- class Expression
52
- # Adds a constraint that forces specified values to be included in the
53
- # set. This constraint has the side effect of sorting the variables in
54
- # non-descending order.
55
- def include(variables)
56
- unless variables.respond_to? :to_int_var_array
57
- raise TypeError, "Expected int var enum, got #{variables.class}."
58
- end
59
- if @params[:negate]
60
- raise Gecode::MissingConstraintError, 'A negated include is not ' +
61
- 'implemented.'
50
+ case options.keys.first
51
+ when :substitutions: subs = options[:substitutions]
52
+ when :weights:
53
+ weights = options[:weights]
54
+ subs = Hash.new do |hash, key|
55
+ if weights[key].nil?
56
+ hash[key] = nil
57
+ else
58
+ hash[key] = key * weights[key]
59
+ end
60
+ end
61
+ else raise ArgumentError, "Unrecognized option #{options.keys.first}."
62
62
  end
63
-
64
- @params.update(:variables => variables)
65
- @model.add_constraint Connection::IncludeConstraint.new(@model, @params)
63
+ Connection::SetSumOperand.new(@model, self, subs)
66
64
  end
67
65
  end
68
-
66
+
69
67
  # A module that gathers the classes and modules used in connection
70
68
  # constraints.
71
69
  module Connection #:nodoc:
72
- # Describes a CompositeStub for the min constraint which constrains the
73
- # minimum value of a set variable.
74
- #
75
- # == Examples
76
- #
77
- # # Constrains the minimum value of +set+ to be larger than 17.
78
- # set.min.must > 17
79
- #
80
- # # Constrains the minimum value of +set+ to equal the integer variable
81
- # # +min+.
82
- # set.min.must == min
83
- #
84
- # # Constrains the minimum value of +set+ to not be larger than the
85
- # # integer variable +ceil+.
86
- # set.min.must_not > ceil
87
- #
88
- # # The same as above but reified with the boolean variable
89
- # # +is_not_above_ceiling+ and with the strength +domain+ applied.
90
- # set.min.must_not_be.larger_than(ceil, :reify => :is_not_above_ceiling,
91
- # :strength => :domain)
92
- class MinExpressionStub < Gecode::Constraints::Int::CompositeStub
93
- def constrain_equal(variable, params, constrain)
94
- set = params[:lhs]
70
+ class SetMinOperand < Gecode::Int::ShortCircuitEqualityOperand #:nodoc:
71
+ def initialize(model, set_op)
72
+ super model
73
+ @set = set_op
74
+ end
75
+
76
+ def constrain_equal(int_operand, constrain, propagation_options)
77
+ set = @set.to_set_var
95
78
  if constrain
96
- variable.must_be.in set.upper_bound.min..set.lower_bound.min
79
+ int_operand.must_be.in set.upper_bound.min..set.lower_bound.min
97
80
  end
98
81
 
99
- Gecode::Raw::min(@model.active_space, set.bind, variable.bind)
82
+ Gecode::Raw::min(@model.active_space, set.bind,
83
+ int_operand.to_int_var.bind)
100
84
  end
101
85
  end
102
86
 
103
- # Describes a CompositeStub for the max constraint which constrains the
104
- # maximum value of a set variable.
105
- #
106
- # == Examples
107
- #
108
- # # Constrains the maximum value of +set+ to be larger than 17.
109
- # set.max.must > 17
110
- #
111
- # # Constrains the maximum value of +set+ to equal the integer variable
112
- # # +max+.
113
- # set.max.must == max
114
- #
115
- # # Constrains the maximum value of +set+ to not be less than the
116
- # # integer variable +floor+.
117
- # set.max.must_not < floor
118
- #
119
- # # The same as above but reified with the boolean variable
120
- # # +is_not_below_floor+ and with the strength +domain+ applied.
121
- # set.max.must_not_be.less_than(ceil, :reify => :is_not_below_floor,
122
- # :strength => :domain)
123
- class MaxExpressionStub < Gecode::Constraints::Int::CompositeStub
124
- def constrain_equal(variable, params, constrain)
125
- set = params[:lhs]
87
+ class SetMaxOperand < Gecode::Int::ShortCircuitEqualityOperand #:nodoc:
88
+ def initialize(model, set_op)
89
+ super model
90
+ @set = set_op
91
+ end
92
+
93
+ def constrain_equal(int_operand, constrain, propagation_options)
94
+ set = @set.to_set_var
126
95
  if constrain
127
- variable.must_be.in set.lower_bound.max..set.upper_bound.max
96
+ int_operand.must_be.in set.upper_bound.min..set.lower_bound.min
128
97
  end
129
98
 
130
- Gecode::Raw::max(@model.active_space, set.bind, variable.bind)
99
+ Gecode::Raw::max(@model.active_space, set.bind,
100
+ int_operand.to_int_var.bind)
131
101
  end
132
102
  end
133
103
 
134
- # Describes a CompositeStub for the sum constraint which constrains the
135
- # sum of all values in a set variable.
136
- #
137
- # == Examples
138
- #
139
- # # Constrains the sum of all values in +set+ to be larger than 17.
140
- # set.sum.must > 17
141
- #
142
- # # Constrains the sum of all values in +set+ to equal the integer
143
- # # variable +sum+.
144
- # set.sum.must == sum
145
- #
146
- # # Constrains the sum of all values in +set+ to not be larger than the
147
- # # integer variable +resources+.
148
- # set.sum.must_not > resources
149
- #
150
- # # The same as above but reified with the boolean variable
151
- # # +not_over_budget+ and with the strength +domain+ applied.
152
- # set.sum.must_not_be.larger_than(resources, :reify => :not_over_budget,
153
- # :strength => :domain)
154
- class SumExpressionStub < Gecode::Constraints::Int::CompositeStub
155
- def constrain_equal(variable, params, constrain)
156
- set, subs = params.values_at(:lhs, :substitutions)
104
+ class SetSumOperand < Gecode::Int::ShortCircuitEqualityOperand #:nodoc:
105
+ def initialize(model, set_op, subs)
106
+ super model
107
+ @set = set_op
108
+ @subs = subs
109
+ end
110
+
111
+ def constrain_equal(int_operand, constrain, propagation_options)
112
+ set = @set.to_set_var
157
113
  lub = set.upper_bound.to_a
158
- lub.delete_if{ |e| subs[e].nil? }
159
- substituted_lub = lub.map{ |e| subs[e] }
114
+ lub.delete_if{ |e| @subs[e].nil? }
115
+ substituted_lub = lub.map{ |e| @subs[e] }
160
116
  if constrain
161
117
  # Compute the theoretical bounds of the weighted sum. This is slightly
162
118
  # sloppy since we could also use the contents of the greatest lower
163
119
  # bound.
164
120
  min = substituted_lub.find_all{ |e| e < 0}.inject(0){ |x, y| x + y }
165
121
  max = substituted_lub.find_all{ |e| e > 0}.inject(0){ |x, y| x + y }
166
- variable.must_be.in min..max
122
+ int_operand.must_be.in min..max
167
123
  end
168
124
 
169
125
  Gecode::Raw::weights(@model.active_space, lub, substituted_lub,
170
- set.bind, variable.bind)
171
- end
172
- end
173
-
174
- # Describes an include constraint, which constrains the set to include the
175
- # values of the specified enumeration of integer variables.
176
- #
177
- # The constraint has the side effect of sorting the integer variables in a
178
- # non-descending order. It does not support reification nor negation.
179
- #
180
- # == Examples
181
- #
182
- # # Constrain +set+ to include the values of all variables in
183
- # # +int_enum+.
184
- # set.must.include int_enum
185
- class IncludeConstraint < Gecode::Constraints::Constraint
186
- def post
187
- set, variables = @params.values_at(:lhs, :variables)
188
- Gecode::Raw::match(@model.active_space, set.bind,
189
- variables.to_int_var_array)
126
+ set.bind, int_operand.to_int_var.bind)
190
127
  end
191
128
  end
192
129
  end
193
- end
130
+ end
@@ -1,13 +1,102 @@
1
- module Gecode::Constraints::Set
2
- class Expression
3
- Gecode::Constraints::Util::SET_RELATION_TYPES.each_pair do |name, type|
4
- module_eval <<-"end_code"
5
- # Creates a domain constraint using the specified constant set.
6
- def #{name}(constant_set, options = {})
7
- add_domain_constraint(:#{name}, constant_set, options)
8
- end
9
- end_code
1
+ module Gecode::Set
2
+ class SetConstraintReceiver
3
+ # Constrains the set operand to have a domain equal to +constant_set+.
4
+ #
5
+ # ==== Examples
6
+ #
7
+ # # +set+ must equal [1,2,5]
8
+ # set.must == [1,2,5]
9
+ #
10
+ # # +set+ must not equal 1..67
11
+ # set.must_not == 1..67
12
+ #
13
+ # # +set+ must equal the singleton set 0. The constraint is reified with
14
+ # # the boolean operand +is_singleton_zero+.
15
+ # set.must.equal(0, :reify => is_singleton_zero)
16
+ def ==(constant_set, options = {})
17
+ add_domain_constraint(:==, constant_set, options)
18
+ end
19
+
20
+ # Constrains the set operand to be a superset of +constant_set+.
21
+ #
22
+ # ==== Examples
23
+ #
24
+ # # +set+ must be a superset of [1,2,5]
25
+ # set.must_be.superset_of [1,2,5]
26
+ #
27
+ # # +set+ must be a superset of 1..67
28
+ # set.must_be.superset_of 1..67
29
+ #
30
+ # # +set+ must not be a superset of [0].
31
+ # set.must_not_be.superset_of 0
32
+ #
33
+ # # +set+ must be a superset of [1,3,5,7]. The constraint is reified with
34
+ # # the boolean operand +bool+.
35
+ # set.must_be.superset_of([1.3.5.7], :reify => bool)
36
+ def superset(constant_set, options = {})
37
+ add_domain_constraint(:superset, constant_set, options)
38
+ end
39
+
40
+ # Constrains the set operand to be a subset of +constant_set+.
41
+ #
42
+ # ==== Examples
43
+ #
44
+ # # +set+ must be a subset of [1,2,5]
45
+ # set.must_be.subset_of [1,2,5]
46
+ #
47
+ # # +set+ must be a subset of 1..67
48
+ # set.must_be.subset_of 1..67
49
+ #
50
+ # # +set+ must not be a subset of [0].
51
+ # set.must_not_be.subset_of 0
52
+ #
53
+ # # +set+ must be a subset of [1,3,5,7]. The constraint is reified with
54
+ # # the boolean operand +bool+.
55
+ # set.must_be.subset_of([1.3.5.7], :reify => bool)
56
+ def subset(constant_set, options = {})
57
+ add_domain_constraint(:subset, constant_set, options)
58
+ end
59
+
60
+ # Constrains the set operand to be disjoint with +constant_set+.
61
+ #
62
+ # ==== Examples
63
+ #
64
+ # # +set+ must be disjoint with [1,2,5]
65
+ # set.must_be.disjoint_with [1,2,5]
66
+ #
67
+ # # +set+ must be disjoint with 1..67
68
+ # set.must_be.disjoint_with 1..67
69
+ #
70
+ # # +set+ must not be disjoint with [0].
71
+ # set.must_not_be.disjoint_with 0
72
+ #
73
+ # # +set+ must be disjoint with [1,3,5,7]. The constraint is reified with
74
+ # # the boolean operand +bool+.
75
+ # set.must_be.disjoint_with([1.3.5.7], :reify => bool)
76
+ def disjoint(constant_set, options = {})
77
+ add_domain_constraint(:disjoint, constant_set, options)
78
+ end
79
+
80
+ # Constrains the set operand to be the complement of +constant_set+.
81
+ #
82
+ # ==== Examples
83
+ #
84
+ # # +set+ must be the complement of [1,2,5]
85
+ # set.must_be.complement_of [1,2,5]
86
+ #
87
+ # # +set+ must be the complement of 1..67
88
+ # set.must_be.complement_of 1..67
89
+ #
90
+ # # +set+ must not be the complement of [0].
91
+ # set.must_not_be.complement_of 0
92
+ #
93
+ # # +set+ must be the complement of [1,3,5,7]. The constraint is
94
+ # # reified with the boolean operand +bool+.
95
+ # set.must_be.complement_of([1.3.5.7], :reify => bool)
96
+ def complement(constant_set, options = {})
97
+ add_domain_constraint(:complement, constant_set, options)
10
98
  end
99
+
11
100
  alias_set_methods
12
101
 
13
102
  private
@@ -15,12 +104,12 @@ module Gecode::Constraints::Set
15
104
  # Adds a domain constraint for the specified relation name, constant set
16
105
  # and options.
17
106
  def add_domain_constraint(relation_name, constant_set, options)
18
- unless Gecode::Constraints::Util.constant_set? constant_set
107
+ unless Gecode::Util.constant_set? constant_set
19
108
  raise TypeError, "Expected constant set, got #{constant_set.class}."
20
109
  end
21
110
  @params[:rhs] = constant_set
22
111
  @params[:relation] = relation_name
23
- @params.update Gecode::Constraints::Set::Util.decode_options(options)
112
+ @params.update Gecode::Set::Util.decode_options(options)
24
113
  if relation_name == :==
25
114
  @model.add_constraint Domain::EqualityDomainConstraint.new(@model,
26
115
  @params)
@@ -32,78 +121,36 @@ module Gecode::Constraints::Set
32
121
 
33
122
  # A module that gathers the classes and modules used in domain constraints.
34
123
  module Domain #:nodoc:
35
- # Describes a domain constraint which constrains a set to be equal to a
36
- # constant set.
37
- #
38
- # == Examples
39
- #
40
- # # +set+ must equal [1,2,5]
41
- # set.must == [1,2,5]
42
- #
43
- # # +set+ must not equal 1..67
44
- # set.must_not == 1..67
45
- #
46
- # # +set+ must equal the singleton set 0. The constraint is reified with
47
- # # the boolean varaible +is_singleton_zero+.
48
- # set.must.equal(0, :reify => is_singleton_zero)
49
- class EqualityDomainConstraint < Gecode::Constraints::ReifiableConstraint
124
+ class EqualityDomainConstraint < Gecode::ReifiableConstraint #:nodoc:
50
125
  def post
51
126
  var, domain, reif_var, negate = @params.values_at(:lhs, :rhs, :reif,
52
127
  :negate)
53
128
  if negate
54
- rel_type = Gecode::Constraints::Util::NEGATED_SET_RELATION_TYPES[:==]
129
+ rel_type = Gecode::Util::NEGATED_SET_RELATION_TYPES[:==]
55
130
  else
56
- rel_type = Gecode::Constraints::Util::SET_RELATION_TYPES[:==]
131
+ rel_type = Gecode::Util::SET_RELATION_TYPES[:==]
57
132
  end
58
133
 
59
- (params = []) << var.bind
134
+ (params = []) << var.to_set_var.bind
60
135
  params << rel_type
61
- params << Gecode::Constraints::Util.constant_set_to_params(domain)
62
- params << reif_var.bind if reif_var.respond_to? :bind
136
+ params << Gecode::Util.constant_set_to_params(domain)
137
+ params << reif_var.to_bool_var.bind if reif_var.respond_to? :to_bool_var
63
138
  Gecode::Raw::dom(@model.active_space, *params.flatten)
64
139
  end
65
140
  end
66
141
 
67
- # Describes a domain constraint which constrains a set to have a specific
68
- # relation to a constant set. A constant set may be specified in three ways
69
- #
70
- # [Fixnum] Represents a singleton set.
71
- # [Range] Represents a set containing all elements in the
72
- # range. This represents the set more efficiently
73
- # than when another enumeration with the same
74
- # elements are used.
75
- # [Enumeration of Fixnum] Represents a set containing the enumeration’s
76
- # elements.
77
- #
78
- # The relations allowed are the same as in
79
- # <tt>Set::Relation::RelationConstraint</tt>.
80
- #
81
- # == Examples
82
- #
83
- # # +set+ must be subset of [1,2,5]
84
- # set.must_be.subset_of [1,2,5]
85
- #
86
- # # +set+ must be disjoint with 1..67
87
- # set.must_be.disjoint_with 1..67
88
- #
89
- # # +set+ must not be a superset of [0].
90
- # set.must_not_be.superset_of 0
91
- #
92
- # # +set+ must be subset of [1,3,5,7]. The constraint is reified with
93
- # # the boolean varaible +only_constains_odd_values+.
94
- # set.must_be.subset_of([1.3.5.7], :reify => only_contains_odd_values)
95
- class DomainConstraint < Gecode::Constraints::ReifiableConstraint
142
+ class DomainConstraint < Gecode::ReifiableConstraint #:nodoc:
96
143
  def post
97
144
  var, domain, reif_var, relation = @params.values_at(:lhs, :rhs, :reif,
98
145
  :relation)
99
146
 
100
- (params = []) << var.bind
101
- params << Gecode::Constraints::Util::SET_RELATION_TYPES[relation]
102
- params << Gecode::Constraints::Util.constant_set_to_params(domain)
103
- params << reif_var.bind if reif_var.respond_to? :bind
147
+ (params = []) << var.to_set_var.bind
148
+ params << Gecode::Util::SET_RELATION_TYPES[relation]
149
+ params << Gecode::Util.constant_set_to_params(domain)
150
+ params << reif_var.to_bool_var.bind if reif_var.respond_to? :to_bool_var
104
151
  Gecode::Raw::dom(@model.active_space, *params.flatten)
105
152
  end
106
153
  negate_using_reification
107
154
  end
108
155
  end
109
- end
156
+ end
@@ -0,0 +1,36 @@
1
+ module Gecode::Set
2
+ class SetConstraintReceiver
3
+ # Constrains this set to include the values of +int_enum+.
4
+ #
5
+ # The constraint has the side effect of sorting the integer operands in a
6
+ # non-descending order. It does not support reification nor negation.
7
+ #
8
+ # ==== Examples
9
+ #
10
+ # # Constrain +set+ to include the values of all operands in
11
+ # # +int_enum+.
12
+ # set.must.include int_enum
13
+ def include(int_enum)
14
+ unless int_enum.respond_to? :to_int_enum
15
+ raise TypeError, "Expected int var enum, got #{int_enum.class}."
16
+ end
17
+ if @params[:negate]
18
+ raise Gecode::MissingConstraintError, 'A negated include is not ' +
19
+ 'implemented.'
20
+ end
21
+
22
+ @params.update(:variables => int_enum)
23
+ @model.add_constraint Connection::IncludeConstraint.new(@model, @params)
24
+ end
25
+ end
26
+
27
+ module Connection #:nodoc:
28
+ class IncludeConstraint < Gecode::Constraint #:nodoc:
29
+ def post
30
+ set, variables = @params.values_at(:lhs, :variables)
31
+ Gecode::Raw::match(@model.active_space, set.to_set_var.bind,
32
+ variables.to_int_enum.bind_array)
33
+ end
34
+ end
35
+ end
36
+ end