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,34 +1,8 @@
1
- module Gecode::Constraints::IntEnum
2
- class Expression
3
- # Adds a channel constraint on the variables in the enum with the specified
4
- # other set or int enum.
5
- def channel(enum, options = {})
6
- if @params[:negate]
7
- raise Gecode::MissingConstraintError, 'A negated channel constraint ' +
8
- 'is not implemented.'
9
- end
10
- unless enum.respond_to?(:to_int_var_array)
11
- raise TypeError, "Expected int enum, got #{enum.class}."
12
- end
13
- if options.has_key? :reify
14
- raise ArgumentError, 'The channel constraints does not support the ' +
15
- 'reification option.'
16
- end
17
-
18
- @params.update(Gecode::Constraints::Util.decode_options(options))
19
- @params.update(:rhs => enum)
20
- @model.add_constraint Channel::ChannelConstraint.new(@model, @params)
21
- end
22
-
23
- provide_commutivity(:channel){ |rhs, _| rhs.respond_to? :to_set_var_array }
24
- end
25
-
26
- # A module that gathers the classes and modules used in channel constraints.
27
- module Channel #:nodoc:
28
- # Describes a channel constraint which "channels" two enumerations of
29
- # integer variables or one enumeration of integer variables and one
30
- # enumeration of set variables. Channel constraints are used to give
31
- # access to multiple viewpoints when modelling.
1
+ module Gecode::IntEnum
2
+ class IntEnumConstraintReceiver
3
+ # Constrains this enumeration to "channel" +int_enum+. Channel
4
+ # constraints are used to give access to multiple viewpoints when
5
+ # modelling.
32
6
  #
33
7
  # The channel constraint can be thought of as constraining the arrays to
34
8
  # be each other's inverses. I.e. if the i:th value in the first enumeration
@@ -37,9 +11,9 @@ module Gecode::Constraints::IntEnum
37
11
  #
38
12
  # Neither reification nor negation is supported.
39
13
  #
40
- # == Example
14
+ # ==== Examples
41
15
  #
42
- # Lets say that were modelling a sequence of numbers that must be distinct
16
+ # Lets say that we're modelling a sequence of numbers that must be distinct
43
17
  # and that we want access to the following two view simultaneously.
44
18
  #
45
19
  # === First view
@@ -77,12 +51,36 @@ module Gecode::Constraints::IntEnum
77
51
  #
78
52
  # elements.must.channel positions
79
53
  #
80
- class ChannelConstraint < Gecode::Constraints::Constraint
54
+ def channel(int_enum, options = {})
55
+ if @params[:negate]
56
+ raise Gecode::MissingConstraintError, 'A negated channel constraint ' +
57
+ 'is not implemented.'
58
+ end
59
+ unless int_enum.respond_to? :to_int_enum
60
+ raise TypeError, "Expected int enum, got #{int_enum.class}."
61
+ end
62
+ if options.has_key? :reify
63
+ raise ArgumentError, 'The channel constraints does not support the ' +
64
+ 'reification option.'
65
+ end
66
+
67
+ @params.update(Gecode::Util.decode_options(options))
68
+ @params.update(:rhs => int_enum)
69
+ @model.add_constraint Channel::ChannelConstraint.new(@model, @params)
70
+ end
71
+
72
+ # Provides commutativity with SetEnumConstraintReceiver#channel .
73
+ provide_commutativity(:channel){ |rhs, _| rhs.respond_to? :to_set_enum }
74
+ end
75
+
76
+ # A module that gathers the classes and modules used in channel constraints.
77
+ module Channel #:nodoc:
78
+ class ChannelConstraint < Gecode::Constraint #:nodoc:
81
79
  def post
82
80
  lhs, rhs = @params.values_at(:lhs, :rhs)
83
- Gecode::Raw::channel(@model.active_space, lhs.to_int_var_array,
84
- rhs.to_int_var_array, *propagation_options)
81
+ Gecode::Raw::channel(@model.active_space, lhs.to_int_enum.bind_array,
82
+ rhs.to_int_enum.bind_array, *propagation_options)
85
83
  end
86
84
  end
87
85
  end
88
- end
86
+ end
@@ -1,91 +1,66 @@
1
- module Gecode
2
- module IntEnumMethods
3
- # Specifies that a specific element should be counted, starting a count
4
- # constraint. The element can be either an int var or a fixnum.
5
- def count(element)
6
- unless element.kind_of?(FreeIntVar) or element.kind_of?(Fixnum)
7
- raise TypeError, 'Elements used with count can not be of type ' +
8
- "#{element.class}."
9
- end
10
- params = {:lhs => self, :element => element}
11
- Gecode::Constraints::SimpleExpressionStub.new(@model, params) do |m, ps|
12
- Gecode::Constraints::IntEnum::Count::Expression.new(m, ps)
1
+ module Gecode::IntEnum
2
+ module IntEnumOperand
3
+ # Produces a new IntOperand representing the number of times
4
+ # +int_operand_or_fixnum+ is present in this enumeration.
5
+ #
6
+ # ==== Examples
7
+ #
8
+ # # The number of times 17 occurs in +int_enum+.
9
+ # int_enum.count(17)
10
+ #
11
+ # # The number of times +int_operand+ occurs in +int_enum+.
12
+ # int_enum.count(int_operand)
13
+ def count(int_operand_or_fixnum)
14
+ unless int_operand_or_fixnum.respond_to? :to_int_var or
15
+ int_operand_or_fixnum.kind_of?(Fixnum)
16
+ raise TypeError, 'Expected integer operand of fixnum, got ' +
17
+ "#{int_operand_or_fixnum.class}."
13
18
  end
19
+ Count::IntEnumCountOperand.new(@model, self, int_operand_or_fixnum)
14
20
  end
15
21
  end
16
- end
17
22
 
18
- # A module that gathers the classes and modules used in count constraints.
19
- module Gecode::Constraints::IntEnum::Count #:nodoc:
20
- # Describes an expression
21
- class Expression < Gecode::Constraints::IntEnum::Expression #:nodoc:
22
- def initialize(model, params)
23
- super
24
- unless params[:negate]
25
- @method_relations = Gecode::Constraints::Util::RELATION_TYPES
26
- else
27
- @method_relations = Gecode::Constraints::Util::NEGATED_RELATION_TYPES
23
+ # A module that gathers the classes and modules used in count constraints.
24
+ module Count #:nodoc:
25
+ class IntEnumCountOperand < Gecode::Int::ShortCircuitRelationsOperand #:nodoc:
26
+ def initialize(model, int_enum, element)
27
+ super model
28
+ @enum = int_enum
29
+ @element = element
30
+ end
31
+
32
+ def relation_constraint(relation, int_operand_or_fix, params)
33
+ unless params[:negate]
34
+ relation_type =
35
+ Gecode::Util::RELATION_TYPES[relation]
36
+ else
37
+ relation_type =
38
+ Gecode::Util::NEGATED_RELATION_TYPES[relation]
39
+ end
40
+
41
+ params.update(:enum => @enum, :element => @element,
42
+ :rhs => int_operand_or_fix, :relation_type => relation_type)
43
+ CountConstraint.new(@model, params)
28
44
  end
29
45
  end
30
46
 
31
- Gecode::Constraints::Util::RELATION_TYPES.each_pair do |name, type|
32
- class_eval <<-"end_code"
33
- def #{name}(expression, options = {})
34
- unless expression.kind_of?(Fixnum) or
35
- expression.kind_of?(Gecode::FreeIntVar)
36
- raise TypeError, 'Invalid right hand side of count constraint: ' +
37
- "\#{expression.class}."
38
- end
47
+ class CountConstraint < Gecode::ReifiableConstraint #:nodoc:
48
+ def post
49
+ enum, element, relation_type, rhs =
50
+ @params.values_at(:enum, :element, :relation_type, :rhs)
39
51
 
40
- relation = @method_relations[:#{name}]
41
- @params.update(Gecode::Constraints::Util.decode_options(options))
42
- @params.update(:rhs => expression, :relation_type => relation)
43
- @model.add_constraint CountConstraint.new(@model, @params)
52
+ # Bind variables if needed.
53
+ unless element.kind_of? Fixnum
54
+ element = element.to_int_var.bind
44
55
  end
45
- end_code
46
- end
47
- alias_comparison_methods
48
- end
49
-
50
- # Describes a count constraint, which constrains the number of times a value
51
- # (constant or a variable) may occurr in an enumeration of integer variable.
52
- #
53
- # All relations available for +SimpleRelationConstraint+ can be used with
54
- # count constraints. Negation and reification is supported.
55
- #
56
- # == Examples
57
- #
58
- # # Constrain +int_enum+ to not contain 0 exactly once.
59
- # int_enum.count(0).must_not == 1
60
- #
61
- # # Constrain +int_enum+ to contain +x+ exactly +x_count+ times.
62
- # int_enum.count(x).must == x_count
63
- #
64
- # # Reifies the constraint that +int_enum+ has +x+ zeros with the boolean
65
- # # variable +has_x_zeros+ and selects the strength +domain+.
66
- # int_enum.count(0).must.equal(x, :reify => has_x_zeros,
67
- # :strength => :domain)
68
- class CountConstraint < Gecode::Constraints::ReifiableConstraint
69
- def post
70
- lhs, element, relation_type, rhs, reif_var =
71
- @params.values_at(:lhs, :element, :relation_type, :rhs, :reif)
72
-
73
- # Bind variables if needed.
74
- element = element.bind if element.respond_to? :bind
75
- rhs = rhs.bind if rhs.respond_to? :bind
76
-
77
- # Post the constraint to gecode.
78
- if reif_var.nil?
79
- Gecode::Raw::count(@model.active_space, lhs.to_int_var_array,
56
+ unless rhs.kind_of? Fixnum
57
+ rhs = rhs.to_int_var.bind
58
+ end
59
+
60
+ # Post the constraint to gecode.
61
+ Gecode::Raw::count(@model.active_space, enum.to_int_enum.bind_array,
80
62
  element, relation_type, rhs, *propagation_options)
81
- else
82
- # We use a proxy int variable to get the reification.
83
- proxy = @model.int_var(rhs.min..rhs.max)
84
- rel = Gecode::Constraints::Util::RELATION_TYPES.invert[relation_type]
85
- proxy.must.send(rel, @params[:rhs], :reify => reif_var)
86
- Gecode::Raw::count(@model.active_space, lhs.to_int_var_array,
87
- element, Gecode::Raw::IRT_EQ, proxy.bind, *propagation_options)
88
63
  end
89
64
  end
90
65
  end
91
- end
66
+ end
@@ -1,23 +1,26 @@
1
- module Gecode
2
- module IntEnumMethods
3
- # Specifies offsets to be used with a distinct constraint. The offsets can
4
- # be specified one by one or as an array of offsets.
5
- def with_offsets(*offsets)
6
- if offsets.kind_of? Enumerable
7
- offsets = *offsets
8
- end
9
- params = {:lhs => self, :offsets => offsets}
10
-
11
- Gecode::Constraints::SimpleExpressionStub.new(@model, params) do |m, ps|
12
- Gecode::Constraints::IntEnum::Expression.new(m, ps)
13
- end
14
- end
15
- end
16
- end
17
-
18
- module Gecode::Constraints::IntEnum
19
- class Expression
20
- # Posts a distinct constraint on the variables in the enum.
1
+ module Gecode::IntEnum
2
+ class IntEnumConstraintReceiver
3
+ # Constrains all integer operands in the enumeration to be distinct
4
+ # (different). The constraint can also be used with constant
5
+ # offsets, so that the operands, with specified offsets added, must
6
+ # be distinct.
7
+ #
8
+ # The constraint does not support negation nor reification.
9
+ #
10
+ # ==== Examples
11
+ #
12
+ # # Constrains all operands in +int_enum+ to be assigned different
13
+ # # values.
14
+ # int_enum.must_be.distinct
15
+ #
16
+ # # The same as above, but also selects that the strength +domain+ should
17
+ # # be used.
18
+ # int_enum.must_be.distinct(:strength => :domain)
19
+ #
20
+ # # Uses the offset to constrain that no number may be the previous number
21
+ # # incremented by one.
22
+ # numbers = int_var_array(8, 0..9)
23
+ # numbers.must_be.distinct(:offsets => (1..numbers.size).to_a.reverse)
21
24
  def distinct(options = {})
22
25
  if @params[:negate]
23
26
  # The best we could implement it as from here would be a bunch of
@@ -29,39 +32,26 @@ module Gecode::Constraints::IntEnum
29
32
  raise ArgumentError, 'Reification is not supported by the distinct ' +
30
33
  'constraint.'
31
34
  end
32
-
35
+
36
+ if options.has_key? :offsets
37
+ offsets = options.delete(:offsets)
38
+ unless offsets.kind_of? Enumerable
39
+ raise TypeError, 'Expected Enumerable as offsets, got ' +
40
+ "#{offsets.class}."
41
+ end
42
+ @params[:offsets] = offsets
43
+ end
33
44
  @model.add_constraint Distinct::DistinctConstraint.new(@model,
34
- @params.update(Gecode::Constraints::Util.decode_options(options)))
45
+ @params.update(Gecode::Util.decode_options(options)))
35
46
  end
36
47
  end
37
48
 
38
49
  # A module that gathers the classes and modules used in distinct constraints.
39
50
  module Distinct #:nodoc:
40
- # Describes a distinct constraint, which constrains all integer variables
41
- # in an enumeration to be distinct (different). The constraint can also be
42
- # used with constant offsets, so that the variables, with specified offsets
43
- # added, must be distinct.
44
- #
45
- # The constraint does not support negation nor reification.
46
- #
47
- # == Examples
48
- #
49
- # # Constrains all variables in +int_enum+ to be assigned different
50
- # # values.
51
- # int_enum.must_be.distinct
52
- #
53
- # # The same as above, but also selects that the strength +domain+ should
54
- # # be used.
55
- # int_enum.must_be.distinct(:strength => :domain)
56
- #
57
- # # Uses the offset to constrain that no number may be the previous number
58
- # # incremented by one.
59
- # numbers = int_var_array(8, 0..9)
60
- # numbers.with_offset((1..numbers.size).to_a.reverse).must_be.distinct
61
- class DistinctConstraint < Gecode::Constraints::Constraint
51
+ class DistinctConstraint < Gecode::Constraint #:nodoc:
62
52
  def post
63
53
  # Bind lhs.
64
- @params[:lhs] = @params[:lhs].to_int_var_array
54
+ @params[:lhs] = @params[:lhs].to_int_enum.bind_array
65
55
 
66
56
  # Fetch the parameters to Gecode.
67
57
  params = @params.values_at(:offsets, :lhs)
@@ -71,4 +61,4 @@ module Gecode::Constraints::IntEnum
71
61
  end
72
62
  end
73
63
  end
74
- end
64
+ end
@@ -1,65 +1,34 @@
1
- # A module that gathers the classes and modules used by element constraints.
2
- module Gecode::Constraints::IntEnum::Element #:nodoc:
3
- # Describes a CompositeStub for the element constraint, which places a
4
- # constraint on a variable at the specified position in an enumeration of
5
- # integer variables. It's basically the array access of constraint
6
- # programming.
7
- #
8
- # == Example
9
- #
10
- # # The variable at the +x+:th position in +int_enum+ must be larger than
11
- # # +y+.
12
- # int_enum[x].must > y
13
- #
14
- # # The price of +selected_item+ as described by +prices+ must not be
15
- # # larger than 100.
16
- # prices = wrap_enum([500, 24, 4711, 412, 24])
17
- # prices[selected_item].must_not > 100
18
- #
19
- # # Reify the constraint that the +x+:th variable in +int_enum+ must be in
20
- # # range 7..17 with the boolean variable +bool+ and select strength
21
- # # +domain+.
22
- #
23
- # int_enum[x].must_be.in(7..17, :reify => bool, :strength => :domain)
24
- class ExpressionStub < Gecode::Constraints::Int::CompositeStub
25
- def constrain_equal(variable, params, constrain)
26
- enum, position = @params.values_at(:lhs, :position)
27
- if constrain
28
- variable.must_be.in enum.domain_range
29
- end
30
-
31
- # The enum can be a constant array.
32
- enum = enum.to_int_var_array if enum.respond_to? :to_int_var_array
33
- Gecode::Raw::element(@model.active_space, enum,
34
- position.bind, variable.bind, *propagation_options)
35
- end
36
- end
37
-
38
- # Methods needed to add support for element constraints to enums.
39
- module AdditionalEnumMethods #:nodoc:
1
+ module Gecode::IntEnum
2
+ module IntEnumOperand
40
3
  # This adds the adder for the methods in the modules including it. The
41
4
  # reason for doing it so indirect is that the first #[] won't be defined
42
5
  # before the module that this is mixed into is mixed into an enum.
43
- def self.included(enum_mod)
6
+ def self.included(enum_mod) #:nodoc:
44
7
  enum_mod.module_eval do
45
- # Now we enter the module AdditionalEnumMethods is mixed into.
8
+ # Now we enter the module IntEnumOperands is mixed into.
46
9
  class << self
47
10
  alias_method :pre_element_included, :included
48
- def included(mod)
11
+ def included(mod) #:nodoc:
49
12
  mod.module_eval do
50
- # Now we enter the module that the module possibly defining #[]
51
- # is mixed into.
52
13
  if instance_methods.include? '[]'
53
14
  alias_method :pre_element_access, :[]
54
15
  end
55
-
16
+
17
+ # Produces an IntOperand representing the
18
+ # i:th integer operand in the enumeration, where i is the
19
+ # value of the integer operand used as index. Think of it
20
+ # as array access in the world of constraint programming.
21
+ #
22
+ # ==== Examples
23
+ #
24
+ # # The operand at the +x+:th position in +int_enum+,
25
+ # # where +x+ is an integer operand.
26
+ # int_enum[x]
27
+ #
56
28
  def [](*vars)
57
- # Hook in an element constraint if a variable is used for array
58
- # access.
59
- if vars.first.kind_of? Gecode::FreeIntVar
60
- params = {:lhs => self, :position => vars.first}
61
- return Gecode::Constraints::IntEnum::Element::ExpressionStub.new(
62
- @model, params)
29
+ if vars.first.respond_to? :to_int_var
30
+ return Element::ElementIntOperand.new(
31
+ model, self, vars.first)
63
32
  else
64
33
  pre_element_access(*vars) if respond_to? :pre_element_access
65
34
  end
@@ -71,12 +40,25 @@ module Gecode::Constraints::IntEnum::Element #:nodoc:
71
40
  end
72
41
  end
73
42
  end
74
- end
75
43
 
76
- module Gecode::IntEnumMethods
77
- include Gecode::Constraints::IntEnum::Element::AdditionalEnumMethods
78
- end
44
+ module Element #:nodoc:
45
+ class ElementIntOperand < Gecode::Int::ShortCircuitEqualityOperand #:nodoc:
46
+ def initialize(model, enum_op, position_int_var_op)
47
+ super model
48
+ @enum = enum_op
49
+ @position = position_int_var_op
50
+ end
79
51
 
80
- module Gecode::FixnumEnumMethods
81
- include Gecode::Constraints::IntEnum::Element::AdditionalEnumMethods
52
+ def constrain_equal(int_operand, constrain, propagation_options)
53
+ enum = @enum.to_int_enum
54
+ if constrain
55
+ int_operand.must_be.in enum.domain_range
56
+ end
57
+
58
+ Gecode::Raw::element(model.active_space, enum.bind_array,
59
+ @position.to_int_var.bind, int_operand.to_int_var.bind,
60
+ *propagation_options)
61
+ end
62
+ end
63
+ end
82
64
  end
@@ -1,6 +1,12 @@
1
- module Gecode::Constraints::IntEnum
2
- class Expression
3
- # Posts an equality constraint on the variables in the enum.
1
+ module Gecode::IntEnum
2
+ class IntEnumConstraintReceiver
3
+ # Constrains all operands in the enumeration to be equal.
4
+ # Neither negation nor reification is supported.
5
+ #
6
+ # ==== Examples
7
+ #
8
+ # # Constrains all operands in +int_enum+ to be equal.
9
+ # int_enum.must_be.equal
4
10
  def equal(options = {})
5
11
  if @params[:negate]
6
12
  # The best we could implement it as from here would be a bunch of
@@ -14,28 +20,18 @@ module Gecode::Constraints::IntEnum
14
20
  end
15
21
 
16
22
  @model.add_constraint Equality::EqualityConstraint.new(@model,
17
- @params.update(Gecode::Constraints::Util.decode_options(options)))
23
+ @params.update(Gecode::Util.decode_options(options)))
18
24
  end
19
25
  end
20
26
 
21
27
  # A module that gathers the classes and modules used in equality constraints.
22
28
  module Equality #:nodoc:
23
- # Describes an equality constraint, which constrains all variables in an
24
- # integer enumeration to be equal. Neither negation nor reification is
25
- # supported.
26
- #
27
- # == Example
28
- #
29
- # # Constrains all variables in +int_enum+ to be equal.
30
- # int_enum.must_be.equal
31
- class EqualityConstraint < Gecode::Constraints::Constraint
29
+ class EqualityConstraint < Gecode::Constraint #:nodoc:
32
30
  def post
33
- # Bind lhs.
34
- lhs = @params[:lhs].to_int_var_array
35
-
36
- # Fetch the parameters to Gecode.
37
- Gecode::Raw::eq(@model.active_space, lhs, *propagation_options)
31
+ Gecode::Raw::rel(@model.active_space,
32
+ @params[:lhs].to_int_enum.bind_array,
33
+ Gecode::Raw::IRT_EQ, *propagation_options)
38
34
  end
39
35
  end
40
36
  end
41
- end
37
+ end