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,149 +1,150 @@
1
- class Gecode::FreeIntVar
2
- # Initiates an arithmetic absolute value constraint.
3
- def abs
4
- Gecode::Constraints::Int::Arithmetic::AbsExpressionStub.new(@model,
5
- :lhs => self)
6
- end
7
-
8
- # Initiates an arithmetic squared value constraint.
9
- def squared
10
- Gecode::Constraints::Int::Arithmetic::SquaredExpressionStub.new(@model,
11
- :lhs => self)
12
- end
13
-
14
- # Initiates an arithmetic squared root constraint.
15
- def sqrt
16
- Gecode::Constraints::Int::Arithmetic::SquareRootExpressionStub.new(@model,
17
- :lhs => self)
18
- end
19
- alias_method :square_root, :sqrt
20
-
1
+ module Gecode::Int
2
+ module IntOperand
3
+ # Produces an IntOperand representing the absolute value of this
4
+ # operand.
5
+ #
6
+ # ==== Examples
7
+ #
8
+ # # The absolute value of +int_op+.
9
+ # int_op.abs
10
+ def abs
11
+ Arithmetic::IntAbsOperand.new(@model, self)
12
+ end
13
+
14
+ # Produces an IntOperand representing this operand squared.
15
+ #
16
+ # ==== Examples
17
+ #
18
+ # # The value of +int_op*int_op+.
19
+ # int_op.squared
20
+ def squared
21
+ Arithmetic::IntSquaredOperand.new(@model, self)
22
+ end
21
23
 
22
- alias_method :pre_arith_mult, :* if instance_methods.include? '*'
23
-
24
- # Begins a multiplication constraint involving the two int variable.
25
- def *(var)
26
- if var.kind_of? Gecode::FreeIntVar
27
- Gecode::Constraints::Int::Arithmetic::MultExpressionStub.new(
28
- @model, :lhs => self, :var => var)
29
- else
30
- pre_arith_mult(var) if respond_to? :pre_arith_mult
24
+ # Produces an IntOperand representing the square root of this
25
+ # operand rounded down.
26
+ #
27
+ # ==== Examples
28
+ #
29
+ # # The square root of +int_op+, rounded down.
30
+ # int_op.square_root
31
+ def square_root
32
+ Arithmetic::IntSquareRootOperand.new(@model, self)
31
33
  end
32
- end
33
- end
34
+ alias_method :sqrt, :square_root
34
35
 
35
- # A module that gathers the classes and modules used by arithmetic constraints.
36
- module Gecode::Constraints::Int::Arithmetic #:nodoc:
37
- # Describes a CompositeStub for absolute value constraints, which constrain
38
- # the absolute value of an integer variable.
39
- #
40
- # == Examples
41
- #
42
- # # The absolute value of +x+ must be less than 2.
43
- # x.abs.must < 2
44
- #
45
- # # The absolute value of +x+ must be in the range 5..7, with +bool+ as
46
- # # reification variable and +value+ as strength.
47
- # x.abs.must_be.in(5..7, :reify => bool, :strength => :value)
48
- class AbsExpressionStub < Gecode::Constraints::Int::CompositeStub
49
- def constrain_equal(variable, params, constrain)
50
- lhs = @params[:lhs]
51
- if constrain
52
- bounds = [lhs.min.abs, lhs.max.abs]
53
- variable.must_be.in bounds.min..bounds.max
36
+
37
+ alias_method :pre_arith_mult, :*
38
+
39
+ # Produces a new IntOperand representing this operand times
40
+ # +int_operand+.
41
+ #
42
+ # ==== Examples
43
+ #
44
+ # # The value of +int_op1+ times +int_op2+.
45
+ # int_op1 * int_op2
46
+ def *(int_operand)
47
+ if int_operand.respond_to? :to_int_var
48
+ Arithmetic::IntMultOperand.new(@model, self, int_operand)
49
+ else
50
+ pre_arith_mult(int_operand)
54
51
  end
55
-
56
- Gecode::Raw::abs(@model.active_space, lhs.bind, variable.bind,
57
- *propagation_options)
58
52
  end
59
53
  end
60
54
 
61
- # Describes a CompositeStub for multiplication constraint, which constrain
62
- # the value of the multiplication of two variables.
63
- #
64
- # == Examples
65
- #
66
- # # The value of +x*y+ must be equal to their sum.
67
- # (x*y).must == x + y
68
- #
69
- # # The value of +x*y+ must be less than 17, with +bool+ as reification
70
- # # variable and +domain+ as strength.
71
- # (x*y).must_be.less_than(17, :reify => bool, :strength => :domain)
72
- class MultExpressionStub < Gecode::Constraints::Int::CompositeStub
73
- def constrain_equal(variable, params, constrain)
74
- lhs, lhs2 = @params.values_at(:lhs, :var)
75
- if constrain
76
- a_min = lhs.min; a_max = lhs.max
77
- b_min = lhs2.min; b_max = lhs2.max
78
- products = [a_min*b_min, a_min*b_max, a_max*b_min, a_max*b_max]
79
- variable.must_be.in products.min..products.max
55
+ # A module that gathers the classes and modules used by arithmetic
56
+ # constraints.
57
+ module Arithmetic #:nodoc:
58
+ class IntAbsOperand < Gecode::Int::ShortCircuitEqualityOperand #:nodoc:
59
+ def initialize(model, int_op)
60
+ super model
61
+ @int = int_op
80
62
  end
81
63
 
82
- Gecode::Raw::mult(@model.active_space, lhs.bind, lhs2.bind,
83
- variable.bind, *propagation_options)
64
+ def constrain_equal(int_operand, constrain, propagation_options)
65
+ int_op = @int.to_int_var
66
+ if constrain
67
+ bounds = [int_op.min.abs, int_op.max.abs]
68
+ bounds << 0 if int_op.min < 0
69
+ int_operand.must_be.in bounds.min..bounds.max
70
+ end
71
+
72
+ Gecode::Raw::abs(@model.active_space, int_op.to_int_var.bind,
73
+ int_operand.to_int_var.bind, *propagation_options)
74
+ end
84
75
  end
85
- end
86
-
87
- # Describes a CompositeStub for the squared constraint, which constrain
88
- # the squared value of the variable.
89
- #
90
- # == Examples
91
- #
92
- # # The value of +x*x+ must be equal to y.
93
- # x.squared.must == y
94
- #
95
- # # The value of +x*x+ must be less than or equal to 16, with +bool+ as
96
- # # reification variable and +domain+ as strength.
97
- # x.squared.must_be.less_or_equal(16, :reify => bool, :strength => :domain)
98
- class SquaredExpressionStub < Gecode::Constraints::Int::CompositeStub
99
- def constrain_equal(variable, params, constrain)
100
- lhs = @params[:lhs]
101
- if constrain
102
- min = lhs.min; max = lhs.max
103
- products = [min*max, min*min, max*max]
104
- variable.must_be.in products.min..products.max
76
+
77
+ class IntMultOperand < Gecode::Int::ShortCircuitEqualityOperand #:nodoc:
78
+ def initialize(model, op1, op2)
79
+ super model
80
+ @op1 = op1
81
+ @op2 = op2
105
82
  end
106
83
 
107
- Gecode::Raw::sqr(@model.active_space, lhs.bind, variable.bind,
108
- *propagation_options)
109
- end
110
- end
111
-
112
- # Describes a CompositeStub for the square root constraint, which constrain
113
- # the rounded down square root of the variable.
114
- #
115
- # == Examples
116
- #
117
- # # The square root of +x+, rounded down, must equal y.
118
- # x.square_root.must == y
119
- #
120
- # # The square root of +x+, rounded down, must be larger than 17, with
121
- # # +bool+ as reification variable and +domain+ as strength.
122
- # x.square_root.must_be.larger_than(17, :reify => bool, :strength => :domain)
123
- class SquareRootExpressionStub < Gecode::Constraints::Int::CompositeStub
124
- def constrain_equal(variable, params, constrain)
125
- lhs = @params[:lhs]
126
- if constrain
127
- max = lhs.max
128
- if max < 0
129
- # The left hand side does not have a real valued square root.
130
- upper_bound = 0
131
- else
132
- upper_bound = Math.sqrt(max).floor;
84
+ def constrain_equal(int_operand, constrain, propagation_options)
85
+ int_op1, int_op2 = @op1.to_int_var, @op2.to_int_var
86
+ if constrain
87
+ a_min = int_op1.min; a_max = int_op1.max
88
+ b_min = int_op2.min; b_max = int_op2.max
89
+ products = [a_min*b_min, a_min*b_max, a_max*b_min, a_max*b_max]
90
+ int_operand.must_be.in products.min..products.max
133
91
  end
134
-
135
- min = lhs.min
136
- if min < 0
137
- lower_bound = 0
138
- else
139
- lower_bound = Math.sqrt(min).floor;
92
+
93
+ Gecode::Raw::mult(@model.active_space, int_op1.to_int_var.bind,
94
+ int_op2.to_int_var.bind, int_operand.to_int_var.bind,
95
+ *propagation_options)
96
+ end
97
+ end
98
+
99
+ class IntSquaredOperand < Gecode::Int::ShortCircuitEqualityOperand #:nodoc:
100
+ def initialize(model, int_op)
101
+ super model
102
+ @int = int_op
103
+ end
104
+
105
+ def constrain_equal(int_operand, constrain, propagation_options)
106
+ int_op = @int.to_int_var
107
+ if constrain
108
+ min = int_op.min; max = int_op.max
109
+ products = [min*max, min*min, max*max]
110
+ int_operand.must_be.in products.min..products.max
140
111
  end
141
-
142
- variable.must_be.in lower_bound..upper_bound
112
+
113
+ Gecode::Raw::sqr(@model.active_space, int_op.to_int_var.bind,
114
+ int_operand.to_int_var.bind, *propagation_options)
115
+ end
116
+ end
117
+
118
+ class IntSquareRootOperand < Gecode::Int::ShortCircuitEqualityOperand #:nodoc:
119
+ def initialize(model, int_op)
120
+ super model
121
+ @int = int_op
143
122
  end
144
123
 
145
- Gecode::Raw::sqrt(@model.active_space, lhs.bind, variable.bind,
146
- *propagation_options)
124
+ def constrain_equal(int_operand, constrain, propagation_options)
125
+ int_op = @int.to_int_var
126
+ if constrain
127
+ max = int_op.max
128
+ if max < 0
129
+ # The left hand side does not have a real valued square root.
130
+ upper_bound = 0
131
+ else
132
+ upper_bound = Math.sqrt(max).floor;
133
+ end
134
+
135
+ min = int_op.min
136
+ if min < 0
137
+ lower_bound = 0
138
+ else
139
+ lower_bound = Math.sqrt(min).floor;
140
+ end
141
+
142
+ int_operand.must_be.in lower_bound..upper_bound
143
+ end
144
+
145
+ Gecode::Raw::sqrt(@model.active_space, int_op.to_int_var.bind,
146
+ int_operand.to_int_var.bind, *propagation_options)
147
+ end
147
148
  end
148
149
  end
149
150
  end
@@ -1,13 +1,19 @@
1
- module Gecode::Constraints::Int
2
- class Expression
1
+ module Gecode::Int
2
+ class IntConstraintReceiver
3
3
  alias_method :pre_channel_equals, :==
4
4
 
5
- # Constrains the integer variable to be equal to the specified boolean
6
- # variable. I.e. constrains the integer variable to be 1 when the boolean
7
- # variable is true and 0 if the boolean variable is false.
5
+ # Constrains the integer operand to be equal to the specified boolean
6
+ # operand. I.e. constrains the integer operand to be 1 when the boolean
7
+ # operand is true and 0 if the boolean operand is false.
8
+ #
9
+ # ==== Examples
10
+ #
11
+ # # The integer operand +int+ must be one exactly when the boolean
12
+ # # operand +bool+ is true.
13
+ # int.must == bool
8
14
  def ==(bool, options = {})
9
- unless @params[:lhs].kind_of?(Gecode::FreeIntVar) and
10
- bool.kind_of?(Gecode::FreeBoolVar)
15
+ unless @params[:lhs].respond_to? :to_int_var and
16
+ bool.respond_to? :to_bool_var
11
17
  return pre_channel_equals(bool, options)
12
18
  end
13
19
 
@@ -20,42 +26,26 @@ module Gecode::Constraints::Int
20
26
  'constraint.'
21
27
  end
22
28
 
23
- @params.update(Gecode::Constraints::Util.decode_options(options))
29
+ @params.update(Gecode::Util.decode_options(options))
24
30
  @params[:rhs] = bool
25
31
  @model.add_constraint Channel::ChannelConstraint.new(@model, @params)
26
32
  end
27
33
 
28
34
  alias_comparison_methods
29
35
 
30
- # Adds a channel constraint on the integer variable and the variables in
31
- # the specifed enum of boolean variables. Beyond the common options the
32
- # channel constraint can also take the following option:
33
- #
34
- # [:offset] Specifies an offset for the integer variable. If the offset is
35
- # set to k then the integer variable takes value i+k exactly
36
- # when the variable at index i in the boolean enumration is true
37
- # and the rest are false.
38
- provide_commutivity(:channel){ |rhs, _| rhs.respond_to? :to_bool_var_array }
36
+ # Provides commutativity with BoolEnumConstraintReceiver#channel .
37
+ provide_commutativity(:channel){ |rhs, _| rhs.respond_to? :to_bool_enum }
39
38
  end
40
39
 
41
40
  # A module that gathers the classes and modules used in channel constraints
42
- # involving a single integer variable.
41
+ # involving a single integer operand.
43
42
  module Channel #:nodoc:
44
- # Describes a channel constraint that constrains an integer variable to be
45
- # 1 if a boolean variable is true, and 0 when the boolean variable is false.
46
- # Does not support negation nor reification.
47
- #
48
- # == Examples
49
- #
50
- # # The integer variable +x+ must be one exactly when the boolean
51
- # # variable +bool+ is true.
52
- # x.must == bool
53
- class ChannelConstraint < Gecode::Constraints::Constraint
43
+ class ChannelConstraint < Gecode::Constraint #:nodoc:
54
44
  def post
55
45
  lhs, rhs = @params.values_at(:lhs, :rhs)
56
- Gecode::Raw::channel(@model.active_space, lhs.bind, rhs.bind,
57
- *propagation_options)
46
+ Gecode::Raw::channel(@model.active_space, lhs.to_int_var.bind,
47
+ rhs.to_bool_var.bind, *propagation_options)
58
48
  end
59
49
  end
60
50
  end
61
- end
51
+ end
@@ -1,8 +1,34 @@
1
- module Gecode::Constraints::Int
2
- class Expression
3
- # Creates a domain constraint using the specified domain.
1
+ module Gecode::Int
2
+ class IntConstraintReceiver
3
+ # Creates a domain constraint using the specified domain, specified
4
+ # as an enumeration of integers. The integer operand is constrained
5
+ # to take a value in the domain. Domains should be specified as
6
+ # ranges if possible.
7
+ #
8
+ # ==== Examples
9
+ #
10
+ # # +x+ must be in the range 1..10
11
+ # x.must_be.in 1..10
12
+ #
13
+ # # +x+ must not be in the range -5...5
14
+ # x.must_not_be.in -5...5
15
+ #
16
+ # # Specifies the above, but reifies the constraint with the boolean
17
+ # # operand +bool+ and specified +value+ as strength.
18
+ # x.must_not_be.in(-5...5, :reify => bool, :strength => :value)
19
+ #
20
+ # # +x+ must be in the enumeration [3,5,7].
21
+ # x.must_be.in [3,5,7]
22
+ #
23
+ # # +x+ must not be in the enumeration [5,6,7,17].
24
+ # x.must_not_be.in [5,6,7,17]
25
+ #
26
+ # # Specifies the above, but reifies the constraint with the boolean
27
+ # # operand +bool+ and specified +value+ as strength.
28
+ # x.must_not_be.in([5,6,7,17], :reify => bool, :strength => :value)
29
+ #
4
30
  def in(domain, options = {})
5
- @params.update(Gecode::Constraints::Util.decode_options(options))
31
+ @params.update(Gecode::Util.decode_options(options))
6
32
  @params[:domain] = domain
7
33
  if domain.kind_of? Range
8
34
  @model.add_constraint Domain::RangeDomainConstraint.new(@model, @params)
@@ -17,28 +43,17 @@ module Gecode::Constraints::Int
17
43
 
18
44
  # A module that gathers the classes and modules used in domain constraints.
19
45
  module Domain #:nodoc:
20
- # Range domain constraints specify that an integer variable must be
21
- # contained within a specified range of integers. Supports reification and
22
- # negation.
23
- #
24
- # == Examples
25
- #
26
- # # +x+ must be in the range 1..10
27
- # x.must_be.in 1..10
28
- #
29
- # # +x+ must not be in the range -5...5
30
- # x.must_not_be.in -5...5
31
- #
32
- # # Specifies the above, but but reifies the constraint with the boolean
33
- # # variable +bool+ and specified +value+ as strength.
34
- # x.must_not_be.in(-5...5, :reify => bool, :strength => :value)
35
- class RangeDomainConstraint < Gecode::Constraints::ReifiableConstraint
46
+ # Range domain constraints specify that an integer operand must be
47
+ # contained within a specified range of integers.
48
+ class RangeDomainConstraint < Gecode::ReifiableConstraint #:nodoc:
36
49
  def post
37
50
  var, domain, reif_var = @params.values_at(:lhs, :domain, :reif)
38
51
 
39
- (params = []) << var.bind
40
- params << domain.first << domain.last
41
- params << reif_var.bind if reif_var.respond_to? :bind
52
+ (params = []) << var.to_int_var.bind
53
+ last = domain.last
54
+ last -= 1 if domain.exclude_end?
55
+ params << domain.first << last
56
+ params << reif_var.to_bool_var.bind if reif_var.respond_to? :to_bool_var
42
57
  params.concat propagation_options
43
58
 
44
59
  Gecode::Raw::dom(@model.active_space, *params)
@@ -46,27 +61,15 @@ module Gecode::Constraints::Int
46
61
  negate_using_reification
47
62
  end
48
63
 
49
- # Enum domain constraints specify that an integer variable must be contained
50
- # in an enumeration of integers. Supports reification and negation.
51
- #
52
- # == Examples
53
- #
54
- # # +x+ must be in the enumeration [3,5,7].
55
- # x.must_be.in [3,5,7]
56
- #
57
- # # +x+ must not be in the enumeration [5,6,7,17].
58
- # x.must_not_be.in [5,6,7,17]
59
- #
60
- # # Specifies the above, but but reifies the constraint with the boolean
61
- # # variable +bool+ and specified +value+ as strength.
62
- # x.must_not_be.in(-[5,6,7,17], :reify => bool, :strength => :value)
63
- class EnumDomainConstraint < Gecode::Constraints::ReifiableConstraint
64
+ # Enum domain constraints specify that an integer operand must be contained
65
+ # in an enumeration of integers.
66
+ class EnumDomainConstraint < Gecode::ReifiableConstraint #:nodoc:
64
67
  def post
65
68
  var, domain, reif_var = @params.values_at(:lhs, :domain, :reif)
66
69
 
67
- (params = []) << var.bind
68
- params << Gecode::Constraints::Util.constant_set_to_int_set(domain)
69
- params << reif_var.bind if reif_var.respond_to? :bind
70
+ (params = []) << var.to_int_var.bind
71
+ params << Gecode::Util.constant_set_to_int_set(domain)
72
+ params << reif_var.to_bool_var.bind if reif_var.respond_to? :to_bool_var
70
73
  params.concat propagation_options
71
74
 
72
75
  Gecode::Raw::dom(@model.active_space, *params)
@@ -74,4 +77,4 @@ module Gecode::Constraints::Int
74
77
  negate_using_reification
75
78
  end
76
79
  end
77
- end
80
+ end