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.
- data/CHANGES +15 -0
- data/README +6 -2
- data/example/equation_system.rb +15 -0
- data/example/magic_sequence.rb +7 -7
- data/example/money.rb +36 -0
- data/example/queens.rb +7 -8
- data/example/send_most_money.rb +1 -1
- data/example/square_tiling.rb +2 -2
- data/example/sudoku-set.rb +11 -12
- data/example/sudoku.rb +40 -45
- data/ext/extconf.rb +0 -0
- data/ext/gecode-2.1.1/LICENSE +0 -0
- data/ext/gecode-2.1.1/configure +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/SDFVariableHeuristic.cc +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/SDFVariableHeuristic.hh +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/configure +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/extensivecomparator.cc +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/extensivecomparator.hh +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/heap.cc +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/implicative.cc +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/implicative.hh +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/myspace.cc +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/myspace.hh +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/qecore.cc +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/qecore.hh +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/warner.cc +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/warner.hh +0 -0
- data/ext/gecode-2.1.1/gecode/cpltset/var-imp/cpltset.vis +0 -0
- data/ext/gecode-2.1.1/gecode/int/arithmetic/abs.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/arithmetic/max.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/arithmetic/mult.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/arithmetic/sqr.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/arithmetic/sqrt.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/array.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/array.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/bool/base.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/bool/eq.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/bool/eqv.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/bool/lq.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/bool/or.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/branch/select-val.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/branch/select-view.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/branch.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/branch.hh +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel/base.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel/dom.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel/link-multi.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel/link-multi.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel/link-single.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel/link-single.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel/val.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel.hh +0 -0
- data/ext/gecode-2.1.1/gecode/int/circuit/base.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/circuit/dom.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/circuit/val.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/circuit.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/circuit.hh +0 -0
- data/ext/gecode-2.1.1/gecode/int/count/int.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/count/rel.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/count/view.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/distinct/bilink.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/distinct/bnd.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/distinct/combptr.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/distinct/dom.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/distinct/edge.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/distinct/node.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/distinct/ter-dom.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/distinct/val.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/dom/range.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/dom/spec.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/dom.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/dom.hh +0 -0
- data/ext/gecode-2.1.1/gecode/int/element/int.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/element/view.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/element.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/element.hh +0 -0
- data/ext/gecode-2.1.1/gecode/int/exception.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/extensional/dfa.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/extensional/dfa.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/extensional/layered-graph.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/gcc/dom.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/gcc/gccbndsup.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/gcc/lbc.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/gcc/ubc.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/gcc.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/gcc.hh +0 -0
- data/ext/gecode-2.1.1/gecode/int/int-set.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/int-set.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/bool-int.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/bool-post.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/bool-scale.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/bool-view.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/int-bin.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/int-dom.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/int-nary.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/int-post.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/int-ter.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/post.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/propagator.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/rel/eq.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/rel/lex.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/rel/lq-le.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/rel/nq.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/unshare.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/var/bool.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/var-imp/bool.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/var-imp/bool.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/var-imp/bool.vis +0 -0
- data/ext/gecode-2.1.1/gecode/int/var-imp/delta.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/var-imp/int.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/var-imp/int.vis +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/bool.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/constint.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/int.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/iter.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/minus.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/offset.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/print.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/rtest.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/scale.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/zero.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-add.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-append.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-array.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-cache.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-compl.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-diff.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-empty.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-inter.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-minmax.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-minus.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-offset.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-operations.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-scale.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-singleton-append.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-singleton.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-union.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-values.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/values-array.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/values-minus.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/values-offset.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/values-ranges.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/values-singleton.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/values-unique.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter.hh +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/advisor.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/array.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/branching.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/exception.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/macros.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/memory-manager.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/modevent.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/propagator.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/shared-array.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/var-traits.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/var.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/view.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel.hh +0 -0
- data/ext/gecode-2.1.1/gecode/minimodel/arithmetic.cc +0 -0
- data/ext/gecode-2.1.1/gecode/minimodel/bool-expr.cc +0 -0
- data/ext/gecode-2.1.1/gecode/minimodel/bool-expr.icc +0 -0
- data/ext/gecode-2.1.1/gecode/minimodel/bool-rel.icc +0 -0
- data/ext/gecode-2.1.1/gecode/minimodel/lin-expr.icc +0 -0
- data/ext/gecode-2.1.1/gecode/minimodel/lin-rel.icc +0 -0
- data/ext/gecode-2.1.1/gecode/minimodel/reg.cc +0 -0
- data/ext/gecode-2.1.1/gecode/minimodel.hh +0 -0
- data/ext/gecode-2.1.1/gecode/search/bab.cc +0 -0
- data/ext/gecode-2.1.1/gecode/search/bab.icc +0 -0
- data/ext/gecode-2.1.1/gecode/search/dfs.cc +0 -0
- data/ext/gecode-2.1.1/gecode/search/dfs.icc +0 -0
- data/ext/gecode-2.1.1/gecode/search/engine-ctrl.icc +0 -0
- data/ext/gecode-2.1.1/gecode/search/lds.cc +0 -0
- data/ext/gecode-2.1.1/gecode/search/lds.icc +0 -0
- data/ext/gecode-2.1.1/gecode/search/options.cc +0 -0
- data/ext/gecode-2.1.1/gecode/search/options.icc +0 -0
- data/ext/gecode-2.1.1/gecode/search/reco-stack.icc +0 -0
- data/ext/gecode-2.1.1/gecode/search/restart.icc +0 -0
- data/ext/gecode-2.1.1/gecode/search/statistics.icc +0 -0
- data/ext/gecode-2.1.1/gecode/search/stop.cc +0 -0
- data/ext/gecode-2.1.1/gecode/search/stop.icc +0 -0
- data/ext/gecode-2.1.1/gecode/set/var-imp/set.vis +0 -0
- data/ext/gecode-2.1.1/gecode/support/block-allocator.icc +0 -0
- data/ext/gecode-2.1.1/gecode/support/cast.icc +0 -0
- data/ext/gecode-2.1.1/gecode/support/exception.cc +0 -0
- data/ext/gecode-2.1.1/gecode/support/exception.icc +0 -0
- data/ext/gecode-2.1.1/gecode/support/macros.icc +0 -0
- data/ext/gecode-2.1.1/gecode/support/marked-pointer.icc +0 -0
- data/ext/gecode-2.1.1/gecode/support/memory.icc +0 -0
- data/ext/gecode-2.1.1/gecode/support/sentinel-stack.icc +0 -0
- data/ext/gecode-2.1.1/gecode/support/static-stack.icc +0 -0
- data/ext/gecode-2.1.1/gecode/support/symbol.cc +0 -0
- data/ext/gecode-2.1.1/gecode/support.hh +0 -0
- data/ext/gecode-2.1.1/install-sh +0 -0
- data/ext/gecode-2.1.1/misc/debian/rules +0 -0
- data/ext/gecode-2.1.1/misc/doxygen/back.png +0 -0
- data/ext/gecode-2.1.1/misc/doxygen/gecode-logo-100.png +0 -0
- data/ext/gecode-2.1.1/misc/genchangelog.perl +0 -0
- data/ext/gecode-2.1.1/misc/genlicense.perl +0 -0
- data/ext/gecode-2.1.1/misc/genstatistics.perl +0 -0
- data/ext/gecode-2.1.1/misc/genvariables.perl +0 -0
- data/ext/gecode-2.1.1/misc/getrevision.perl +0 -0
- data/ext/gecode-2.1.1/misc/makedepend.perl +0 -0
- data/ext/gecode-2.1.1/misc/svn-ignore.txt +0 -0
- data/ext/gecode-2.1.1/variables.vsl +0 -0
- data/lib/gecoder/bindings/bindings.rb +16 -0
- data/lib/gecoder/bindings.rb +42 -0
- data/lib/gecoder/interface/branch.rb +16 -9
- data/lib/gecoder/interface/constraints/bool/boolean.rb +205 -213
- data/lib/gecoder/interface/constraints/bool/channel.rb +4 -5
- data/lib/gecoder/interface/constraints/bool/linear.rb +192 -21
- data/lib/gecoder/interface/constraints/bool_enum/channel.rb +43 -39
- data/lib/gecoder/interface/constraints/bool_enum/extensional.rb +43 -49
- data/lib/gecoder/interface/constraints/bool_enum/relation.rb +38 -71
- data/lib/gecoder/interface/constraints/bool_enum_constraints.rb +73 -22
- data/lib/gecoder/interface/constraints/bool_var_constraints.rb +140 -61
- data/lib/gecoder/interface/constraints/extensional_regexp.rb +4 -4
- data/lib/gecoder/interface/constraints/fixnum_enum/element.rb +63 -0
- data/lib/gecoder/interface/constraints/fixnum_enum/operation.rb +65 -0
- data/lib/gecoder/interface/constraints/fixnum_enum_constraints.rb +42 -0
- data/lib/gecoder/interface/constraints/int/arithmetic.rb +131 -130
- data/lib/gecoder/interface/constraints/int/channel.rb +21 -31
- data/lib/gecoder/interface/constraints/int/domain.rb +45 -42
- data/lib/gecoder/interface/constraints/int/linear.rb +85 -239
- data/lib/gecoder/interface/constraints/int/relation.rb +141 -0
- data/lib/gecoder/interface/constraints/int_enum/arithmetic.rb +55 -64
- data/lib/gecoder/interface/constraints/int_enum/channel.rb +35 -37
- data/lib/gecoder/interface/constraints/int_enum/count.rb +53 -78
- data/lib/gecoder/interface/constraints/int_enum/distinct.rb +36 -46
- data/lib/gecoder/interface/constraints/int_enum/element.rb +39 -57
- data/lib/gecoder/interface/constraints/int_enum/equality.rb +15 -19
- data/lib/gecoder/interface/constraints/int_enum/extensional.rb +65 -72
- data/lib/gecoder/interface/constraints/int_enum/sort.rb +42 -45
- data/lib/gecoder/interface/constraints/int_enum_constraints.rb +79 -22
- data/lib/gecoder/interface/constraints/int_var_constraints.rb +215 -44
- data/lib/gecoder/interface/constraints/reifiable_constraints.rb +14 -14
- data/lib/gecoder/interface/constraints/selected_set/select.rb +120 -0
- data/lib/gecoder/interface/constraints/selected_set_constraints.rb +75 -0
- data/lib/gecoder/interface/constraints/set/cardinality.rb +43 -53
- data/lib/gecoder/interface/constraints/set/channel.rb +26 -29
- data/lib/gecoder/interface/constraints/set/connection.rb +89 -152
- data/lib/gecoder/interface/constraints/set/domain.rb +112 -65
- data/lib/gecoder/interface/constraints/set/include.rb +36 -0
- data/lib/gecoder/interface/constraints/set/operation.rb +96 -110
- data/lib/gecoder/interface/constraints/set/relation.rb +114 -137
- data/lib/gecoder/interface/constraints/set_elements/relation.rb +116 -0
- data/lib/gecoder/interface/constraints/set_elements_constraints.rb +97 -0
- data/lib/gecoder/interface/constraints/set_enum/channel.rb +23 -27
- data/lib/gecoder/interface/constraints/set_enum/distinct.rb +18 -19
- data/lib/gecoder/interface/constraints/set_enum/operation.rb +62 -53
- data/lib/gecoder/interface/constraints/set_enum/select.rb +79 -0
- data/lib/gecoder/interface/constraints/set_enum_constraints.rb +73 -23
- data/lib/gecoder/interface/constraints/set_var_constraints.rb +222 -57
- data/lib/gecoder/interface/constraints.rb +410 -451
- data/lib/gecoder/interface/enum_matrix.rb +4 -4
- data/lib/gecoder/interface/enum_wrapper.rb +71 -22
- data/lib/gecoder/interface/model.rb +167 -12
- data/lib/gecoder/interface/model_sugar.rb +84 -0
- data/lib/gecoder/interface/search.rb +30 -18
- data/lib/gecoder/interface/variables.rb +103 -33
- data/lib/gecoder/interface.rb +2 -1
- data/lib/gecoder/version.rb +2 -2
- data/specs/bool_var.rb +19 -12
- data/specs/constraints/{boolean.rb → bool/boolean.rb} +103 -28
- data/specs/constraints/bool/boolean_properties.rb +51 -0
- data/specs/constraints/bool/linear.rb +213 -0
- data/specs/constraints/bool_enum/bool_enum_relation.rb +117 -0
- data/specs/constraints/bool_enum/channel.rb +102 -0
- data/specs/constraints/{extensional.rb → bool_enum/extensional.rb} +32 -101
- data/specs/constraints/constraint_helper.rb +149 -179
- data/specs/constraints/constraint_receivers.rb +103 -0
- data/specs/constraints/constraints.rb +6 -63
- data/specs/constraints/fixnum_enum/element.rb +58 -0
- data/specs/constraints/fixnum_enum/operation.rb +67 -0
- data/specs/constraints/int/arithmetic.rb +149 -0
- data/specs/constraints/int/channel.rb +101 -0
- data/specs/constraints/int/domain.rb +106 -0
- data/specs/constraints/int/linear.rb +183 -0
- data/specs/constraints/int/linear_properties.rb +97 -0
- data/specs/constraints/int/relation.rb +84 -0
- data/specs/constraints/int_enum/arithmetic.rb +72 -0
- data/specs/constraints/int_enum/channel.rb +57 -0
- data/specs/constraints/int_enum/count.rb +72 -0
- data/specs/constraints/int_enum/distinct.rb +80 -0
- data/specs/constraints/int_enum/element.rb +61 -0
- data/specs/constraints/int_enum/equality.rb +29 -0
- data/specs/constraints/int_enum/extensional.rb +224 -0
- data/specs/constraints/int_enum/sort.rb +167 -0
- data/specs/constraints/operands.rb +264 -0
- data/specs/constraints/property_helper.rb +443 -0
- data/specs/constraints/reification_sugar.rb +4 -5
- data/specs/constraints/selected_set/select.rb +56 -0
- data/specs/constraints/selected_set/select_properties.rb +157 -0
- data/specs/constraints/set/cardinality.rb +58 -0
- data/specs/constraints/set/cardinality_properties.rb +46 -0
- data/specs/constraints/set/channel.rb +77 -0
- data/specs/constraints/set/connection.rb +176 -0
- data/specs/constraints/set/domain.rb +197 -0
- data/specs/constraints/set/include.rb +36 -0
- data/specs/constraints/set/operation.rb +132 -0
- data/specs/constraints/set/relation.rb +117 -0
- data/specs/constraints/set_elements/relation.rb +84 -0
- data/specs/constraints/set_enum/channel.rb +80 -0
- data/specs/constraints/set_enum/distinct.rb +59 -0
- data/specs/constraints/set_enum/operation.rb +111 -0
- data/specs/constraints/set_enum/select.rb +73 -0
- data/specs/enum_wrapper.rb +53 -3
- data/specs/int_var.rb +44 -25
- data/specs/model.rb +58 -1
- data/specs/model_sugar.rb +30 -0
- data/specs/search.rb +24 -5
- data/specs/selected_set.rb +39 -0
- data/specs/set_elements.rb +34 -0
- data/specs/set_var.rb +22 -8
- data/specs/spec_helper.rb +206 -6
- data/tasks/distribution.rake +22 -7
- data/tasks/svn.rake +3 -1
- metadata +219 -135
- data/lib/gecoder/interface/constraints/set_enum/selection.rb +0 -217
- data/specs/constraints/arithmetic.rb +0 -351
- data/specs/constraints/bool_enum_relation.rb +0 -160
- data/specs/constraints/cardinality.rb +0 -157
- data/specs/constraints/channel.rb +0 -454
- data/specs/constraints/connection.rb +0 -369
- data/specs/constraints/count.rb +0 -146
- data/specs/constraints/distinct.rb +0 -164
- data/specs/constraints/element.rb +0 -108
- data/specs/constraints/equality.rb +0 -31
- data/specs/constraints/int_domain.rb +0 -70
- data/specs/constraints/int_relation.rb +0 -82
- data/specs/constraints/linear.rb +0 -340
- data/specs/constraints/selection.rb +0 -292
- data/specs/constraints/set_domain.rb +0 -185
- data/specs/constraints/set_operation.rb +0 -285
- data/specs/constraints/set_relation.rb +0 -197
- data/specs/constraints/sort.rb +0 -179
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../constraint_helper'
|
2
|
+
|
3
|
+
describe Gecode::Set::Cardinality, ' (constraint)' do
|
4
|
+
before do
|
5
|
+
@model = Gecode::Model.new
|
6
|
+
@set = @model.set_var([], 0..10)
|
7
|
+
@model.branch_on @model.wrap_enum([@set])
|
8
|
+
@range = 1..2
|
9
|
+
@three_dot_range = 1...2
|
10
|
+
|
11
|
+
@invoke = lambda do |rhs|
|
12
|
+
@set.size.must_be.in(rhs)
|
13
|
+
@model.solve!
|
14
|
+
end
|
15
|
+
@expect = lambda do |rhs|
|
16
|
+
@model.allow_space_access do
|
17
|
+
Gecode::Raw.should_receive(:cardinality).once.with(
|
18
|
+
an_instance_of(Gecode::Raw::Space),
|
19
|
+
an_instance_of(Gecode::Raw::SetVar), rhs.first, rhs.last)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should translate cardinality constraints with ranges' do
|
25
|
+
@expect.call(@range)
|
26
|
+
@invoke.call(@range)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should translate cardinality constraints with three dot range domains' do
|
30
|
+
@expect.call(@three_dot_range)
|
31
|
+
@invoke.call(@three_dot_range)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should constrain the cardinality of a set' do
|
35
|
+
@set.size.must_be.in @range
|
36
|
+
@model.solve!
|
37
|
+
@range.should include(@set.value.size)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should raise error if the right hand side is not a range' do
|
41
|
+
lambda{ @set.size.must_be.in 'hello' }.should raise_error(TypeError)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should not shadow the integer variable domain constrain' do
|
45
|
+
Gecode::Raw.should_receive(:dom).with(
|
46
|
+
an_instance_of(Gecode::Raw::Space),
|
47
|
+
an_instance_of(Gecode::Raw::IntVar), 0, 11, Gecode::Raw::ICL_DEF,
|
48
|
+
Gecode::Raw::PK_DEF)
|
49
|
+
Gecode::Raw.should_receive(:dom).with(
|
50
|
+
an_instance_of(Gecode::Raw::Space),
|
51
|
+
an_instance_of(Gecode::Raw::IntVar), an_instance_of(Gecode::Raw::IntSet),
|
52
|
+
an_instance_of(Gecode::Raw::BoolVar), Gecode::Raw::ICL_DEF,
|
53
|
+
Gecode::Raw::PK_DEF)
|
54
|
+
@set.size.must_not_be.in [1,3]
|
55
|
+
@model.solve!
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../property_helper'
|
2
|
+
|
3
|
+
describe Gecode::Set::Cardinality, ' (property)' do
|
4
|
+
before do
|
5
|
+
@model = Gecode::Model.new
|
6
|
+
@set = @model.set_var([], 0..10)
|
7
|
+
@var = @model.int_var(0..11)
|
8
|
+
@model.branch_on @set
|
9
|
+
@model.branch_on @var
|
10
|
+
|
11
|
+
@property_types = [:set]
|
12
|
+
@select_property = lambda do |set|
|
13
|
+
set.size
|
14
|
+
end
|
15
|
+
@selected_property = @set.size
|
16
|
+
@constraint_class = Gecode::BlockConstraint
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should constrain the cardinality of a set' do
|
20
|
+
@set.size.must == @var
|
21
|
+
@model.solve!
|
22
|
+
@set.value.size.should == @var.value
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should constrain the cardinality of a set (2)' do
|
26
|
+
@set.size.must == 2
|
27
|
+
@model.solve!.should_not be_nil
|
28
|
+
@set.value.size.should == 2
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should constrain the cardinality of a set (3)' do
|
32
|
+
@set.size.must == @var
|
33
|
+
@var.must == 2
|
34
|
+
@model.solve!
|
35
|
+
@set.value.size.should == 2
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should translate into a cardinality constraint' do
|
39
|
+
Gecode::Raw.should_receive(:cardinality)
|
40
|
+
@set.size.must == @var
|
41
|
+
@model.solve!
|
42
|
+
end
|
43
|
+
|
44
|
+
it_should_behave_like(
|
45
|
+
'property that produces int operand by short circuiting equality')
|
46
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../constraint_helper'
|
2
|
+
|
3
|
+
class SetChannelSampleProblem < Gecode::Model
|
4
|
+
attr :bool_enum
|
5
|
+
attr :set
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@bool_enum = bool_var_array(4)
|
9
|
+
@set = set_var([], 0..3)
|
10
|
+
|
11
|
+
branch_on @bool_enum
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe Gecode::Set::Channel, ' (set variable as lhs with bool enum)' do
|
16
|
+
before do
|
17
|
+
@model = SetChannelSampleProblem.new
|
18
|
+
@bools = @model.bool_enum
|
19
|
+
@set = @model.set
|
20
|
+
|
21
|
+
@types = [:set, :bool_enum]
|
22
|
+
@invoke = lambda do |receiver, bool_enum, hash|
|
23
|
+
receiver.channel(bool_enum, hash)
|
24
|
+
@model.solve!
|
25
|
+
end
|
26
|
+
@expect = lambda do |var1, var2, opts, reif_var|
|
27
|
+
Gecode::Raw.should_receive(:channel).once.with(
|
28
|
+
an_instance_of(Gecode::Raw::Space),
|
29
|
+
var1, var2)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should channel the bool enum with the set variable' do
|
34
|
+
@set.must_be.superset_of [0, 2]
|
35
|
+
@set.must.channel @bools
|
36
|
+
@model.solve!.should_not be_nil
|
37
|
+
set_values = @set.value
|
38
|
+
@bools.values.each_with_index do |bool, index|
|
39
|
+
bool.should == set_values.include?(index)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it_should_behave_like 'non-reifiable set constraint'
|
44
|
+
it_should_behave_like 'non-negatable constraint'
|
45
|
+
end
|
46
|
+
|
47
|
+
describe Gecode::Set::Channel, ' (bool enum as lhs with set variable)' do
|
48
|
+
before do
|
49
|
+
@model = SetChannelSampleProblem.new
|
50
|
+
@bools = @model.bool_enum
|
51
|
+
@set = @model.set
|
52
|
+
|
53
|
+
@types = [:bool_enum, :set]
|
54
|
+
@invoke = lambda do |receiver, set, hash|
|
55
|
+
receiver.channel(set, hash)
|
56
|
+
@model.solve!
|
57
|
+
end
|
58
|
+
@expect = lambda do |var1, var2, opts, reif_var|
|
59
|
+
Gecode::Raw.should_receive(:channel).once.with(
|
60
|
+
an_instance_of(Gecode::Raw::Space),
|
61
|
+
var1, var2)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should channel the bool enum with the set variable' do
|
66
|
+
@set.must_be.superset_of [0, 2]
|
67
|
+
@bools.must.channel @set
|
68
|
+
@model.solve!.should_not be_nil
|
69
|
+
set_values = @set.value
|
70
|
+
@bools.values.each_with_index do |bool, index|
|
71
|
+
bool.should == set_values.include?(index)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it_should_behave_like 'non-reifiable set constraint'
|
76
|
+
it_should_behave_like 'non-negatable constraint'
|
77
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../property_helper'
|
2
|
+
|
3
|
+
describe Gecode::Set::Connection, ' (min)' do
|
4
|
+
before do
|
5
|
+
@model = Gecode::Model.new
|
6
|
+
@set = @model.set_var([], 0..9)
|
7
|
+
@var = @model.int_var(0..10)
|
8
|
+
@model.branch_on @model.wrap_enum([@set])
|
9
|
+
|
10
|
+
@property_types = [:set]
|
11
|
+
@select_property = lambda do |set|
|
12
|
+
set.min
|
13
|
+
end
|
14
|
+
@selected_property = @set.min
|
15
|
+
@constraint_class = Gecode::BlockConstraint
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should constrain the min of a set' do
|
19
|
+
@set.min.must == 3
|
20
|
+
@model.solve!
|
21
|
+
@set.lower_bound.min.should == 3
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should translate into a min constraint' do
|
25
|
+
Gecode::Raw.should_receive(:min)
|
26
|
+
@set.min.must == 5
|
27
|
+
@model.solve!
|
28
|
+
end
|
29
|
+
|
30
|
+
it_should_behave_like(
|
31
|
+
'property that produces int operand by short circuiting equality')
|
32
|
+
end
|
33
|
+
|
34
|
+
describe Gecode::Set::Connection, ' (max)' do
|
35
|
+
before do
|
36
|
+
@model = Gecode::Model.new
|
37
|
+
@set = @model.set_var([], 0..9)
|
38
|
+
@var = @model.int_var(0..10)
|
39
|
+
@model.branch_on @model.wrap_enum([@set])
|
40
|
+
|
41
|
+
@property_types = [:set]
|
42
|
+
@select_property = lambda do |set|
|
43
|
+
set.max
|
44
|
+
end
|
45
|
+
@selected_property = @set.max
|
46
|
+
@constraint_class = Gecode::BlockConstraint
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should constrain the max of a set' do
|
50
|
+
@set.max.must == 3
|
51
|
+
@model.solve!
|
52
|
+
@set.lower_bound.max.should == 3
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should translate into a max constraint' do
|
56
|
+
Gecode::Raw.should_receive(:max)
|
57
|
+
@set.max.must == 5
|
58
|
+
@model.solve!
|
59
|
+
end
|
60
|
+
|
61
|
+
it_should_behave_like(
|
62
|
+
'property that produces int operand by short circuiting equality')
|
63
|
+
end
|
64
|
+
|
65
|
+
describe Gecode::Set::Connection, ' (sum)' do
|
66
|
+
before do
|
67
|
+
@model = Gecode::Model.new
|
68
|
+
@set = @model.set_var([], 0..9)
|
69
|
+
@target = @var = @model.int_var(0..20)
|
70
|
+
@model.branch_on @model.wrap_enum([@set])
|
71
|
+
|
72
|
+
@property_types = [:set]
|
73
|
+
@select_property = lambda do |set|
|
74
|
+
set.sum
|
75
|
+
end
|
76
|
+
@selected_property = @set.sum
|
77
|
+
@constraint_class = Gecode::BlockConstraint
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should constrain the sum of a set' do
|
81
|
+
@set.sum.must == 7
|
82
|
+
@model.solve!.should_not be_nil
|
83
|
+
@set.value.inject(0){ |x, y| x + y }.should == 7
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should translate into a weights constraint' do
|
87
|
+
Gecode::Raw.should_receive(:weights)
|
88
|
+
@set.sum.must == 5
|
89
|
+
@model.solve!
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should raise error if unsupported options is given' do
|
93
|
+
lambda do
|
94
|
+
@set.sum(:does_not_exist => :foo).must == @var
|
95
|
+
end.should raise_error(ArgumentError)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should raise error if multiple options are given' do
|
99
|
+
lambda do
|
100
|
+
@set.sum(:weights => {}, :substitutions => {}).must == @var
|
101
|
+
end.should raise_error(ArgumentError)
|
102
|
+
end
|
103
|
+
|
104
|
+
it_should_behave_like(
|
105
|
+
'property that produces int operand by short circuiting equality')
|
106
|
+
end
|
107
|
+
|
108
|
+
describe Gecode::Set::Connection, ' (sum with weights)' do
|
109
|
+
before do
|
110
|
+
@model = Gecode::Model.new
|
111
|
+
@set = @model.set_var([], 0..9)
|
112
|
+
@target = @var = @model.int_var(-20..20)
|
113
|
+
@model.branch_on @model.wrap_enum([@set])
|
114
|
+
@weights = Hash[*(0..9).zip((-9..-0).to_a.reverse).flatten]
|
115
|
+
|
116
|
+
@property_types = [:set]
|
117
|
+
@select_property = lambda do |set|
|
118
|
+
set.sum(:weights => @weights)
|
119
|
+
end
|
120
|
+
@selected_property = @set.sum(:weights => @weights)
|
121
|
+
@constraint_class = Gecode::BlockConstraint
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should constrain the sum of a set' do
|
125
|
+
@set.sum(:weights => @weights).must_be.in(-10..-1)
|
126
|
+
@model.solve!.should_not be_nil
|
127
|
+
weighted_sum = @set.value.inject(0){ |sum, x| sum - x**2 }
|
128
|
+
weighted_sum.should >= -10
|
129
|
+
weighted_sum.should <= -1
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'should remove any elements not in the weight hash' do
|
133
|
+
@set.must_be.superset_of 0
|
134
|
+
@set.sum(:weights => {}).must_be == 0
|
135
|
+
lambda do
|
136
|
+
@model.solve!
|
137
|
+
end.should raise_error(Gecode::NoSolutionError)
|
138
|
+
end
|
139
|
+
|
140
|
+
it_should_behave_like(
|
141
|
+
'property that produces int operand by short circuiting equality')
|
142
|
+
end
|
143
|
+
|
144
|
+
describe Gecode::Set::Connection, ' (sum with substitutions)' do
|
145
|
+
before do
|
146
|
+
@model = Gecode::Model.new
|
147
|
+
@set = @model.set_var([], 0..9)
|
148
|
+
@target = @var = @model.int_var(-20..20)
|
149
|
+
@model.branch_on @model.wrap_enum([@set])
|
150
|
+
@subs = Hash[*(0..9).zip((-9..-0).to_a.reverse).flatten]
|
151
|
+
|
152
|
+
@property_types = [:set]
|
153
|
+
@select_property = lambda do |set|
|
154
|
+
set.sum(:substitutions => @subs)
|
155
|
+
end
|
156
|
+
@selected_property = @set.sum(:substitutions => @subs)
|
157
|
+
@constraint_class = Gecode::BlockConstraint
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'should constrain the sum of a set' do
|
161
|
+
@set.sum(:substitutions => @subs).must_be.in(-10..-1)
|
162
|
+
@model.solve!.should_not be_nil
|
163
|
+
substituted_sum = @set.value.inject{ |sum, x| sum + @subs[x] }
|
164
|
+
substituted_sum.should >= -10
|
165
|
+
substituted_sum.should <= -1
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should not be allowed together with :weights option' do
|
169
|
+
lambda do
|
170
|
+
@set.sum(:substitutions => @subs, :weights => [1]*20).must_be.in(-10..-1)
|
171
|
+
end.should raise_error(ArgumentError)
|
172
|
+
end
|
173
|
+
|
174
|
+
it_should_behave_like(
|
175
|
+
'property that produces int operand by short circuiting equality')
|
176
|
+
end
|
@@ -0,0 +1,197 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../constraint_helper'
|
2
|
+
|
3
|
+
Gecode::Util::SET_RELATION_TYPES.each_pair do |relation, type|
|
4
|
+
next if relation == :==
|
5
|
+
|
6
|
+
describe Gecode::Set::Domain, " (#{relation})" do
|
7
|
+
include GecodeR::Specs::SetHelper
|
8
|
+
|
9
|
+
before do
|
10
|
+
@model = Gecode::Model.new
|
11
|
+
@glb = []
|
12
|
+
@lub = 0..3
|
13
|
+
@set = @model.set_var(@glb, @lub)
|
14
|
+
@model.branch_on @set
|
15
|
+
@range = 0..1
|
16
|
+
@non_range = [0, 2]
|
17
|
+
@singleton = 0
|
18
|
+
|
19
|
+
@types = [:set]
|
20
|
+
@invoke = lambda do |receiver, hash|
|
21
|
+
receiver.method(relation).call(@non_range, hash)
|
22
|
+
@model.solve!
|
23
|
+
end
|
24
|
+
@expect = lambda do |var, opts, reif_var|
|
25
|
+
@expect_with_rhs.call(var, opts, reif_var, @non_range)
|
26
|
+
end
|
27
|
+
@expect_with_rhs = lambda do |var, opts, reif_var, rhs|
|
28
|
+
if reif_var.nil?
|
29
|
+
Gecode::Raw.should_receive(:dom).once.with(
|
30
|
+
an_instance_of(Gecode::Raw::Space),
|
31
|
+
var, type,
|
32
|
+
*expect_constant_set(rhs))
|
33
|
+
else
|
34
|
+
params = [an_instance_of(Gecode::Raw::Space),
|
35
|
+
var, type]
|
36
|
+
params << expect_constant_set(rhs)
|
37
|
+
params << reif_var
|
38
|
+
Gecode::Raw.should_receive(:dom).once.with(*params.flatten)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should translate #{relation} with constant range to domain constraint" do
|
44
|
+
@expect_with_rhs.call(@model.allow_space_access{ @set.bind },
|
45
|
+
nil, nil, @range)
|
46
|
+
@set.must.send(relation, @range)
|
47
|
+
@model.solve!
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should translate #{relation} with constant non-range to domain constraint" do
|
51
|
+
@expect_with_rhs.call(@model.allow_space_access{ @set.bind },
|
52
|
+
nil, nil, @non_range)
|
53
|
+
@set.must.send(relation, @non_range)
|
54
|
+
@model.solve!
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should translate #{relation} with constant singleton to domain constraint" do
|
58
|
+
@expect_with_rhs.call(@model.allow_space_access{ @set.bind },
|
59
|
+
nil, nil, @singleton)
|
60
|
+
@set.must.send(relation, @singleton)
|
61
|
+
@model.solve!
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should raise error if the right hand side is not a constant set' do
|
65
|
+
lambda do
|
66
|
+
@set.must.send(relation, 'not a constant set')
|
67
|
+
end.should raise_error(TypeError)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should constrain the domain when #{relation} is used" do
|
71
|
+
@set = @model.set_var if relation == :complement
|
72
|
+
@set.must.method(relation).call(@non_range)
|
73
|
+
@model.solve!
|
74
|
+
@set.should be_assigned
|
75
|
+
case relation
|
76
|
+
when :superset
|
77
|
+
(@non_range - @set.value.to_a).should be_empty
|
78
|
+
when :subset
|
79
|
+
(@set.value.to_a - @non_range).should be_empty
|
80
|
+
when :complement
|
81
|
+
val = @set.value
|
82
|
+
val.min.should == Gecode::Model::SET_MIN_INT
|
83
|
+
val.max.should == Gecode::Model::SET_MAX_INT
|
84
|
+
@non_range.each do |element|
|
85
|
+
@set.not_in_upper_bound?(element).should be_true
|
86
|
+
end
|
87
|
+
when :disjoint
|
88
|
+
(@non_range & @set.value.to_a).should be_empty
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should constrain the domain when negated #{relation} is used" do
|
93
|
+
@set.must_not.method(relation).call(@non_range)
|
94
|
+
@model.solve!
|
95
|
+
@set.should be_assigned
|
96
|
+
case relation
|
97
|
+
when :superset
|
98
|
+
(@non_range - @set.value.to_a).should_not be_empty
|
99
|
+
when :subset
|
100
|
+
(@set.value.to_a - @non_range).should_not be_empty
|
101
|
+
when :complement
|
102
|
+
val = @set.value
|
103
|
+
((val.min != Gecode::Model::SET_MIN_INT) ||
|
104
|
+
(val.max != Gecode::Model::SET_MAX_INT) ||
|
105
|
+
@non_range.any?{ |element| @set.in_lower_bound?(element) }
|
106
|
+
).should be_true
|
107
|
+
when :disjoint
|
108
|
+
(@non_range & @set.value.to_a).should_not be_empty
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
it_should_behave_like 'reifiable set constraint'
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe Gecode::Set::Domain, ' (equality)' do
|
117
|
+
include GecodeR::Specs::SetHelper
|
118
|
+
|
119
|
+
before do
|
120
|
+
@model = Gecode::Model.new
|
121
|
+
@glb = [0]
|
122
|
+
@lub = 0..3
|
123
|
+
@set = @model.set_var(@glb, @lub)
|
124
|
+
@range = 0..1
|
125
|
+
@non_range = [0, 2]
|
126
|
+
@singleton = 0
|
127
|
+
@model.branch_on @model.wrap_enum([@set])
|
128
|
+
|
129
|
+
@types = [:set]
|
130
|
+
@invoke = lambda do |receiver, hash|
|
131
|
+
receiver.equal(@non_range, hash)
|
132
|
+
@model.solve!
|
133
|
+
end
|
134
|
+
@expect = lambda do |var, opts, reif_var|
|
135
|
+
@expect_with_rhs.call(var, opts, reif_var, @non_range)
|
136
|
+
end
|
137
|
+
@expect_with_rhs = lambda do |var, opts, reif_var, rhs|
|
138
|
+
if reif_var.nil?
|
139
|
+
Gecode::Raw.should_receive(:dom).once.with(
|
140
|
+
an_instance_of(Gecode::Raw::Space),
|
141
|
+
var, Gecode::Raw::SRT_EQ,
|
142
|
+
*expect_constant_set(rhs))
|
143
|
+
else
|
144
|
+
params = [an_instance_of(Gecode::Raw::Space),
|
145
|
+
var, Gecode::Raw::SRT_EQ]
|
146
|
+
params << expect_constant_set(rhs)
|
147
|
+
params << reif_var
|
148
|
+
Gecode::Raw.should_receive(:dom).once.with(*params.flatten)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'should translate equality with constant range to domain constraint' do
|
154
|
+
@expect_with_rhs.call(@model.allow_space_access{ @set.bind },
|
155
|
+
nil, nil, @range)
|
156
|
+
@set.must == @range
|
157
|
+
@model.solve!
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'should translate equality with constant non-range to domain constraint' do
|
161
|
+
@expect_with_rhs.call(@model.allow_space_access{ @set.bind },
|
162
|
+
nil, nil, @non_range)
|
163
|
+
@set.must == @non_range
|
164
|
+
@model.solve!
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'should translate equality with constant singleton to domain constraint' do
|
168
|
+
@expect_with_rhs.call(@model.allow_space_access{ @set.bind },
|
169
|
+
nil, nil, @singleton)
|
170
|
+
@set.must == @singleton
|
171
|
+
@model.solve!
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'should constrain the domain with equality' do
|
175
|
+
@set.must == @singleton
|
176
|
+
@model.solve!
|
177
|
+
@set.should be_assigned
|
178
|
+
@set.value.should include(@singleton)
|
179
|
+
@set.value.size.should == 1
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'should constrain the domain with inequality' do
|
183
|
+
@set.must_not == @singleton
|
184
|
+
@model.solve!
|
185
|
+
@set.should be_assigned
|
186
|
+
@set.value.should include(@singleton)
|
187
|
+
((@set.value.size > 1) || (@set.value != [@singleton])).should be_true
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should raise error if the right hand side is not a constant set' do
|
191
|
+
lambda do
|
192
|
+
@set.must == 'not a constant set'
|
193
|
+
end.should raise_error(TypeError)
|
194
|
+
end
|
195
|
+
|
196
|
+
it_should_behave_like 'reifiable set constraint'
|
197
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../constraint_helper'
|
2
|
+
|
3
|
+
describe Gecode::Set::Connection, ' (include)' do
|
4
|
+
before do
|
5
|
+
@model = Gecode::Model.new
|
6
|
+
@set = @model.set_var([], 2..5)
|
7
|
+
@array = @model.int_var_array(4, 0..9)
|
8
|
+
@array.must_be.distinct
|
9
|
+
@model.branch_on @array
|
10
|
+
#@model.branch_on @model.wrap_enum([@set])
|
11
|
+
|
12
|
+
@types = [:set, :int_enum]
|
13
|
+
@invoke = lambda do |receiver, int_enum, hash|
|
14
|
+
if hash.empty?
|
15
|
+
receiver.include(int_enum)
|
16
|
+
else
|
17
|
+
receiver.include(int_enum, hash)
|
18
|
+
end
|
19
|
+
@model.solve!
|
20
|
+
end
|
21
|
+
@expect = lambda do |var1, var2, opts, reif_var|
|
22
|
+
Gecode::Raw.should_receive(:match).once.with(
|
23
|
+
an_instance_of(Gecode::Raw::Space),
|
24
|
+
var1, var2)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should constrain the variables to be included in the set' do
|
29
|
+
@set.must.include @array
|
30
|
+
@model.solve!.should_not be_nil
|
31
|
+
@array.all?{ |x| @set.lower_bound.include? x.value }.should be_true
|
32
|
+
end
|
33
|
+
|
34
|
+
it_should_behave_like 'non-reifiable set constraint'
|
35
|
+
it_should_behave_like 'non-negatable constraint'
|
36
|
+
end
|