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
@@ -0,0 +1,97 @@
1
+ # A module containing constraints that have set.elements as left hand
2
+ # side.
3
+ module Gecode::SetElements #:nodoc:
4
+ # A SetElementsOperand is an uncommon operand that results from calling
5
+ # SetOperand#elements. It facilitates placing the constraints defined
6
+ # in SetElementsConstraintReceiver
7
+ #
8
+ # ==== Examples
9
+ #
10
+ # Producing a SetElementsOperand from +set_operand+:
11
+ #
12
+ # set_operand.elements
13
+ #
14
+ class SetElementsOperand
15
+ include Gecode::Operand
16
+
17
+ # Constructs a new set elements operand +set+.
18
+ def initialize(set) #:nodoc:
19
+ unless set.respond_to? :to_set_var
20
+ raise TypeError, "Expected set operand, got #{set.class}."
21
+ end
22
+
23
+ @set = set
24
+ end
25
+
26
+ # Returns the set operand that makes up the set elements operand.
27
+ def to_set_elements #:nodoc:
28
+ return @set
29
+ end
30
+
31
+ def model #:nodoc:
32
+ @set.model
33
+ end
34
+
35
+ private
36
+
37
+ def construct_receiver(params)
38
+ SetElementsConstraintReceiver.new(model, params)
39
+ end
40
+ end
41
+
42
+ # SetElementsConstraintReceiver contains all constraints that can be
43
+ # placed on a SetElementsOperand.
44
+ #
45
+ # Constraints are placed by calling SetElementsOperand#must (or any other
46
+ # of the variations defined in Operand), which produces a
47
+ # SetElementsConstraintReceiver from which the desired constraint can
48
+ # be used.
49
+ #
50
+ # Each constraint accepts a number of options. See ConstraintReceiver
51
+ # for more information.
52
+ #
53
+ # ==== Examples
54
+ #
55
+ # Constrains all elements in +set_operand+ to be strictly greater than 17
56
+ # using SetOperand#elements and SetElementsConstraintReceiver#>:
57
+ #
58
+ # set.elements.must > 17
59
+ #
60
+ # Constrains all elements in +set_operand+ to be strictly greater than
61
+ # +int_operand+ using SetOperand#elements and SetElementsConstraintReceiver#>:
62
+ #
63
+ # set.elements.must > int_operand
64
+ #
65
+ # The same as above, but specifying that strength :domain should be
66
+ # used and that the constraint should be reified with +bool_operand+:
67
+ #
68
+ # set.elements.must_be.greater_than(int_operand, :strength => :domain, :reify => bool_operand)
69
+ #
70
+ class SetElementsConstraintReceiver < Gecode::ConstraintReceiver
71
+ # Raises TypeError unless the left hand side is set elements operand.
72
+ def initialize(model, params) #:nodoc:
73
+ super
74
+
75
+ unless params[:lhs].respond_to? :to_set_elements
76
+ raise TypeError, 'Must have set elements operand as left hand side.'
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ module Gecode::Set #:nodoc:
83
+ module SetOperand
84
+ # Produces a SetElementsOperand on which relation constraints can be placed that
85
+ # constrain all elements in the set.
86
+ #
87
+ # ==== Examples
88
+ #
89
+ # # The elements of +set+.
90
+ # set.elements
91
+ def elements
92
+ Gecode::SetElements::SetElementsOperand.new(self)
93
+ end
94
+ end
95
+ end
96
+
97
+ require 'gecoder/interface/constraints/set_elements/relation.rb'
@@ -1,10 +1,21 @@
1
- module Gecode::Constraints::SetEnum
2
- class Expression
3
- # Posts a channel constraint on the variables in the enum with the specified
4
- # int enum.
1
+ module Gecode::SetEnum
2
+ class SetEnumConstraintReceiver
3
+ # Constrains this set enum to channel +int_enum_operand+. The i:th set
4
+ # in the enumeration of set operands is constrained to includes the value
5
+ # of the j:th integer operand.
6
+ #
7
+ # Neither reification nor negation is supported.
8
+ #
9
+ # ==== Examples
10
+ #
11
+ # # +set_enum+ is constrained to channel +int_enum+.
12
+ # int_enum.must.channel set_enum
13
+ #
14
+ # # This is another way of writing the above.
15
+ # set_enum.must.channel int_enum
5
16
  def channel(enum, options = {})
6
- unless enum.respond_to? :to_int_var_array
7
- raise TypeError, "Expected integer variable enum, for #{enum.class}."
17
+ unless enum.respond_to? :to_int_enum
18
+ raise TypeError, "Expected integer enum, for #{enum.class}."
8
19
  end
9
20
  if @params[:negate]
10
21
  raise Gecode::MissingConstraintError, 'A negated channel constraint ' +
@@ -15,35 +26,20 @@ module Gecode::Constraints::SetEnum
15
26
  'reification option.'
16
27
  end
17
28
 
18
- @params.update(Gecode::Constraints::Set::Util.decode_options(options))
29
+ @params.update(Gecode::Set::Util.decode_options(options))
19
30
  @params.update(:rhs => enum)
20
- @model.add_constraint Channel::IntChannelConstraint.new(@model, @params)
31
+ @model.add_constraint Channel::IntEnumChannelConstraint.new(@model, @params)
21
32
  end
22
33
  end
23
34
 
24
35
  # A module that gathers the classes and modules used in channel constraints.
25
36
  module Channel #:nodoc:
26
- # Describes a channel constraint which "channels" one enumeration of
27
- # integer variables with one enumeration of set variables. The i:th set
28
- # in the enumeration of set variables is constrainde to includes the value
29
- # of the j:th integer variable.
30
- #
31
- # Neither reification nor negation is supported.
32
- #
33
- # == Examples
34
- #
35
- # # +set_enum+ is constrained to channel +int_enum+.
36
- # int_enum.must.channel set_enum
37
- #
38
- # # This is another way of saying the above.
39
- # set_enum.must.channel int_enum
40
- #
41
- class IntChannelConstraint < Gecode::Constraints::Constraint
37
+ class IntEnumChannelConstraint < Gecode::Constraint #:nodoc:
42
38
  def post
43
39
  lhs, rhs = @params.values_at(:lhs, :rhs)
44
- Gecode::Raw::channel(@model.active_space, rhs.to_int_var_array,
45
- lhs.to_set_var_array)
40
+ Gecode::Raw::channel(@model.active_space, rhs.to_int_enum.bind_array,
41
+ lhs.to_set_enum.bind_array)
46
42
  end
47
43
  end
48
44
  end
49
- end
45
+ end
@@ -1,12 +1,21 @@
1
- module Gecode::Constraints::SetEnum
2
- class Expression
3
- # Adds a constraint on the sets that specifies that they must have at most
4
- # one element in common. The "option" :size must be specified, the sets
5
- # will be constrained to that size.
1
+ module Gecode::SetEnum
2
+ class SetEnumConstraintReceiver
3
+ # Constrains all pairs of set operands in the enumeration to at
4
+ # most have one element in common and be of a specified size.
5
+ # Providing a size is not optional.
6
+ #
7
+ # Neither negation nor reification is supported.
8
+ #
9
+ # ==== Examples
10
+ #
11
+ # # All set operands in +sets+ must have cardinality 17 and no pair may
12
+ # # have more than one element in common.
13
+ # sets.must.at_most_share_one_element(:size => 17)
6
14
  def at_most_share_one_element(options = {})
7
15
  unless options.has_key? :size
8
16
  raise ArgumentError, 'Option :size has to be specified.'
9
17
  end
18
+ # TODO can we use Set::Util::decode_options here instead?
10
19
  unless options.size == 1
11
20
  raise ArgumentError, 'Only the option :size is accepted, got ' +
12
21
  "#{options.keys.join(', ')}."
@@ -23,22 +32,12 @@ module Gecode::Constraints::SetEnum
23
32
 
24
33
  # A module that gathers the classes and modules used in distinct constraints.
25
34
  module Distinct #:nodoc:
26
- # Describes an at most one constraint, which constrains all pairs of set
27
- # variables in the enumeration to at most have one element in common and be
28
- # of a specified size. Providing a size is not optional.
29
- #
30
- # Neither negation nor reification is supported.
31
- #
32
- # == Examples
33
- #
34
- # # All set variables in +sets+ must have cardinality 17 and no pair may
35
- # # have more than one element in common.
36
- # sets.must.at_most_share_one_element(:size => 17)
37
- class AtMostOneConstraint < Gecode::Constraints::Constraint
35
+ class AtMostOneConstraint < Gecode::Constraint #:nodoc:
38
36
  def post
39
37
  sets, size = @params.values_at(:lhs, :size)
40
- Gecode::Raw::atmostOne(@model.active_space, sets.to_set_var_array, size)
38
+ Gecode::Raw::atmostOne(@model.active_space,
39
+ sets.to_set_enum.bind_array, size)
41
40
  end
42
41
  end
43
42
  end
44
- end
43
+ end
@@ -1,60 +1,69 @@
1
- module Gecode::SetEnumMethods
2
- Gecode::Constraints::Util::SET_OPERATION_TYPES.each_pair do |name, type|
3
- next if type == Gecode::Raw::SOT_MINUS # Does not support this constraint?
1
+ module Gecode::SetEnum
2
+ module SetEnumOperand
3
+ # Produces a SetOperand representing the union of all sets in this
4
+ # enumeration.
5
+ #
6
+ # ==== Examples
7
+ #
8
+ # # The union of all sets in +set_enum+.
9
+ # set_enum.union
10
+ def union
11
+ set_operation(:union)
12
+ end
4
13
 
5
- module_eval <<-"end_code"
6
- # Starts a constraint on the #{name} of the sets.
7
- def #{name}
8
- params = {:lhs => self, :operation => #{type}}
9
- Gecode::Constraints::SetEnum::Operation::ExpressionStub.new(
10
- @model, params)
11
- end
12
- end_code
14
+ # Produces a SetOperand representing the intersection of all sets in this
15
+ # enumeration.
16
+ #
17
+ # ==== Examples
18
+ #
19
+ # # The intersection of all sets in +set_enum+.
20
+ # set_enum.intersection
21
+ def intersection
22
+ set_operation(:intersection)
23
+ end
24
+
25
+ # Produces a SetOperand representing the disjoint union of all sets
26
+ # in this enumeration.
27
+ #
28
+ # ==== Examples
29
+ #
30
+ # # The disjoint union of all sets in +set_enum+.
31
+ # set_enum.disjoint_union
32
+ def disjoint_union
33
+ set_operation(:disjoint_union)
34
+ end
35
+
36
+ private
37
+
38
+ # Produces the SetOperand resulting from +operator+ applied to this
39
+ # operand.
40
+ def set_operation(operator)
41
+ Operation::OperationSetOperand.new(model, self, operator)
42
+ end
13
43
  end
14
- end
15
44
 
16
- # A module that gathers the classes and modules used by operation constaints.
17
- module Gecode::Constraints::SetEnum::Operation #:nodoc:
18
- # Describes a CompositeStub for the enumeration operation constraint, which
19
- # constrains the result of applying an operation between all set variables in
20
- # a set enumeration.
21
- #
22
- # The supported operations are:
23
- # * union
24
- # * disjoint_union
25
- # * intersection
26
- # * minus
27
- #
28
- # == Example
29
- #
30
- # # The union of all set variables in +sets+ must be subset of 1..17.
31
- # sets.union.must_be.subset_of 1..17
32
- #
33
- # # The intersection of all set variables must equal [1,3,5].
34
- # sets.intersection.must == [1,3,5]
35
- #
36
- # # The union of all set variable must be a subset of the set variable
37
- # # +universe+.
38
- # sets.union.must_be.subset_of universe
39
- #
40
- # # The same as above, but reified with the boolean variable
41
- # # +is_within_universe+.
42
- # sets.union.must_be.subset_of(universe, :reify => is_within_universe)
43
- class ExpressionStub < Gecode::Constraints::Set::CompositeStub
44
- def constrain_equal(variable, params, constrain)
45
- enum, operation = @params.values_at(:lhs, :operation)
46
-
47
- if constrain
48
- if operation == Gecode::Raw::SOT_INTER or
49
- operation == Gecode::Raw::SOT_MINUS
50
- variable.must_be.subset_of enum.first.upper_bound
51
- else
52
- variable.must_be.subset_of enum.upper_bound_range
45
+ # A module that gathers the classes and modules used in operation constraints.
46
+ module Operation #:nodoc:
47
+ class OperationSetOperand < Gecode::Set::ShortCircuitEqualityOperand #:nodoc:
48
+ def initialize(model, enum, operator)
49
+ super model
50
+ @enum = enum
51
+ @operator = operator
52
+ end
53
+
54
+ def constrain_equal(set_operand, constrain_domain, propagation_options)
55
+ operation = Gecode::Util::SET_OPERATION_TYPES[@operator]
56
+ if constrain_domain
57
+ if operation == Gecode::Raw::SOT_INTER
58
+ set_operand.must_be.subset_of @enum.first.upper_bound
59
+ else
60
+ set_operand.must_be.subset_of @enum.upper_bound_range
61
+ end
53
62
  end
63
+
64
+ Gecode::Raw::rel(@model.active_space, operation,
65
+ @enum.to_set_enum.bind_array, set_operand.to_set_var.bind)
54
66
  end
55
-
56
- Gecode::Raw::rel(@model.active_space, operation, enum.to_set_var_array,
57
- variable.bind)
58
67
  end
59
68
  end
60
- end
69
+ end
@@ -0,0 +1,79 @@
1
+ module Gecode::SetEnum
2
+ module SetEnumOperand
3
+ # This adds the adder for the methods in the modules including it. The
4
+ # reason for doing it so indirect is that the first #[] won't be defined
5
+ # before the module that this is mixed into is mixed into an enum.
6
+ def self.included(mod) #:nodoc:
7
+ mod.module_eval do
8
+ # Now we enter the module SetEnumOperands is mixed into.
9
+ class << self
10
+ alias_method :pre_selection_included, :included
11
+ def included(mod) #:nodoc:
12
+ mod.module_eval do
13
+ # Now we enter the module that the module possibly defining #[]
14
+ # is mixed into.
15
+ if instance_methods.include?('[]') and
16
+ not instance_methods.include?('pre_selection_access')
17
+ alias_method :pre_selection_access, :[]
18
+ end
19
+
20
+ # Produces a SetOperand representing the i:th set
21
+ # operand in the enumeration, where i is the value of the
22
+ # int operand used as index.
23
+ #
24
+ # A set can also be used as index, in which case a
25
+ # SelectedSetOperand is produced.
26
+ #
27
+ # ==== Examples
28
+ #
29
+ # # The set operand at the +x+:th position in +set_enum+,
30
+ # # where +x+ is a int operand.
31
+ # set_enum[x]
32
+ #
33
+ # # The SelectedSetOperand representing sets at positions
34
+ # # included in the value of +set+ in +set_enum+,
35
+ # set_enum[set]
36
+ #
37
+ def [](*vars)
38
+ # Hook in an element constraint if a operand is used for array
39
+ # access.
40
+ if vars.first.respond_to? :to_int_var
41
+ Select::SelectSetOperand.new(
42
+ model, self, vars.first)
43
+ elsif vars.first.respond_to? :to_set_var
44
+ Gecode::SelectedSet::SelectedSetOperand.new(
45
+ self, vars.first)
46
+ else
47
+ if respond_to? :pre_selection_access
48
+ pre_selection_access(*vars)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ pre_selection_included(mod)
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ module Select #:nodoc:
61
+ class SelectSetOperand < Gecode::Set::ShortCircuitEqualityOperand #:nodoc:
62
+ def initialize(model, enum_op, position_int_op)
63
+ super model
64
+ @enum = enum_op
65
+ @position = position_int_op
66
+ end
67
+
68
+ def constrain_equal(set_operand, constrain, propagation_options)
69
+ enum = @enum.to_set_enum
70
+ if constrain
71
+ set_operand.must_be.subset_of enum.upper_bound_range
72
+ end
73
+
74
+ Gecode::Raw::selectSet(@model.active_space, enum.bind_array,
75
+ @position.to_int_var.bind, set_operand.to_set_var.bind)
76
+ end
77
+ end
78
+ end
79
+ end
@@ -1,28 +1,78 @@
1
- module Gecode
2
- module SetEnumMethods
3
- include Gecode::Constraints::LeftHandSideMethods
4
-
1
+ # A module containing constraints that have enumerations of set operands as
2
+ # left hand side.
3
+ module Gecode::SetEnum #:nodoc:
4
+ # A SetEnumOperand is a enumeration of SetOperand on which the
5
+ # constraints defined in SetEnumConstraintReceiver can be placed.
6
+ #
7
+ # Enumerations of set operands can be created either by using
8
+ # Gecode::Model#set_var_array and Gecode::Model#set_var_matrix, or
9
+ # by wrapping an existing enumeration containing SetOperand using
10
+ # Gecode::Model#wrap_enum. The enumerations, no matter how they were
11
+ # created, all respond to the properties defined by SetEnumOperand.
12
+ #
13
+ # ==== Examples
14
+ #
15
+ # Produces an array of five set operands, with greatest lower bound
16
+ # {0} and least upper bound {0, 1, 2}, inside a problem formulation
17
+ # using Gecode::Model#set_var_array:
18
+ #
19
+ # set_enum = set_var_array(5, 0, 1..2)
20
+ #
21
+ # Uses Gecode::Model#wrap_enum inside a problem formulation to create
22
+ # a SetEnumOperand from an existing enumeration containing the
23
+ # set operands +set_operand1+ and +set_operand2+:
24
+ #
25
+ # set_enum = wrap_enum([set_operand1, set_operand2])
26
+ #
27
+ #--
28
+ # Classes that mix in SetEnumOperand must define #model and
29
+ # #to_set_enum .
30
+ module SetEnumOperand
31
+ include Gecode::Operand
32
+
33
+ def method_missing(method, *args) #:nodoc:
34
+ if Gecode::SetEnum::Dummy.instance_methods.include? method.to_s
35
+ # Delegate to the set enum.
36
+ to_set_enum.method(method).call(*args)
37
+ else
38
+ super
39
+ end
40
+ end
41
+
5
42
  private
6
-
7
- # Produces an expression for the lhs module.
8
- def expression(params)
9
- params.update(:lhs => self)
10
- Constraints::SetEnum::Expression.new(@model, params)
43
+
44
+ def construct_receiver(params)
45
+ Gecode::SetEnum::SetEnumConstraintReceiver.new(@model, params)
11
46
  end
12
47
  end
13
-
14
- # A module containing constraints that have enumerations of set variables as
15
- # left hand side.
16
- module Constraints::SetEnum
17
- # Expressions with set enums as left hand sides.
18
- class Expression < Gecode::Constraints::Expression
19
- # Raises TypeError unless the left hand side is a set enum.
20
- def initialize(model, params)
21
- super
22
-
23
- unless params[:lhs].respond_to? :to_set_var_array
24
- raise TypeError, 'Must have set enum as left hand side.'
25
- end
48
+
49
+ # SetEnumConstraintReceiver contains all constraints that can be
50
+ # placed on a SetEnumOperand.
51
+ #
52
+ # Constraints are placed by calling SetEnumOperand#must (or any other
53
+ # of the variations defined in Operand), which produces a
54
+ # SetEnumConstraintReceiver from which the desired constraint can be used.
55
+ #
56
+ # ==== Examples
57
+ #
58
+ # Constrains +set_enum+ to channel +int_enum+ by using
59
+ # SetEnumConstraintReceiver#channel:
60
+ #
61
+ # set_enum.must.channel set_enum
62
+ #
63
+ # Constrains each pair of set operands in +set_enum+ to at most share
64
+ # one element. Also constrains each set to have size 17. Uses
65
+ # SetEnumConstraintReceiver#at_most_share_one_element.
66
+ #
67
+ # set_enum.must.at_most_share_one_element(:size => 17)
68
+ #
69
+ class SetEnumConstraintReceiver < Gecode::ConstraintReceiver
70
+ # Raises TypeError unless the left hand side is a set enum operand.
71
+ def initialize(model, params) #:nodoc:
72
+ super
73
+
74
+ unless params[:lhs].respond_to? :to_set_enum
75
+ raise TypeError, 'Must have set enum operand as left hand side.'
26
76
  end
27
77
  end
28
78
  end
@@ -30,5 +80,5 @@ end
30
80
 
31
81
  require 'gecoder/interface/constraints/set_enum/channel'
32
82
  require 'gecoder/interface/constraints/set_enum/distinct'
33
- require 'gecoder/interface/constraints/set_enum/selection'
83
+ require 'gecoder/interface/constraints/set_enum/select'
34
84
  require 'gecoder/interface/constraints/set_enum/operation'