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,213 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../constraint_helper'
|
2
|
+
|
3
|
+
class BoolLinearSampleProblem < Gecode::Model
|
4
|
+
attr :x
|
5
|
+
attr :y
|
6
|
+
attr :z
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@x = self.bool_var
|
10
|
+
@y = self.bool_var
|
11
|
+
@z = self.bool_var
|
12
|
+
branch_on wrap_enum([@x, @y, @z])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class TrueClass
|
17
|
+
def to_i
|
18
|
+
1
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class FalseClass
|
23
|
+
def to_i
|
24
|
+
0
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe Gecode::Int::Linear, '(with booleans)' do
|
29
|
+
before do
|
30
|
+
@model = BoolLinearSampleProblem.new
|
31
|
+
@x = @model.x
|
32
|
+
@y = @model.y
|
33
|
+
@z = @model.z
|
34
|
+
@operand = @x + @y
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should handle addition with a variable' do
|
38
|
+
(@x + @y).must == 0
|
39
|
+
sol = @model.solve!
|
40
|
+
x = sol.x.value.to_i
|
41
|
+
y = sol.y.value.to_i
|
42
|
+
(x + y).should be_zero
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should handle reification (1)' do
|
46
|
+
bool = @model.bool_var
|
47
|
+
(@x + @y).must.equal(0, :reify => bool)
|
48
|
+
bool.must_be.false
|
49
|
+
sol = @model.solve!
|
50
|
+
x = sol.x.value.to_i
|
51
|
+
y = sol.y.value.to_i
|
52
|
+
(x + y).should_not be_zero
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should handle reification (2)' do
|
56
|
+
bool = @model.bool_var
|
57
|
+
(@x + @y).must.equal(0, :reify => bool)
|
58
|
+
bool.must_be.true
|
59
|
+
sol = @model.solve!
|
60
|
+
x = sol.x.value.to_i
|
61
|
+
y = sol.y.value.to_i
|
62
|
+
(x + y).should be_zero
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should handle addition with multiple variables' do
|
66
|
+
(@x + @y + @z).must == 0
|
67
|
+
sol = @model.solve!
|
68
|
+
x = sol.x.value.to_i
|
69
|
+
y = sol.y.value.to_i
|
70
|
+
z = sol.z.value.to_i
|
71
|
+
(x + y + z).should be_zero
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should handle subtraction with a variable' do
|
75
|
+
(@x - @y).must == 0
|
76
|
+
sol = @model.solve!
|
77
|
+
x = sol.x.value.to_i
|
78
|
+
y = sol.y.value.to_i
|
79
|
+
(x - y).should be_zero
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should handle non-zero constants as right hand side' do
|
83
|
+
(@x + @y).must == 1
|
84
|
+
sol = @model.solve!
|
85
|
+
x = sol.x.value.to_i
|
86
|
+
y = sol.y.value.to_i
|
87
|
+
(x + y).should equal(1)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should handle single booleans as left hand side' do
|
91
|
+
@x.must == @y + 1
|
92
|
+
sol = @model.solve!
|
93
|
+
x = sol.x.value.to_i
|
94
|
+
y = sol.y.value.to_i
|
95
|
+
x.should equal(y + 1)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should handle single booleans as left hand side (2)' do
|
99
|
+
@x.must == @y + @z
|
100
|
+
sol = @model.solve!
|
101
|
+
x = sol.x.value.to_i
|
102
|
+
y = sol.y.value.to_i
|
103
|
+
z = sol.z.value.to_i
|
104
|
+
x.should equal(y + z)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should handle single booleans as left hand side (3)' do
|
108
|
+
bool = @model.bool_var
|
109
|
+
@x.must.equal(@y + @z, :reify => bool)
|
110
|
+
bool.must_be.false
|
111
|
+
sol = @model.solve!
|
112
|
+
x = sol.x.value.to_i
|
113
|
+
y = sol.y.value.to_i
|
114
|
+
z = sol.z.value.to_i
|
115
|
+
x.should_not equal(y + z)
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should handle variables as right hand side' do
|
119
|
+
(@x + @y).must == @z
|
120
|
+
sol = @model.solve!
|
121
|
+
x = sol.x.value.to_i
|
122
|
+
y = sol.y.value.to_i
|
123
|
+
z = sol.z.value.to_i
|
124
|
+
(x + y).should equal(z)
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'should handle linear expressions as right hand side' do
|
128
|
+
(@x + @y).must == @z + @y
|
129
|
+
sol = @model.solve!
|
130
|
+
x = sol.x.value.to_i
|
131
|
+
y = sol.y.value.to_i
|
132
|
+
z = sol.z.value.to_i
|
133
|
+
(x + y).should equal(z + y)
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should raise error on invalid right hand sides' do
|
137
|
+
lambda do
|
138
|
+
(@x + @y).must == 'z'
|
139
|
+
end.should raise_error(TypeError)
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should raise error if a fixnum is not used in multiplication' do
|
143
|
+
lambda do
|
144
|
+
(@x * @y).must == 0
|
145
|
+
end.should raise_error(TypeError)
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'should raise error if bools are combined with integer variables' do
|
149
|
+
lambda do
|
150
|
+
(@x + @model.int_var).must == 0
|
151
|
+
end.should raise_error(TypeError)
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should handle coefficients other than 1' do
|
155
|
+
(@x * 2 + @y).must == 0
|
156
|
+
sol = @model.solve!
|
157
|
+
x = sol.x.value.to_i
|
158
|
+
y = sol.y.value.to_i
|
159
|
+
(2*x + y).should equal(0)
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'should handle addition with constants' do
|
163
|
+
(@y + 1).must == 1
|
164
|
+
sol = @model.solve!
|
165
|
+
y = sol.y.value.to_i
|
166
|
+
(y + 1).should equal(1)
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'should handle subtraction with a constant' do
|
170
|
+
(@x - 1).must == 0
|
171
|
+
sol = @model.solve!
|
172
|
+
x = sol.x.value.to_i
|
173
|
+
(x - 1).should be_zero
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'should handle parenthesis' do
|
177
|
+
(@x - (@y + @z)).must == 1
|
178
|
+
sol = @model.solve!
|
179
|
+
x = sol.x.value.to_i
|
180
|
+
y = sol.y.value.to_i
|
181
|
+
z = sol.z.value.to_i
|
182
|
+
(x - (y + z)).should equal(1)
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'should handle multiplication of parenthesis' do
|
186
|
+
(((@x + @y*10)*10 + @z)*10).must == 0
|
187
|
+
sol = @model.solve!
|
188
|
+
x = sol.x.value.to_i
|
189
|
+
y = sol.y.value.to_i
|
190
|
+
z = sol.z.value.to_i
|
191
|
+
(((x + y*10)*10 + z)*10).should equal(0)
|
192
|
+
end
|
193
|
+
|
194
|
+
relations = ['>', '>=', '<', '<=', '==']
|
195
|
+
|
196
|
+
relations.each do |relation|
|
197
|
+
it "should handle #{relation} with constant integers" do
|
198
|
+
(@x + @y).must.send(relation, 1)
|
199
|
+
sol = @model.solve!
|
200
|
+
sol.should_not be_nil
|
201
|
+
(sol.x.value.to_i + sol.y.value.to_i).should.send(relation, 1)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
relations.each do |relation|
|
206
|
+
it "should handle negated #{relation} with constant integers" do
|
207
|
+
(@x + @y).must_not.send(relation, 1)
|
208
|
+
sol = @model.solve!
|
209
|
+
sol.should_not be_nil
|
210
|
+
(sol.x.value.to_i + sol.y.value.to_i).should_not.send(relation, 1)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../property_helper'
|
2
|
+
|
3
|
+
class BoolEnumSampleProblem < Gecode::Model
|
4
|
+
attr :bools
|
5
|
+
attr :b1
|
6
|
+
attr :b2
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@bools = bool_var_array(4)
|
10
|
+
@b1 = bool_var
|
11
|
+
@b2 = bool_var
|
12
|
+
branch_on @bools
|
13
|
+
branch_on wrap_enum([@b1, @b2])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Expects @stub, which contains the started constraint and @compute_result
|
18
|
+
# which computes whether the left hand side is true or not.
|
19
|
+
describe 'bool enum relation constraint', :shared => true do
|
20
|
+
it 'should handle being constrained to be true' do
|
21
|
+
@stub.must_be.true
|
22
|
+
@model.solve!
|
23
|
+
@compute_result.call.should be_true
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should handle being constrained to be negated true' do
|
27
|
+
@stub.must_not_be.true
|
28
|
+
@model.solve!
|
29
|
+
@compute_result.call.should_not be_true
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should handle being constrained to be false' do
|
33
|
+
@stub.must_be.false
|
34
|
+
@model.solve!
|
35
|
+
@compute_result.call.should_not be_true
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should handle being constrained to be negated false' do
|
39
|
+
@stub.must_not_be.false
|
40
|
+
@model.solve!
|
41
|
+
@compute_result.call.should be_true
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should handle being constrained to be equal to a variable' do
|
45
|
+
@stub.must_be == @b1
|
46
|
+
@model.solve!
|
47
|
+
@compute_result.call.should == @b1.value
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should handle being constrained to not be equal to a variable' do
|
51
|
+
@stub.must_not_be == @b1
|
52
|
+
@model.solve!
|
53
|
+
@compute_result.call.should_not == @b1.value
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should handle being constrained to be equal to be a nested expression' do
|
57
|
+
@stub.must_be == (@b1 | @b2) & @b1
|
58
|
+
@model.solve!
|
59
|
+
@compute_result.call.should == (@b1.value | @b2.value) & @b1.value
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should handle being constrained to not be equal to be a nested expression' do
|
63
|
+
@stub.must_not_be == (@b1 | @b2) & @b1
|
64
|
+
@model.solve!
|
65
|
+
@compute_result.call.should_not == (@b1.value | @b2.value) & @b1.value
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe Gecode::BoolEnum::Relation, ' (conjunction)' do
|
70
|
+
before do
|
71
|
+
@model = BoolEnumSampleProblem.new
|
72
|
+
@bools = @model.bools
|
73
|
+
@b1 = @model.b1
|
74
|
+
@b2 = @model.b2
|
75
|
+
|
76
|
+
# For property spec.
|
77
|
+
@property_types = [:bool_enum]
|
78
|
+
@select_property = lambda do |bool_enum|
|
79
|
+
bool_enum.conjunction
|
80
|
+
end
|
81
|
+
@selected_property = @bools.conjunction
|
82
|
+
@constraint_class = Gecode::BlockConstraint
|
83
|
+
|
84
|
+
# For bool enum spec.
|
85
|
+
@stub = @selected_property
|
86
|
+
@compute_result = lambda{ @bools.all?{ |b| b.value } }
|
87
|
+
end
|
88
|
+
|
89
|
+
it_should_behave_like 'bool enum relation constraint'
|
90
|
+
it_should_behave_like(
|
91
|
+
'property that produces bool operand by short circuiting equality')
|
92
|
+
end
|
93
|
+
|
94
|
+
describe Gecode::BoolEnum::Relation, ' (disjunction)' do
|
95
|
+
before do
|
96
|
+
@model = BoolEnumSampleProblem.new
|
97
|
+
@bools = @model.bools
|
98
|
+
@b1 = @model.b1
|
99
|
+
@b2 = @model.b2
|
100
|
+
|
101
|
+
# For constraint option spec.
|
102
|
+
@property_types = [:bool_enum]
|
103
|
+
@select_property = lambda do |bool_enum|
|
104
|
+
bool_enum.disjunction
|
105
|
+
end
|
106
|
+
@selected_property = @bools.disjunction
|
107
|
+
@constraint_class = Gecode::BlockConstraint
|
108
|
+
|
109
|
+
# For bool enum spec.
|
110
|
+
@stub = @selected_property
|
111
|
+
@compute_result = lambda{ @bools.any?{ |b| b.value } }
|
112
|
+
end
|
113
|
+
|
114
|
+
it_should_behave_like 'bool enum relation constraint'
|
115
|
+
it_should_behave_like(
|
116
|
+
'property that produces bool operand by short circuiting equality')
|
117
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../constraint_helper'
|
2
|
+
|
3
|
+
class BoolChannelSampleProblem < Gecode::Model
|
4
|
+
attr :bool_enum
|
5
|
+
attr :bool
|
6
|
+
attr :int
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@bool_enum = bool_var_array(4)
|
10
|
+
@int = int_var(0..3)
|
11
|
+
@bool = bool_var
|
12
|
+
|
13
|
+
branch_on @int
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe Gecode::BoolEnum::Channel, ' (bool enum as lhs with int variable)' do
|
18
|
+
before do
|
19
|
+
@model = BoolChannelSampleProblem.new
|
20
|
+
@bools = @model.bool_enum
|
21
|
+
@int = @model.int
|
22
|
+
|
23
|
+
@types = [:bool_enum, :int]
|
24
|
+
@invoke = lambda do |receiver, int, hash|
|
25
|
+
receiver.channel(int, hash)
|
26
|
+
@model.solve!
|
27
|
+
end
|
28
|
+
@expect = lambda do |var1, var2, opts, reif_var|
|
29
|
+
Gecode::Raw.should_receive(:channel).once.with(
|
30
|
+
an_instance_of(Gecode::Raw::Space),
|
31
|
+
var1, var2, 0, *opts)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should channel the bool enum with the integer variable' do
|
36
|
+
@int.must > 2
|
37
|
+
@bools.must.channel @int
|
38
|
+
@model.solve!.should_not be_nil
|
39
|
+
int_val = @int.value
|
40
|
+
@bools.values.each_with_index do |bool, index|
|
41
|
+
bool.should == (index == int_val)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should take the offset into account when channeling' do
|
46
|
+
@int.must > 2
|
47
|
+
offset = 1
|
48
|
+
@bools.must.channel(@int, :offset => offset)
|
49
|
+
@model.solve!.should_not be_nil
|
50
|
+
int_val = @int.value
|
51
|
+
@bools.values.each_with_index do |bool, index|
|
52
|
+
bool.should == (index + offset == int_val)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it_should_behave_like 'non-reifiable constraint'
|
57
|
+
it_should_behave_like 'non-negatable constraint'
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
describe Gecode::BoolEnum::Channel, ' (int variable as lhs with bool enum)' do
|
62
|
+
before do
|
63
|
+
@model = BoolChannelSampleProblem.new
|
64
|
+
@bools = @model.bool_enum
|
65
|
+
@int = @model.int
|
66
|
+
|
67
|
+
@types = [:int, :bool_enum]
|
68
|
+
@invoke = lambda do |receiver, bool_enum, hash|
|
69
|
+
receiver.channel(bool_enum, hash)
|
70
|
+
@model.solve!
|
71
|
+
end
|
72
|
+
@expect = lambda do |var1, var2, opts, reif_var|
|
73
|
+
Gecode::Raw.should_receive(:channel).once.with(
|
74
|
+
an_instance_of(Gecode::Raw::Space),
|
75
|
+
var2, var1, 0, *opts)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should channel the bool enum with the integer variable' do
|
80
|
+
@int.must > 2
|
81
|
+
@int.must.channel @bools
|
82
|
+
@model.solve!.should_not be_nil
|
83
|
+
int_val = @int.value
|
84
|
+
@bools.values.each_with_index do |bool, index|
|
85
|
+
bool.should == (index == int_val)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should take the offset into account when channeling' do
|
90
|
+
@int.must > 2
|
91
|
+
offset = 1
|
92
|
+
@int.must.channel(@bools, :offset => offset)
|
93
|
+
@model.solve!.should_not be_nil
|
94
|
+
int_val = @int.value
|
95
|
+
@bools.values.each_with_index do |bool, index|
|
96
|
+
bool.should == (index + offset == int_val)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
it_should_behave_like 'non-reifiable constraint'
|
101
|
+
it_should_behave_like 'non-negatable constraint'
|
102
|
+
end
|
@@ -1,21 +1,7 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../
|
2
|
-
require File.dirname(__FILE__) + '/constraint_helper'
|
1
|
+
require File.dirname(__FILE__) + '/../constraint_helper'
|
3
2
|
|
4
3
|
# Assumes that @variables, @expected_array and @tuples are defined.
|
5
|
-
describe 'tuple constraint', :shared => true do
|
6
|
-
before do
|
7
|
-
@invoke_options = lambda do |hash|
|
8
|
-
@variables.must_be.in(@tuples, hash)
|
9
|
-
@model.solve!
|
10
|
-
end
|
11
|
-
@expect_options = option_expectation do |strength, kind, reif_var|
|
12
|
-
Gecode::Raw.should_receive(:extensional).once.with(
|
13
|
-
an_instance_of(Gecode::Raw::Space),
|
14
|
-
@expected_array,
|
15
|
-
an_instance_of(Gecode::Raw::TupleSet), strength, kind)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
4
|
+
describe 'bool tuple constraint', :shared => true do
|
19
5
|
it 'should not allow negation' do
|
20
6
|
lambda do
|
21
7
|
@variables.must_not_be.in @tuples
|
@@ -40,51 +26,26 @@ describe 'tuple constraint', :shared => true do
|
|
40
26
|
@variables.must_be.in ['h'*size, 'i'*size]
|
41
27
|
end.should raise_error(TypeError)
|
42
28
|
end
|
43
|
-
|
44
|
-
it_should_behave_like 'non-reifiable constraint'
|
45
|
-
end
|
46
|
-
|
47
|
-
describe Gecode::Constraints::IntEnum::Extensional, ' (tuple constraint)' do
|
48
|
-
before do
|
49
|
-
@model = Gecode::Model.new
|
50
|
-
@tuples = [[1,7], [5,1]]
|
51
|
-
@variables = @digits = @model.int_var_array(2, 0..9)
|
52
|
-
@model.branch_on @digits
|
53
|
-
|
54
|
-
@expected_array = an_instance_of Gecode::Raw::IntVarArray
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should constrain the domain of all variables' do
|
58
|
-
@digits.must_be.in @tuples
|
59
|
-
|
60
|
-
found_solutions = []
|
61
|
-
@model.each_solution do |m|
|
62
|
-
found_solutions << @digits.values
|
63
|
-
end
|
64
|
-
|
65
|
-
found_solutions.size.should == 2
|
66
|
-
(found_solutions - @tuples).should be_empty
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'should raise error if the right hand side is not an enumeration' do
|
70
|
-
lambda{ @digits.must_be.in 4711 }.should raise_error(TypeError)
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'should raise error if the right hand side does not contain tuples' do
|
74
|
-
lambda{ @digits.must_be.in [17, 4711] }.should raise_error(TypeError)
|
75
|
-
end
|
76
|
-
|
77
|
-
it_should_behave_like 'tuple constraint'
|
78
29
|
end
|
79
30
|
|
80
|
-
describe Gecode::
|
31
|
+
describe Gecode::BoolEnum::Extensional, ' (tuple constraint)' do
|
81
32
|
before do
|
82
33
|
@model = Gecode::Model.new
|
83
34
|
@tuples = [[true, false, true], [false, false, true]]
|
84
35
|
@variables = @bools = @model.bool_var_array(3)
|
85
36
|
@model.branch_on @bools
|
86
37
|
|
87
|
-
@
|
38
|
+
@types = [:bool_enum]
|
39
|
+
@invoke = lambda do |receiver, hash|
|
40
|
+
receiver.in([[true, false, true, false, true],
|
41
|
+
[false, true, true, true, true]], hash)
|
42
|
+
@model.solve!
|
43
|
+
end
|
44
|
+
@expect = lambda do |var, opts, reif_var|
|
45
|
+
Gecode::Raw.should_receive(:extensional).once.with(
|
46
|
+
an_instance_of(Gecode::Raw::Space),
|
47
|
+
var, an_instance_of(Gecode::Raw::TupleSet), *opts)
|
48
|
+
end
|
88
49
|
end
|
89
50
|
|
90
51
|
it 'should constrain the domain of all variables' do
|
@@ -107,25 +68,14 @@ describe Gecode::Constraints::BoolEnum::Extensional, ' (tuple constraint)' do
|
|
107
68
|
lambda{ @bools.must_be.in [true, false] }.should raise_error(TypeError)
|
108
69
|
end
|
109
70
|
|
110
|
-
it_should_behave_like 'tuple constraint'
|
71
|
+
it_should_behave_like 'bool tuple constraint'
|
72
|
+
it_should_behave_like 'non-reifiable constraint'
|
111
73
|
end
|
112
74
|
|
75
|
+
|
113
76
|
# Assumes that @variables, @expected_array, @value1, @value2 (must not
|
114
77
|
# equal @value1) and @regexp are defined.
|
115
|
-
describe 'regular expression constraint', :shared => true do
|
116
|
-
before do
|
117
|
-
@invoke_options = lambda do |hash|
|
118
|
-
@variables.must.match(@regexp, hash)
|
119
|
-
@model.solve!
|
120
|
-
end
|
121
|
-
@expect_options = option_expectation do |strength, kind, reif_var|
|
122
|
-
Gecode::Raw.should_receive(:extensional).once.with(
|
123
|
-
an_instance_of(Gecode::Raw::Space),
|
124
|
-
@expected_array,
|
125
|
-
an_instance_of(Gecode::Raw::REG), strength, kind)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
78
|
+
describe 'bool regular expression constraint', :shared => true do
|
129
79
|
it 'should handle values grouped in a single array' do
|
130
80
|
@variables.must.match [@value1, @value2, @value1]
|
131
81
|
@model.solve!.should_not be_nil
|
@@ -231,40 +181,9 @@ describe 'regular expression constraint', :shared => true do
|
|
231
181
|
@variables.must_not.match @regexp
|
232
182
|
end.should raise_error(Gecode::MissingConstraintError)
|
233
183
|
end
|
234
|
-
|
235
|
-
it_should_behave_like 'non-reifiable constraint'
|
236
|
-
end
|
237
|
-
|
238
|
-
describe Gecode::Constraints::IntEnum::Extensional, ' (regexp constraint)' do
|
239
|
-
before do
|
240
|
-
@model = Gecode::Model.new
|
241
|
-
@variables = @digits = @model.int_var_array(3, 0..9)
|
242
|
-
@model.branch_on @digits
|
243
|
-
@expected_array = an_instance_of Gecode::Raw::IntVarArray
|
244
|
-
@value1 = 3
|
245
|
-
@value2 = 5
|
246
|
-
@regexp = [1, @model.any(3, 4), @model.at_most_once(5)]
|
247
|
-
end
|
248
|
-
|
249
|
-
it 'should handle the any operation' do
|
250
|
-
@digits.must.match [1, @model.any(1, 2, 3), 3]
|
251
|
-
@model.solve!.should_not be_nil
|
252
|
-
values = @digits.values
|
253
|
-
values.size.should == 3
|
254
|
-
values.should == values.sort
|
255
|
-
end
|
256
|
-
|
257
|
-
it 'should handle the any operator with nested expressions' do
|
258
|
-
@digits.must.match [1, @model.any(@model.at_least_once(2), [3, 5])]
|
259
|
-
@digits[2].must < 4
|
260
|
-
@model.solve!.should_not be_nil
|
261
|
-
@digits.values.should == [1,2,2]
|
262
|
-
end
|
263
|
-
|
264
|
-
it_should_behave_like 'regular expression constraint'
|
265
184
|
end
|
266
185
|
|
267
|
-
describe Gecode::
|
186
|
+
describe Gecode::BoolEnum::Extensional, ' (regexp constraint)' do
|
268
187
|
before do
|
269
188
|
@model = Gecode::Model.new
|
270
189
|
@variables = @bools = @model.bool_var_array(3)
|
@@ -273,6 +192,17 @@ describe Gecode::Constraints::BoolEnum::Extensional, ' (regexp constraint)' do
|
|
273
192
|
@value1 = true
|
274
193
|
@value2 = false
|
275
194
|
@regexp = [true, @model.any(true, false), @model.at_most_once(true)]
|
195
|
+
|
196
|
+
@types = [:bool_enum]
|
197
|
+
@invoke = lambda do |receiver, hash|
|
198
|
+
receiver.match(@regexp, hash)
|
199
|
+
@model.solve!
|
200
|
+
end
|
201
|
+
@expect = lambda do |var, opts, reif_var|
|
202
|
+
Gecode::Raw.should_receive(:extensional).once.with(
|
203
|
+
an_instance_of(Gecode::Raw::Space),
|
204
|
+
var, an_instance_of(Gecode::Raw::REG), *opts)
|
205
|
+
end
|
276
206
|
end
|
277
207
|
|
278
208
|
it 'should handle the any operation' do
|
@@ -290,5 +220,6 @@ describe Gecode::Constraints::BoolEnum::Extensional, ' (regexp constraint)' do
|
|
290
220
|
@bools.values.should == [true, true, true]
|
291
221
|
end
|
292
222
|
|
293
|
-
it_should_behave_like 'regular expression constraint'
|
223
|
+
it_should_behave_like 'bool regular expression constraint'
|
224
|
+
it_should_behave_like 'non-reifiable constraint'
|
294
225
|
end
|