gecoder-with-gecode 0.8.3 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (337) hide show
  1. data/CHANGES +15 -0
  2. data/README +6 -2
  3. data/example/equation_system.rb +15 -0
  4. data/example/magic_sequence.rb +7 -7
  5. data/example/money.rb +36 -0
  6. data/example/queens.rb +7 -8
  7. data/example/send_most_money.rb +1 -1
  8. data/example/square_tiling.rb +2 -2
  9. data/example/sudoku-set.rb +11 -12
  10. data/example/sudoku.rb +40 -45
  11. data/ext/extconf.rb +0 -0
  12. data/ext/gecode-2.1.1/LICENSE +0 -0
  13. data/ext/gecode-2.1.1/configure +0 -0
  14. data/ext/gecode-2.1.1/contribs/qecode/SDFVariableHeuristic.cc +0 -0
  15. data/ext/gecode-2.1.1/contribs/qecode/SDFVariableHeuristic.hh +0 -0
  16. data/ext/gecode-2.1.1/contribs/qecode/configure +0 -0
  17. data/ext/gecode-2.1.1/contribs/qecode/extensivecomparator.cc +0 -0
  18. data/ext/gecode-2.1.1/contribs/qecode/extensivecomparator.hh +0 -0
  19. data/ext/gecode-2.1.1/contribs/qecode/heap.cc +0 -0
  20. data/ext/gecode-2.1.1/contribs/qecode/implicative.cc +0 -0
  21. data/ext/gecode-2.1.1/contribs/qecode/implicative.hh +0 -0
  22. data/ext/gecode-2.1.1/contribs/qecode/myspace.cc +0 -0
  23. data/ext/gecode-2.1.1/contribs/qecode/myspace.hh +0 -0
  24. data/ext/gecode-2.1.1/contribs/qecode/qecore.cc +0 -0
  25. data/ext/gecode-2.1.1/contribs/qecode/qecore.hh +0 -0
  26. data/ext/gecode-2.1.1/contribs/qecode/warner.cc +0 -0
  27. data/ext/gecode-2.1.1/contribs/qecode/warner.hh +0 -0
  28. data/ext/gecode-2.1.1/gecode/cpltset/var-imp/cpltset.vis +0 -0
  29. data/ext/gecode-2.1.1/gecode/int/arithmetic/abs.icc +0 -0
  30. data/ext/gecode-2.1.1/gecode/int/arithmetic/max.icc +0 -0
  31. data/ext/gecode-2.1.1/gecode/int/arithmetic/mult.icc +0 -0
  32. data/ext/gecode-2.1.1/gecode/int/arithmetic/sqr.icc +0 -0
  33. data/ext/gecode-2.1.1/gecode/int/arithmetic/sqrt.icc +0 -0
  34. data/ext/gecode-2.1.1/gecode/int/array.cc +0 -0
  35. data/ext/gecode-2.1.1/gecode/int/array.icc +0 -0
  36. data/ext/gecode-2.1.1/gecode/int/bool/base.icc +0 -0
  37. data/ext/gecode-2.1.1/gecode/int/bool/eq.icc +0 -0
  38. data/ext/gecode-2.1.1/gecode/int/bool/eqv.icc +0 -0
  39. data/ext/gecode-2.1.1/gecode/int/bool/lq.icc +0 -0
  40. data/ext/gecode-2.1.1/gecode/int/bool/or.icc +0 -0
  41. data/ext/gecode-2.1.1/gecode/int/branch/select-val.icc +0 -0
  42. data/ext/gecode-2.1.1/gecode/int/branch/select-view.icc +0 -0
  43. data/ext/gecode-2.1.1/gecode/int/branch.cc +0 -0
  44. data/ext/gecode-2.1.1/gecode/int/branch.hh +0 -0
  45. data/ext/gecode-2.1.1/gecode/int/channel/base.icc +0 -0
  46. data/ext/gecode-2.1.1/gecode/int/channel/dom.icc +0 -0
  47. data/ext/gecode-2.1.1/gecode/int/channel/link-multi.cc +0 -0
  48. data/ext/gecode-2.1.1/gecode/int/channel/link-multi.icc +0 -0
  49. data/ext/gecode-2.1.1/gecode/int/channel/link-single.cc +0 -0
  50. data/ext/gecode-2.1.1/gecode/int/channel/link-single.icc +0 -0
  51. data/ext/gecode-2.1.1/gecode/int/channel/val.icc +0 -0
  52. data/ext/gecode-2.1.1/gecode/int/channel.cc +0 -0
  53. data/ext/gecode-2.1.1/gecode/int/channel.hh +0 -0
  54. data/ext/gecode-2.1.1/gecode/int/circuit/base.icc +0 -0
  55. data/ext/gecode-2.1.1/gecode/int/circuit/dom.icc +0 -0
  56. data/ext/gecode-2.1.1/gecode/int/circuit/val.icc +0 -0
  57. data/ext/gecode-2.1.1/gecode/int/circuit.cc +0 -0
  58. data/ext/gecode-2.1.1/gecode/int/circuit.hh +0 -0
  59. data/ext/gecode-2.1.1/gecode/int/count/int.icc +0 -0
  60. data/ext/gecode-2.1.1/gecode/int/count/rel.icc +0 -0
  61. data/ext/gecode-2.1.1/gecode/int/count/view.icc +0 -0
  62. data/ext/gecode-2.1.1/gecode/int/distinct/bilink.icc +0 -0
  63. data/ext/gecode-2.1.1/gecode/int/distinct/bnd.icc +0 -0
  64. data/ext/gecode-2.1.1/gecode/int/distinct/combptr.icc +0 -0
  65. data/ext/gecode-2.1.1/gecode/int/distinct/dom.icc +0 -0
  66. data/ext/gecode-2.1.1/gecode/int/distinct/edge.icc +0 -0
  67. data/ext/gecode-2.1.1/gecode/int/distinct/node.icc +0 -0
  68. data/ext/gecode-2.1.1/gecode/int/distinct/ter-dom.icc +0 -0
  69. data/ext/gecode-2.1.1/gecode/int/distinct/val.icc +0 -0
  70. data/ext/gecode-2.1.1/gecode/int/dom/range.icc +0 -0
  71. data/ext/gecode-2.1.1/gecode/int/dom/spec.icc +0 -0
  72. data/ext/gecode-2.1.1/gecode/int/dom.cc +0 -0
  73. data/ext/gecode-2.1.1/gecode/int/dom.hh +0 -0
  74. data/ext/gecode-2.1.1/gecode/int/element/int.icc +0 -0
  75. data/ext/gecode-2.1.1/gecode/int/element/view.icc +0 -0
  76. data/ext/gecode-2.1.1/gecode/int/element.cc +0 -0
  77. data/ext/gecode-2.1.1/gecode/int/element.hh +0 -0
  78. data/ext/gecode-2.1.1/gecode/int/exception.icc +0 -0
  79. data/ext/gecode-2.1.1/gecode/int/extensional/dfa.cc +0 -0
  80. data/ext/gecode-2.1.1/gecode/int/extensional/dfa.icc +0 -0
  81. data/ext/gecode-2.1.1/gecode/int/extensional/layered-graph.icc +0 -0
  82. data/ext/gecode-2.1.1/gecode/int/gcc/dom.icc +0 -0
  83. data/ext/gecode-2.1.1/gecode/int/gcc/gccbndsup.icc +0 -0
  84. data/ext/gecode-2.1.1/gecode/int/gcc/lbc.icc +0 -0
  85. data/ext/gecode-2.1.1/gecode/int/gcc/ubc.icc +0 -0
  86. data/ext/gecode-2.1.1/gecode/int/gcc.cc +0 -0
  87. data/ext/gecode-2.1.1/gecode/int/gcc.hh +0 -0
  88. data/ext/gecode-2.1.1/gecode/int/int-set.cc +0 -0
  89. data/ext/gecode-2.1.1/gecode/int/int-set.icc +0 -0
  90. data/ext/gecode-2.1.1/gecode/int/linear/bool-int.icc +0 -0
  91. data/ext/gecode-2.1.1/gecode/int/linear/bool-post.cc +0 -0
  92. data/ext/gecode-2.1.1/gecode/int/linear/bool-scale.icc +0 -0
  93. data/ext/gecode-2.1.1/gecode/int/linear/bool-view.icc +0 -0
  94. data/ext/gecode-2.1.1/gecode/int/linear/int-bin.icc +0 -0
  95. data/ext/gecode-2.1.1/gecode/int/linear/int-dom.icc +0 -0
  96. data/ext/gecode-2.1.1/gecode/int/linear/int-nary.icc +0 -0
  97. data/ext/gecode-2.1.1/gecode/int/linear/int-post.cc +0 -0
  98. data/ext/gecode-2.1.1/gecode/int/linear/int-ter.icc +0 -0
  99. data/ext/gecode-2.1.1/gecode/int/linear/post.icc +0 -0
  100. data/ext/gecode-2.1.1/gecode/int/propagator.icc +0 -0
  101. data/ext/gecode-2.1.1/gecode/int/rel/eq.icc +0 -0
  102. data/ext/gecode-2.1.1/gecode/int/rel/lex.icc +0 -0
  103. data/ext/gecode-2.1.1/gecode/int/rel/lq-le.icc +0 -0
  104. data/ext/gecode-2.1.1/gecode/int/rel/nq.icc +0 -0
  105. data/ext/gecode-2.1.1/gecode/int/unshare.cc +0 -0
  106. data/ext/gecode-2.1.1/gecode/int/var/bool.cc +0 -0
  107. data/ext/gecode-2.1.1/gecode/int/var-imp/bool.cc +0 -0
  108. data/ext/gecode-2.1.1/gecode/int/var-imp/bool.icc +0 -0
  109. data/ext/gecode-2.1.1/gecode/int/var-imp/bool.vis +0 -0
  110. data/ext/gecode-2.1.1/gecode/int/var-imp/delta.icc +0 -0
  111. data/ext/gecode-2.1.1/gecode/int/var-imp/int.icc +0 -0
  112. data/ext/gecode-2.1.1/gecode/int/var-imp/int.vis +0 -0
  113. data/ext/gecode-2.1.1/gecode/int/view/bool.icc +0 -0
  114. data/ext/gecode-2.1.1/gecode/int/view/constint.icc +0 -0
  115. data/ext/gecode-2.1.1/gecode/int/view/int.icc +0 -0
  116. data/ext/gecode-2.1.1/gecode/int/view/iter.icc +0 -0
  117. data/ext/gecode-2.1.1/gecode/int/view/minus.icc +0 -0
  118. data/ext/gecode-2.1.1/gecode/int/view/offset.icc +0 -0
  119. data/ext/gecode-2.1.1/gecode/int/view/print.cc +0 -0
  120. data/ext/gecode-2.1.1/gecode/int/view/rtest.icc +0 -0
  121. data/ext/gecode-2.1.1/gecode/int/view/scale.icc +0 -0
  122. data/ext/gecode-2.1.1/gecode/int/view/zero.icc +0 -0
  123. data/ext/gecode-2.1.1/gecode/int/view.icc +0 -0
  124. data/ext/gecode-2.1.1/gecode/iter/ranges-add.icc +0 -0
  125. data/ext/gecode-2.1.1/gecode/iter/ranges-append.icc +0 -0
  126. data/ext/gecode-2.1.1/gecode/iter/ranges-array.icc +0 -0
  127. data/ext/gecode-2.1.1/gecode/iter/ranges-cache.icc +0 -0
  128. data/ext/gecode-2.1.1/gecode/iter/ranges-compl.icc +0 -0
  129. data/ext/gecode-2.1.1/gecode/iter/ranges-diff.icc +0 -0
  130. data/ext/gecode-2.1.1/gecode/iter/ranges-empty.icc +0 -0
  131. data/ext/gecode-2.1.1/gecode/iter/ranges-inter.icc +0 -0
  132. data/ext/gecode-2.1.1/gecode/iter/ranges-minmax.icc +0 -0
  133. data/ext/gecode-2.1.1/gecode/iter/ranges-minus.icc +0 -0
  134. data/ext/gecode-2.1.1/gecode/iter/ranges-offset.icc +0 -0
  135. data/ext/gecode-2.1.1/gecode/iter/ranges-operations.icc +0 -0
  136. data/ext/gecode-2.1.1/gecode/iter/ranges-scale.icc +0 -0
  137. data/ext/gecode-2.1.1/gecode/iter/ranges-singleton-append.icc +0 -0
  138. data/ext/gecode-2.1.1/gecode/iter/ranges-singleton.icc +0 -0
  139. data/ext/gecode-2.1.1/gecode/iter/ranges-union.icc +0 -0
  140. data/ext/gecode-2.1.1/gecode/iter/ranges-values.icc +0 -0
  141. data/ext/gecode-2.1.1/gecode/iter/values-array.icc +0 -0
  142. data/ext/gecode-2.1.1/gecode/iter/values-minus.icc +0 -0
  143. data/ext/gecode-2.1.1/gecode/iter/values-offset.icc +0 -0
  144. data/ext/gecode-2.1.1/gecode/iter/values-ranges.icc +0 -0
  145. data/ext/gecode-2.1.1/gecode/iter/values-singleton.icc +0 -0
  146. data/ext/gecode-2.1.1/gecode/iter/values-unique.icc +0 -0
  147. data/ext/gecode-2.1.1/gecode/iter.hh +0 -0
  148. data/ext/gecode-2.1.1/gecode/kernel/advisor.icc +0 -0
  149. data/ext/gecode-2.1.1/gecode/kernel/array.icc +0 -0
  150. data/ext/gecode-2.1.1/gecode/kernel/branching.icc +0 -0
  151. data/ext/gecode-2.1.1/gecode/kernel/exception.icc +0 -0
  152. data/ext/gecode-2.1.1/gecode/kernel/macros.icc +0 -0
  153. data/ext/gecode-2.1.1/gecode/kernel/memory-manager.icc +0 -0
  154. data/ext/gecode-2.1.1/gecode/kernel/modevent.icc +0 -0
  155. data/ext/gecode-2.1.1/gecode/kernel/propagator.icc +0 -0
  156. data/ext/gecode-2.1.1/gecode/kernel/shared-array.icc +0 -0
  157. data/ext/gecode-2.1.1/gecode/kernel/var-traits.icc +0 -0
  158. data/ext/gecode-2.1.1/gecode/kernel/var.icc +0 -0
  159. data/ext/gecode-2.1.1/gecode/kernel/view.icc +0 -0
  160. data/ext/gecode-2.1.1/gecode/kernel.hh +0 -0
  161. data/ext/gecode-2.1.1/gecode/minimodel/arithmetic.cc +0 -0
  162. data/ext/gecode-2.1.1/gecode/minimodel/bool-expr.cc +0 -0
  163. data/ext/gecode-2.1.1/gecode/minimodel/bool-expr.icc +0 -0
  164. data/ext/gecode-2.1.1/gecode/minimodel/bool-rel.icc +0 -0
  165. data/ext/gecode-2.1.1/gecode/minimodel/lin-expr.icc +0 -0
  166. data/ext/gecode-2.1.1/gecode/minimodel/lin-rel.icc +0 -0
  167. data/ext/gecode-2.1.1/gecode/minimodel/reg.cc +0 -0
  168. data/ext/gecode-2.1.1/gecode/minimodel.hh +0 -0
  169. data/ext/gecode-2.1.1/gecode/search/bab.cc +0 -0
  170. data/ext/gecode-2.1.1/gecode/search/bab.icc +0 -0
  171. data/ext/gecode-2.1.1/gecode/search/dfs.cc +0 -0
  172. data/ext/gecode-2.1.1/gecode/search/dfs.icc +0 -0
  173. data/ext/gecode-2.1.1/gecode/search/engine-ctrl.icc +0 -0
  174. data/ext/gecode-2.1.1/gecode/search/lds.cc +0 -0
  175. data/ext/gecode-2.1.1/gecode/search/lds.icc +0 -0
  176. data/ext/gecode-2.1.1/gecode/search/options.cc +0 -0
  177. data/ext/gecode-2.1.1/gecode/search/options.icc +0 -0
  178. data/ext/gecode-2.1.1/gecode/search/reco-stack.icc +0 -0
  179. data/ext/gecode-2.1.1/gecode/search/restart.icc +0 -0
  180. data/ext/gecode-2.1.1/gecode/search/statistics.icc +0 -0
  181. data/ext/gecode-2.1.1/gecode/search/stop.cc +0 -0
  182. data/ext/gecode-2.1.1/gecode/search/stop.icc +0 -0
  183. data/ext/gecode-2.1.1/gecode/set/var-imp/set.vis +0 -0
  184. data/ext/gecode-2.1.1/gecode/support/block-allocator.icc +0 -0
  185. data/ext/gecode-2.1.1/gecode/support/cast.icc +0 -0
  186. data/ext/gecode-2.1.1/gecode/support/exception.cc +0 -0
  187. data/ext/gecode-2.1.1/gecode/support/exception.icc +0 -0
  188. data/ext/gecode-2.1.1/gecode/support/macros.icc +0 -0
  189. data/ext/gecode-2.1.1/gecode/support/marked-pointer.icc +0 -0
  190. data/ext/gecode-2.1.1/gecode/support/memory.icc +0 -0
  191. data/ext/gecode-2.1.1/gecode/support/sentinel-stack.icc +0 -0
  192. data/ext/gecode-2.1.1/gecode/support/static-stack.icc +0 -0
  193. data/ext/gecode-2.1.1/gecode/support/symbol.cc +0 -0
  194. data/ext/gecode-2.1.1/gecode/support.hh +0 -0
  195. data/ext/gecode-2.1.1/install-sh +0 -0
  196. data/ext/gecode-2.1.1/misc/debian/rules +0 -0
  197. data/ext/gecode-2.1.1/misc/doxygen/back.png +0 -0
  198. data/ext/gecode-2.1.1/misc/doxygen/gecode-logo-100.png +0 -0
  199. data/ext/gecode-2.1.1/misc/genchangelog.perl +0 -0
  200. data/ext/gecode-2.1.1/misc/genlicense.perl +0 -0
  201. data/ext/gecode-2.1.1/misc/genstatistics.perl +0 -0
  202. data/ext/gecode-2.1.1/misc/genvariables.perl +0 -0
  203. data/ext/gecode-2.1.1/misc/getrevision.perl +0 -0
  204. data/ext/gecode-2.1.1/misc/makedepend.perl +0 -0
  205. data/ext/gecode-2.1.1/misc/svn-ignore.txt +0 -0
  206. data/ext/gecode-2.1.1/variables.vsl +0 -0
  207. data/lib/gecoder/bindings/bindings.rb +16 -0
  208. data/lib/gecoder/bindings.rb +42 -0
  209. data/lib/gecoder/interface/branch.rb +16 -9
  210. data/lib/gecoder/interface/constraints/bool/boolean.rb +205 -213
  211. data/lib/gecoder/interface/constraints/bool/channel.rb +4 -5
  212. data/lib/gecoder/interface/constraints/bool/linear.rb +192 -21
  213. data/lib/gecoder/interface/constraints/bool_enum/channel.rb +43 -39
  214. data/lib/gecoder/interface/constraints/bool_enum/extensional.rb +43 -49
  215. data/lib/gecoder/interface/constraints/bool_enum/relation.rb +38 -71
  216. data/lib/gecoder/interface/constraints/bool_enum_constraints.rb +73 -22
  217. data/lib/gecoder/interface/constraints/bool_var_constraints.rb +140 -61
  218. data/lib/gecoder/interface/constraints/extensional_regexp.rb +4 -4
  219. data/lib/gecoder/interface/constraints/fixnum_enum/element.rb +63 -0
  220. data/lib/gecoder/interface/constraints/fixnum_enum/operation.rb +65 -0
  221. data/lib/gecoder/interface/constraints/fixnum_enum_constraints.rb +42 -0
  222. data/lib/gecoder/interface/constraints/int/arithmetic.rb +131 -130
  223. data/lib/gecoder/interface/constraints/int/channel.rb +21 -31
  224. data/lib/gecoder/interface/constraints/int/domain.rb +45 -42
  225. data/lib/gecoder/interface/constraints/int/linear.rb +85 -239
  226. data/lib/gecoder/interface/constraints/int/relation.rb +141 -0
  227. data/lib/gecoder/interface/constraints/int_enum/arithmetic.rb +55 -64
  228. data/lib/gecoder/interface/constraints/int_enum/channel.rb +35 -37
  229. data/lib/gecoder/interface/constraints/int_enum/count.rb +53 -78
  230. data/lib/gecoder/interface/constraints/int_enum/distinct.rb +36 -46
  231. data/lib/gecoder/interface/constraints/int_enum/element.rb +39 -57
  232. data/lib/gecoder/interface/constraints/int_enum/equality.rb +15 -19
  233. data/lib/gecoder/interface/constraints/int_enum/extensional.rb +65 -72
  234. data/lib/gecoder/interface/constraints/int_enum/sort.rb +42 -45
  235. data/lib/gecoder/interface/constraints/int_enum_constraints.rb +79 -22
  236. data/lib/gecoder/interface/constraints/int_var_constraints.rb +215 -44
  237. data/lib/gecoder/interface/constraints/reifiable_constraints.rb +14 -14
  238. data/lib/gecoder/interface/constraints/selected_set/select.rb +120 -0
  239. data/lib/gecoder/interface/constraints/selected_set_constraints.rb +75 -0
  240. data/lib/gecoder/interface/constraints/set/cardinality.rb +43 -53
  241. data/lib/gecoder/interface/constraints/set/channel.rb +26 -29
  242. data/lib/gecoder/interface/constraints/set/connection.rb +89 -152
  243. data/lib/gecoder/interface/constraints/set/domain.rb +112 -65
  244. data/lib/gecoder/interface/constraints/set/include.rb +36 -0
  245. data/lib/gecoder/interface/constraints/set/operation.rb +96 -110
  246. data/lib/gecoder/interface/constraints/set/relation.rb +114 -137
  247. data/lib/gecoder/interface/constraints/set_elements/relation.rb +116 -0
  248. data/lib/gecoder/interface/constraints/set_elements_constraints.rb +97 -0
  249. data/lib/gecoder/interface/constraints/set_enum/channel.rb +23 -27
  250. data/lib/gecoder/interface/constraints/set_enum/distinct.rb +18 -19
  251. data/lib/gecoder/interface/constraints/set_enum/operation.rb +62 -53
  252. data/lib/gecoder/interface/constraints/set_enum/select.rb +79 -0
  253. data/lib/gecoder/interface/constraints/set_enum_constraints.rb +73 -23
  254. data/lib/gecoder/interface/constraints/set_var_constraints.rb +222 -57
  255. data/lib/gecoder/interface/constraints.rb +410 -451
  256. data/lib/gecoder/interface/enum_matrix.rb +4 -4
  257. data/lib/gecoder/interface/enum_wrapper.rb +71 -22
  258. data/lib/gecoder/interface/model.rb +167 -12
  259. data/lib/gecoder/interface/model_sugar.rb +84 -0
  260. data/lib/gecoder/interface/search.rb +30 -18
  261. data/lib/gecoder/interface/variables.rb +103 -33
  262. data/lib/gecoder/interface.rb +2 -1
  263. data/lib/gecoder/version.rb +2 -2
  264. data/specs/bool_var.rb +19 -12
  265. data/specs/constraints/{boolean.rb → bool/boolean.rb} +103 -28
  266. data/specs/constraints/bool/boolean_properties.rb +51 -0
  267. data/specs/constraints/bool/linear.rb +213 -0
  268. data/specs/constraints/bool_enum/bool_enum_relation.rb +117 -0
  269. data/specs/constraints/bool_enum/channel.rb +102 -0
  270. data/specs/constraints/{extensional.rb → bool_enum/extensional.rb} +32 -101
  271. data/specs/constraints/constraint_helper.rb +149 -179
  272. data/specs/constraints/constraint_receivers.rb +103 -0
  273. data/specs/constraints/constraints.rb +6 -63
  274. data/specs/constraints/fixnum_enum/element.rb +58 -0
  275. data/specs/constraints/fixnum_enum/operation.rb +67 -0
  276. data/specs/constraints/int/arithmetic.rb +149 -0
  277. data/specs/constraints/int/channel.rb +101 -0
  278. data/specs/constraints/int/domain.rb +106 -0
  279. data/specs/constraints/int/linear.rb +183 -0
  280. data/specs/constraints/int/linear_properties.rb +97 -0
  281. data/specs/constraints/int/relation.rb +84 -0
  282. data/specs/constraints/int_enum/arithmetic.rb +72 -0
  283. data/specs/constraints/int_enum/channel.rb +57 -0
  284. data/specs/constraints/int_enum/count.rb +72 -0
  285. data/specs/constraints/int_enum/distinct.rb +80 -0
  286. data/specs/constraints/int_enum/element.rb +61 -0
  287. data/specs/constraints/int_enum/equality.rb +29 -0
  288. data/specs/constraints/int_enum/extensional.rb +224 -0
  289. data/specs/constraints/int_enum/sort.rb +167 -0
  290. data/specs/constraints/operands.rb +264 -0
  291. data/specs/constraints/property_helper.rb +443 -0
  292. data/specs/constraints/reification_sugar.rb +4 -5
  293. data/specs/constraints/selected_set/select.rb +56 -0
  294. data/specs/constraints/selected_set/select_properties.rb +157 -0
  295. data/specs/constraints/set/cardinality.rb +58 -0
  296. data/specs/constraints/set/cardinality_properties.rb +46 -0
  297. data/specs/constraints/set/channel.rb +77 -0
  298. data/specs/constraints/set/connection.rb +176 -0
  299. data/specs/constraints/set/domain.rb +197 -0
  300. data/specs/constraints/set/include.rb +36 -0
  301. data/specs/constraints/set/operation.rb +132 -0
  302. data/specs/constraints/set/relation.rb +117 -0
  303. data/specs/constraints/set_elements/relation.rb +84 -0
  304. data/specs/constraints/set_enum/channel.rb +80 -0
  305. data/specs/constraints/set_enum/distinct.rb +59 -0
  306. data/specs/constraints/set_enum/operation.rb +111 -0
  307. data/specs/constraints/set_enum/select.rb +73 -0
  308. data/specs/enum_wrapper.rb +53 -3
  309. data/specs/int_var.rb +44 -25
  310. data/specs/model.rb +58 -1
  311. data/specs/model_sugar.rb +30 -0
  312. data/specs/search.rb +24 -5
  313. data/specs/selected_set.rb +39 -0
  314. data/specs/set_elements.rb +34 -0
  315. data/specs/set_var.rb +22 -8
  316. data/specs/spec_helper.rb +206 -6
  317. data/tasks/distribution.rake +22 -7
  318. data/tasks/svn.rake +3 -1
  319. metadata +219 -135
  320. data/lib/gecoder/interface/constraints/set_enum/selection.rb +0 -217
  321. data/specs/constraints/arithmetic.rb +0 -351
  322. data/specs/constraints/bool_enum_relation.rb +0 -160
  323. data/specs/constraints/cardinality.rb +0 -157
  324. data/specs/constraints/channel.rb +0 -454
  325. data/specs/constraints/connection.rb +0 -369
  326. data/specs/constraints/count.rb +0 -146
  327. data/specs/constraints/distinct.rb +0 -164
  328. data/specs/constraints/element.rb +0 -108
  329. data/specs/constraints/equality.rb +0 -31
  330. data/specs/constraints/int_domain.rb +0 -70
  331. data/specs/constraints/int_relation.rb +0 -82
  332. data/specs/constraints/linear.rb +0 -340
  333. data/specs/constraints/selection.rb +0 -292
  334. data/specs/constraints/set_domain.rb +0 -185
  335. data/specs/constraints/set_operation.rb +0 -285
  336. data/specs/constraints/set_relation.rb +0 -197
  337. data/specs/constraints/sort.rb +0 -179
@@ -1,7 +1,17 @@
1
- module Gecode::Constraints::IntEnum
2
- class Expression
3
- # Posts a tuple constraint on the variables in the enum, constraining them
4
- # to equal one of the specified tuples.
1
+ module Gecode::IntEnum
2
+ class IntEnumConstraintReceiver
3
+ # Constrains all the operands in this enumeration to be equal to
4
+ # one of the specified tuples. Neither negation nor reification is
5
+ # supported.
6
+ #
7
+ # ==== Examples
8
+ #
9
+ # # Constrains the two integer operands in +numbers+ to either have
10
+ # # values 1 and 7, or values 47 and 11.
11
+ # numbers.must_be.in [[1,7], [47,11]]
12
+ #
13
+ # # The same as above, but preferring speed over low memory usage.
14
+ # numbers.must_be.in([[1,7], [47,11]], :kind => :speed)
5
15
  def in(tuples, options = {})
6
16
  if @params[:negate]
7
17
  raise Gecode::MissingConstraintError, 'A negated tuple constraint is ' +
@@ -12,7 +22,7 @@ module Gecode::Constraints::IntEnum
12
22
  'constraint.'
13
23
  end
14
24
 
15
- util = Gecode::Constraints::Util
25
+ util = Gecode::Util
16
26
 
17
27
  # Check that the tuples are correct.
18
28
  expected_size = @params[:lhs].size
@@ -27,64 +37,9 @@ module Gecode::Constraints::IntEnum
27
37
  @params.update(util.decode_options(options)))
28
38
  end
29
39
 
30
- # Adds a constraint that forces the enumeration to match the
31
- # specified regular expression over the integer domain. The regular
32
- # expression is expressed using arrays and integers. See
33
- # IntEnum::Extensional::RegexpConstraint for more information and examples of
34
- # such regexps.
35
- def match(regexp, options = {})
36
- if @params[:negate]
37
- raise Gecode::MissingConstraintError, 'A negated regexp constraint ' +
38
- 'is not implemented.'
39
- end
40
- unless options[:reify].nil?
41
- raise ArgumentError, 'Reification is not supported by the regexp ' +
42
- 'constraint.'
43
- end
44
-
45
- @params[:regexp] =
46
- Gecode::Constraints::Util::Extensional.parse_regexp regexp
47
- @params.update Gecode::Constraints::Util.decode_options(options)
48
- @model.add_constraint Extensional::RegexpConstraint.new(@model, @params)
49
- end
50
- end
51
-
52
- # A module that gathers the classes and modules used in extensional
53
- # constraints.
54
- module Extensional #:nodoc:
55
- # Describes a tuple constraint, which constrains all the variables in an
56
- # enumeration of integer variables to be equal to one of the specified
57
- # tuples. Neither negation nor reification is supported.
58
- #
59
- # == Example
60
- #
61
- # # Constrains the two integer variables in +numbers+ to either have
62
- # # values 1 and 7, or values 47 and 11.
63
- # numbers.must_be.in [[1,7], [47,11]]
64
- #
65
- # # The same as above, but preferring speed over low memory usage.
66
- # numbers.must_be.in([[1,7], [47,11]], :kind => :speed)
67
- class TupleConstraint < Gecode::Constraints::Constraint
68
- def post
69
- # Bind lhs.
70
- lhs = @params[:lhs].to_int_var_array
71
-
72
- # Create the tuple set.
73
- tuple_set = Gecode::Raw::TupleSet.new
74
- @params[:tuples].each do |tuple|
75
- tuple_set.add tuple
76
- end
77
- tuple_set.finalize
78
-
79
- # Post the constraint.
80
- Gecode::Raw::extensional(@model.active_space, lhs, tuple_set,
81
- *propagation_options)
82
- end
83
- end
84
-
85
- # Describes a regexp constraint, which constrains the enumeration of
86
- # integer variables to match a specified regexp in the integer
87
- # domain. Neither negation nor reification is supported.
40
+ # Constrains the sequence of operands in this enumeration to match
41
+ # a specified regexp in the integer domain. Neither negation nor
42
+ # reification is supported.
88
43
  #
89
44
  # == Regexp syntax
90
45
  #
@@ -114,7 +69,7 @@ module Gecode::Constraints::IntEnum
114
69
  # Additionally Model#at_least_once and Model#at_most_once are
115
70
  # provided as convenience methods.
116
71
  #
117
- # === Examples
72
+ # ==== Examples
118
73
  #
119
74
  # # Matches 1 followed by any number of 2s.
120
75
  # [1, repeat(2)]
@@ -166,28 +121,66 @@ module Gecode::Constraints::IntEnum
166
121
  # # Exactly the same as the above.
167
122
  # [0, repeat(1, 0, 1)]
168
123
  #
169
- # == Example
124
+ # ==== Examples
170
125
  #
171
- # # Constrains the two integer variables in +numbers+ to have
126
+ # # Constrains the two integer operands in +numbers+ to have
172
127
  # # values 1 and 7.
173
128
  # numbers.must.match [1, 7]
174
129
  #
175
- # # Constrains the integer variables in +numbers+ to contain the
130
+ # # Constrains the integer operands in +numbers+ to contain the
176
131
  # # value 47 followed by 11, with all other values set to -1.
177
132
  # numbers.must.match [repeat(-1), 47, 11, repeat(-1)]
178
133
  #
179
- # # Constrains exactly three of the integer variables in +numbers+ to
134
+ # # Constrains exactly three of the integer operands in +numbers+ to
180
135
  # # contain 47 or 11, each followed by at least two
181
- # # variables set to -1. All other variables are constrained to
136
+ # # operands set to -1. All other operands are constrained to
182
137
  # # equal -1.
183
138
  # numbers.must.match repeat([repeat(-1), any(11, 47),
184
139
  # repeat(-1, 2)], 3, 3)
185
140
  #
186
- class RegexpConstraint < Gecode::Constraints::Constraint
141
+ def match(regexp, options = {})
142
+ if @params[:negate]
143
+ raise Gecode::MissingConstraintError, 'A negated regexp constraint ' +
144
+ 'is not implemented.'
145
+ end
146
+ unless options[:reify].nil?
147
+ raise ArgumentError, 'Reification is not supported by the regexp ' +
148
+ 'constraint.'
149
+ end
150
+
151
+ @params[:regexp] =
152
+ Gecode::Util::Extensional.parse_regexp regexp
153
+ @params.update Gecode::Util.decode_options(options)
154
+ @model.add_constraint Extensional::RegexpConstraint.new(@model, @params)
155
+ end
156
+ end
157
+
158
+ # A module that gathers the classes and modules used in extensional
159
+ # constraints.
160
+ module Extensional #:nodoc:
161
+ class TupleConstraint < Gecode::Constraint #:nodoc:
162
+ def post
163
+ # Bind lhs.
164
+ lhs = @params[:lhs].to_int_enum.bind_array
165
+
166
+ # Create the tuple set.
167
+ tuple_set = Gecode::Raw::TupleSet.new
168
+ @params[:tuples].each do |tuple|
169
+ tuple_set.add tuple
170
+ end
171
+ tuple_set.finalize
172
+
173
+ # Post the constraint.
174
+ Gecode::Raw::extensional(@model.active_space, lhs, tuple_set,
175
+ *propagation_options)
176
+ end
177
+ end
178
+
179
+ class RegexpConstraint < Gecode::Constraint #:nodoc:
187
180
  def post
188
181
  lhs, regexp = @params.values_at(:lhs, :regexp)
189
- Gecode::Raw::extensional(@model.active_space, lhs.to_int_var_array,
190
- regexp, *propagation_options)
182
+ Gecode::Raw::extensional(@model.active_space,
183
+ lhs.to_int_enum.bind_array, regexp, *propagation_options)
191
184
  end
192
185
  end
193
186
  end
@@ -1,36 +1,60 @@
1
- module Gecode::Constraints::IntEnum
2
- class Expression
3
- # Initiates a sort constraint. Beyond the common options the sort constraint
4
- # can also take the following options:
1
+ module Gecode::IntEnum
2
+ class IntEnumConstraintReceiver
3
+ # Constrains the elements in this enumeration to be sorted in ascending
4
+ # order. The following options can be given in addition to the
5
+ # common constraint options:
5
6
  #
6
- # [:as] Defines a target (must be an int variable enumerable) that will
7
+ # [:as] Defines a target (must be an IntEnum) that will
7
8
  # hold the sorted version of the original enumerable. The original
8
9
  # enumerable will not be affected (i.e. will not necessarily be
9
10
  # sorted)
10
- # [:order] Sets an int variable enumerable that should be used to store the
11
- # order of the original enum's variables when sorted. The original
11
+ # [:order] Sets an IntEnum that should be used to store the
12
+ # order of the original enum's operands when sorted. The original
12
13
  # enumerable will not be affected (i.e. will not necessarily be
13
14
  # sorted)
14
15
  #
15
16
  # If neither of those options are specified then the original enumerable
16
17
  # will be constrained to be sorted (otherwise not). Sort constraints with
17
18
  # options do not allow negation.
19
+ #
20
+ # ==== Examples
21
+ #
22
+ # # Constrain +numbers+ to be sorted.
23
+ # numbers.must_be.sorted
24
+ #
25
+ # # Constrain +numbers+ to not be sorted.
26
+ # numbers.must_not_be.sorted
27
+ #
28
+ # # Constrain +sorted_numbers+ to be a sorted version of +numbers+.
29
+ # numbers.must_be.sorted(:as => sorted_numbers)
30
+ #
31
+ # # Constrain +order+ to be the order in which +numbers+ has to be
32
+ # # ordered to be sorted.
33
+ # numbers.must_be.sorted(:order => order)
34
+ #
35
+ # # Constrain +sorted_numbers+ to be +numbers+ sorted in the order
36
+ # # described by the IntEnum +order+.
37
+ # numbers.must_be.sorted(:as => sorted_numbers, :order => order)
38
+ #
39
+ # # Constrains +numbers+ to be sorted, reifying with the boolean
40
+ # # operand +is_sorted+, while selecting +domain+ as strength.
41
+ # numbers.must_be.sorted(:reify => :is_sorted, :strength => :domain)
18
42
  def sorted(options = {})
19
43
  # Extract and check options.
20
44
  target = options.delete(:as)
21
45
  order = options.delete(:order)
22
- unless target.nil? or target.respond_to? :to_int_var_array
46
+ unless target.nil? or target.respond_to? :to_int_enum
23
47
  raise TypeError, 'Expected int var enum as :as, got ' +
24
48
  "#{target.class}."
25
49
  end
26
- unless order.nil? or order.respond_to? :to_int_var_array
50
+ unless order.nil? or order.respond_to? :to_int_enum
27
51
  raise TypeError, 'Expected int var enum as :order, got ' +
28
52
  "#{order.class}."
29
53
  end
30
54
 
31
55
  # Extract standard options and convert to constraint.
32
56
  reified = !options[:reify].nil?
33
- @params.update(Gecode::Constraints::Util.decode_options(options))
57
+ @params.update(Gecode::Util.decode_options(options))
34
58
  if target.nil? and order.nil?
35
59
  @model.add_constraint Sort::SortConstraint.new(@model, @params)
36
60
  else
@@ -53,33 +77,18 @@ module Gecode::Constraints::IntEnum
53
77
 
54
78
  # A module that gathers the classes and modules used in sort constraints.
55
79
  module Sort #:nodoc:
56
- # Describes a sort constraint which constrains a target enumeration of
57
- # integer variables to be the sorted version of another set of integer
58
- # variables. Optionally a third enumeration may be used to define the order
59
- # in which the the variables should be sorted.
60
- #
61
- # Neither negation nor reification is supported.
62
- #
63
- # == Example
64
- #
65
- # # Constrains +sorted_numbers+ to be a sorted version of +numbers+.
66
- # numbers.must_be.sorted(:as => sorted_numbers)
67
- #
68
- # # Constrains +sorted_numbers+ to be +numbers+ sorted in the order
69
- # # described by the integer variable enumeration +order+.
70
- # numbers.must_be.sorted(:as => sorted_numbers, :order => order)
71
- class SortConstraintWithOptions < Gecode::Constraints::Constraint
80
+ class SortConstraintWithOptions < Gecode::Constraint #:nodoc:
72
81
  def post
73
82
  if @params[:target].nil?
74
83
  # We must have a target.
75
- lhs = @params[:lhs]
84
+ lhs = @params[:lhs].to_int_enum
76
85
  @params[:target] = @model.int_var_array(lhs.size, lhs.domain_range)
77
86
  end
78
87
 
79
88
  # Prepare the parameters.
80
89
  params = @params.values_at(:lhs, :target, :order).map do |param|
81
- if param.respond_to? :to_int_var_array
82
- param.to_int_var_array
90
+ if param.respond_to? :to_int_enum
91
+ param.to_int_enum.bind_array
83
92
  else
84
93
  param
85
94
  end
@@ -91,19 +100,7 @@ module Gecode::Constraints::IntEnum
91
100
  end
92
101
  end
93
102
 
94
- # Describes a sort constraint which constrains an enumeration of integer
95
- # variables to be sorted. Supports reification and negation.
96
- #
97
- # == Example
98
- #
99
- # # Constrains the variables in +int_enum+ to be sorted ascendingly.
100
- # int_enum.must_be.sorted
101
- #
102
- # # Reifies the constraint that the variables in +int_enum+ to be sorted
103
- # # ascendingly with the boolean variable +is_sorted+, while selecting
104
- # # +domain+ as strength.
105
- # int_enum.must_be.sorted(:reify => :is_sorted, :strength => :domain)
106
- class SortConstraint < Gecode::Constraints::ReifiableConstraint
103
+ class SortConstraint < Gecode::ReifiableConstraint #:nodoc:
107
104
  def post
108
105
  lhs, strength, kind, reif_var =
109
106
  @params.values_at(:lhs, :strength, :kind, :reif)
@@ -112,9 +109,9 @@ module Gecode::Constraints::IntEnum
112
109
  # We translate the constraint into n-1 relation constraints.
113
110
  options = {
114
111
  :strength =>
115
- Gecode::Constraints::Util::PROPAGATION_STRENGTHS.invert[strength],
112
+ Gecode::Util::PROPAGATION_STRENGTHS.invert[strength],
116
113
  :kind =>
117
- Gecode::Constraints::Util::PROPAGATION_KINDS.invert[kind]
114
+ Gecode::Util::PROPAGATION_KINDS.invert[kind]
118
115
  }
119
116
  if using_reification
120
117
  reification_variables = @model.bool_var_array(lhs.size - 1)
@@ -135,4 +132,4 @@ module Gecode::Constraints::IntEnum
135
132
  negate_using_reification
136
133
  end
137
134
  end
138
- end
135
+ end
@@ -1,28 +1,85 @@
1
- module Gecode
2
- module IntEnumMethods
3
- include Gecode::Constraints::LeftHandSideMethods
4
-
1
+ # A module containing constraints that have enumerations of integer
2
+ # operands as left hand side.
3
+ module Gecode::IntEnum #:nodoc:
4
+ # A IntEnumOperand is a enumeration of IntOperand on which the
5
+ # constraints defined in IntEnumConstraintReceiver can be placed.
6
+ #
7
+ # Enumerations of integer operands can be created either by using
8
+ # Gecode::Model#int_var_array and Gecode::Model#int_var_matrix, or
9
+ # by wrapping an existing enumeration containing IntOperand using
10
+ # Gecode::Model#wrap_enum. The enumerations, no matter how they were
11
+ # created, all respond to the properties defined by IntEnumOperand.
12
+ #
13
+ # ==== Examples
14
+ #
15
+ # Produces an array of five int operands with domain 0..9 inside a
16
+ # problem formulation using Gecode::Model#int_var_array:
17
+ #
18
+ # int_enum = int_var_array(5, 0..9)
19
+ #
20
+ # Uses Gecode::Model#wrap_enum inside a problem formulation to create
21
+ # a IntEnumOperand from an existing enumeration containing the
22
+ # integer operands +int_operand1+ and +int_operand2+:
23
+ #
24
+ # int_enum = wrap_enum([int_operand1, int_operand2])
25
+ #
26
+ #--
27
+ # Classes that mix in IntEnumOperand must define #model and
28
+ # #to_int_enum .
29
+ module IntEnumOperand
30
+ include Gecode::Operand
31
+
32
+ def method_missing(method, *args) #:nodoc:
33
+ if Gecode::IntEnum::Dummy.instance_methods.include? method.to_s
34
+ # Delegate to the int enum.
35
+ to_int_enum.method(method).call(*args)
36
+ else
37
+ super
38
+ end
39
+ end
40
+
5
41
  private
6
-
7
- # Produces an expression for the lhs module.
8
- def expression(params)
9
- params.update(:lhs => self)
10
- Constraints::IntEnum::Expression.new(@model, params)
42
+
43
+ def construct_receiver(params)
44
+ IntEnumConstraintReceiver.new(@model, params)
11
45
  end
12
46
  end
13
-
14
- # A module containing constraints that have enumerations of integer
15
- # variables as left hand side.
16
- module Constraints::IntEnum
17
- # Expressions with int enums as left hand sides.
18
- class Expression < Gecode::Constraints::Expression #:nodoc:
19
- # Raises TypeError unless the left hand side is an int enum.
20
- def initialize(model, params)
21
- super
22
-
23
- unless params[:lhs].respond_to? :to_int_var_array
24
- raise TypeError, 'Must have int enum as left hand side.'
25
- end
47
+
48
+ # IntEnumConstraintReceiver contains all constraints that can be
49
+ # placed on a IntEnumOperand.
50
+ #
51
+ # Constraints are placed by calling IntEnumOperand#must (or any other
52
+ # of the variations defined in Operand), which produces a
53
+ # IntEnumConstraintReceiver from which the desired constraint can be used.
54
+ #
55
+ # Some constraint accepts a number of options. See ConstraintReceiver
56
+ # for more information.
57
+ #
58
+ # ==== Examples
59
+ #
60
+ # Constrains the integer operands in +int_enum+ to take on different
61
+ # values by using IntEnumConstraintReceiver#distinct:
62
+ #
63
+ # int_enum.must_be.distinct
64
+ #
65
+ # Constrains +int_enum2+ to have the same elements as +int_enum+, but
66
+ # sorted in ascending order. Uses IntEnumConstraintReceiver#sorted:
67
+ #
68
+ # int_enum.must_be.sorted(:as => int_enum2)
69
+ #
70
+ # The same as above, but specifying that strength :domain should be
71
+ # used and that the constraint should be reified with +bool_operand+:
72
+ #
73
+ # int_enum.must_be.sorted(:as => int_enum2, :strength => :domain, :reify => bool_operand)
74
+ #
75
+ class IntEnumConstraintReceiver < Gecode::ConstraintReceiver
76
+ # Raises TypeError unless the left hand side is an int enum
77
+ # operand.
78
+ def initialize(model, params) #:nodoc:
79
+ super
80
+
81
+ unless params[:lhs].respond_to? :to_int_enum
82
+ raise TypeError, 'Must have int enum operand as left hand side.'
26
83
  end
27
84
  end
28
85
  end