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
@@ -1,351 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
require File.dirname(__FILE__) + '/constraint_helper'
|
3
|
-
|
4
|
-
class ArithmeticSampleProblem < Gecode::Model
|
5
|
-
attr :numbers
|
6
|
-
attr :var
|
7
|
-
attr :var2
|
8
|
-
attr :var3
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
@numbers = int_var_array(4, 0..9)
|
12
|
-
@var = int_var(-9..9)
|
13
|
-
@var2 = int_var(0..9)
|
14
|
-
@var3 = int_var(0..9)
|
15
|
-
branch_on @numbers
|
16
|
-
branch_on wrap_enum([@var, @var2, @var3])
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# Construct a method placing expectations for an arithmetic constraint with the
|
21
|
-
# specified arity (number of variables before must) and the specified name in
|
22
|
-
# Gecode.
|
23
|
-
def arithmetic_expectation(gecode_name, arity)
|
24
|
-
lambda do |relation, rhs, strength, kind, reif_var, negated|
|
25
|
-
# Construct the arguments expected to be passed to the Gecode variant of
|
26
|
-
# the constraint.
|
27
|
-
rhs = an_instance_of(Gecode::Raw::IntVar) if rhs.respond_to? :bind
|
28
|
-
expected_gecode_arguments = [an_instance_of(Gecode::Raw::Space)]
|
29
|
-
arity.times do
|
30
|
-
expected_gecode_arguments << an_instance_of(Gecode::Raw::IntVar)
|
31
|
-
end
|
32
|
-
can_use_single_gecode_constraint = reif_var.nil? && !negated &&
|
33
|
-
relation == Gecode::Raw::IRT_EQ && !rhs.kind_of?(Fixnum)
|
34
|
-
if can_use_single_gecode_constraint
|
35
|
-
expected_gecode_arguments << rhs
|
36
|
-
else
|
37
|
-
expected_gecode_arguments << an_instance_of(Gecode::Raw::IntVar)
|
38
|
-
end
|
39
|
-
expected_gecode_arguments.concat([strength, kind])
|
40
|
-
|
41
|
-
# Create the actual method producing the expectation.
|
42
|
-
@model.allow_space_access do
|
43
|
-
if reif_var.nil?
|
44
|
-
if can_use_single_gecode_constraint
|
45
|
-
Gecode::Raw.should_receive(gecode_name).once.with(
|
46
|
-
*expected_gecode_arguments)
|
47
|
-
Gecode::Raw.should_receive(:rel).exactly(0).times
|
48
|
-
else
|
49
|
-
Gecode::Raw.should_receive(gecode_name).once.with(
|
50
|
-
*expected_gecode_arguments)
|
51
|
-
Gecode::Raw.should_receive(:rel).once.with(
|
52
|
-
an_instance_of(Gecode::Raw::Space),
|
53
|
-
an_instance_of(Gecode::Raw::IntVar),
|
54
|
-
relation, rhs, strength, kind)
|
55
|
-
end
|
56
|
-
else
|
57
|
-
Gecode::Raw.should_receive(gecode_name).once.with(
|
58
|
-
*expected_gecode_arguments)
|
59
|
-
Gecode::Raw.should_receive(:rel).once.with(
|
60
|
-
an_instance_of(Gecode::Raw::Space),
|
61
|
-
an_instance_of(Gecode::Raw::IntVar), relation, rhs,
|
62
|
-
an_instance_of(Gecode::Raw::BoolVar),
|
63
|
-
strength, kind)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
# Requires @stub, @target, @model and @expect.
|
70
|
-
describe 'arithmetic constraint', :shared => true do
|
71
|
-
before do
|
72
|
-
# For constraint option spec.
|
73
|
-
@invoke_options = lambda do |hash|
|
74
|
-
@stub.must_be.greater_than(@target, hash)
|
75
|
-
@model.solve!
|
76
|
-
end
|
77
|
-
@expect_options = option_expectation do |strength, kind, reif_var|
|
78
|
-
@expect.call(Gecode::Raw::IRT_GR, @target, strength, kind, reif_var,
|
79
|
-
false)
|
80
|
-
end
|
81
|
-
|
82
|
-
# For composite spec.
|
83
|
-
@invoke_relation = lambda do |relation, target, negated|
|
84
|
-
if negated
|
85
|
-
@stub.must_not.send(relation, target)
|
86
|
-
else
|
87
|
-
@stub.must.send(relation, target)
|
88
|
-
end
|
89
|
-
@model.solve!
|
90
|
-
end
|
91
|
-
@expect_relation = lambda do |relation, target, negated|
|
92
|
-
@expect.call(relation, target, Gecode::Raw::ICL_DEF, Gecode::Raw::PK_DEF,
|
93
|
-
nil, negated)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'should translate reification when using equality' do
|
98
|
-
bool_var = @model.bool_var
|
99
|
-
@expect.call(Gecode::Raw::IRT_EQ, @target, Gecode::Raw::ICL_DEF,
|
100
|
-
Gecode::Raw::PK_DEF, bool_var, false)
|
101
|
-
@stub.must_be.equal_to(@target, :reify => bool_var)
|
102
|
-
@model.solve!
|
103
|
-
end
|
104
|
-
|
105
|
-
it_should_behave_like 'composite constraint'
|
106
|
-
it_should_behave_like 'reifiable constraint'
|
107
|
-
end
|
108
|
-
|
109
|
-
describe Gecode::Constraints::IntEnum::Arithmetic, ' (max)' do
|
110
|
-
before do
|
111
|
-
@model = ArithmeticSampleProblem.new
|
112
|
-
@numbers = @model.numbers
|
113
|
-
@target = @var = @model.var
|
114
|
-
@stub = @numbers.max
|
115
|
-
|
116
|
-
# Creates an expectation corresponding to the specified input.
|
117
|
-
@expect = lambda do |relation, rhs, strength, kind, reif_var, negated|
|
118
|
-
@model.allow_space_access do
|
119
|
-
rhs = an_instance_of(Gecode::Raw::IntVar) if rhs.respond_to? :bind
|
120
|
-
if reif_var.nil?
|
121
|
-
if !negated and relation == Gecode::Raw::IRT_EQ and
|
122
|
-
!rhs.kind_of? Fixnum
|
123
|
-
Gecode::Raw.should_receive(:max).once.with(
|
124
|
-
an_instance_of(Gecode::Raw::Space),
|
125
|
-
an_instance_of(Gecode::Raw::IntVarArray),
|
126
|
-
rhs, strength, kind)
|
127
|
-
Gecode::Raw.should_receive(:rel).exactly(0).times
|
128
|
-
else
|
129
|
-
Gecode::Raw.should_receive(:max).once.with(
|
130
|
-
an_instance_of(Gecode::Raw::Space),
|
131
|
-
an_instance_of(Gecode::Raw::IntVarArray),
|
132
|
-
an_instance_of(Gecode::Raw::IntVar),
|
133
|
-
strength, kind)
|
134
|
-
Gecode::Raw.should_receive(:rel).once.with(
|
135
|
-
an_instance_of(Gecode::Raw::Space),
|
136
|
-
an_instance_of(Gecode::Raw::IntVar),
|
137
|
-
relation, rhs, strength, kind)
|
138
|
-
end
|
139
|
-
else
|
140
|
-
Gecode::Raw.should_receive(:max).once.with(
|
141
|
-
an_instance_of(Gecode::Raw::Space),
|
142
|
-
an_instance_of(Gecode::Raw::IntVarArray),
|
143
|
-
an_instance_of(Gecode::Raw::IntVar),
|
144
|
-
strength, kind)
|
145
|
-
Gecode::Raw.should_receive(:rel).once.with(
|
146
|
-
an_instance_of(Gecode::Raw::Space),
|
147
|
-
an_instance_of(Gecode::Raw::IntVar), relation, rhs,
|
148
|
-
an_instance_of(Gecode::Raw::BoolVar),
|
149
|
-
strength, kind)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
it 'should constrain the maximum value' do
|
156
|
-
@numbers.max.must > 5
|
157
|
-
@model.solve!.numbers.values.max.should > 5
|
158
|
-
end
|
159
|
-
|
160
|
-
it_should_behave_like 'arithmetic constraint'
|
161
|
-
end
|
162
|
-
|
163
|
-
describe Gecode::Constraints::IntEnum::Arithmetic, ' (min)' do
|
164
|
-
before do
|
165
|
-
@model = ArithmeticSampleProblem.new
|
166
|
-
@numbers = @model.numbers
|
167
|
-
@target = @var = @model.var
|
168
|
-
@stub = @numbers.min
|
169
|
-
|
170
|
-
# Creates an expectation corresponding to the specified input.
|
171
|
-
@expect = lambda do |relation, rhs, strength, kind, reif_var, negated|
|
172
|
-
@model.allow_space_access do
|
173
|
-
rhs = an_instance_of(Gecode::Raw::IntVar) if rhs.respond_to? :bind
|
174
|
-
if reif_var.nil?
|
175
|
-
if !negated and relation == Gecode::Raw::IRT_EQ and
|
176
|
-
!rhs.kind_of? Fixnum
|
177
|
-
Gecode::Raw.should_receive(:min).once.with(
|
178
|
-
an_instance_of(Gecode::Raw::Space),
|
179
|
-
an_instance_of(Gecode::Raw::IntVarArray),
|
180
|
-
rhs, strength, kind)
|
181
|
-
Gecode::Raw.should_receive(:rel).exactly(0).times
|
182
|
-
else
|
183
|
-
Gecode::Raw.should_receive(:min).once.with(
|
184
|
-
an_instance_of(Gecode::Raw::Space),
|
185
|
-
an_instance_of(Gecode::Raw::IntVarArray),
|
186
|
-
an_instance_of(Gecode::Raw::IntVar),
|
187
|
-
strength, kind)
|
188
|
-
Gecode::Raw.should_receive(:rel).once.with(
|
189
|
-
an_instance_of(Gecode::Raw::Space),
|
190
|
-
an_instance_of(Gecode::Raw::IntVar),
|
191
|
-
relation, rhs, strength, kind)
|
192
|
-
end
|
193
|
-
else
|
194
|
-
Gecode::Raw.should_receive(:min).once.with(
|
195
|
-
an_instance_of(Gecode::Raw::Space),
|
196
|
-
an_instance_of(Gecode::Raw::IntVarArray),
|
197
|
-
an_instance_of(Gecode::Raw::IntVar),
|
198
|
-
strength, kind)
|
199
|
-
Gecode::Raw.should_receive(:rel).once.with(
|
200
|
-
an_instance_of(Gecode::Raw::Space),
|
201
|
-
an_instance_of(Gecode::Raw::IntVar), relation, rhs,
|
202
|
-
an_instance_of(Gecode::Raw::BoolVar),
|
203
|
-
strength, kind)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
it 'should constrain the minimum value' do
|
210
|
-
@numbers.min.must > 5
|
211
|
-
@model.solve!.numbers.values.min.should > 5
|
212
|
-
end
|
213
|
-
|
214
|
-
it_should_behave_like 'arithmetic constraint'
|
215
|
-
end
|
216
|
-
|
217
|
-
describe Gecode::Constraints::Int::Arithmetic, ' (abs)' do
|
218
|
-
before do
|
219
|
-
@model = ArithmeticSampleProblem.new
|
220
|
-
@var = @model.var
|
221
|
-
@target = @model.var2
|
222
|
-
@stub = @var.abs
|
223
|
-
|
224
|
-
# Creates an expectation corresponding to the specified input.
|
225
|
-
@expect = lambda do |relation, rhs, strength, kind, reif_var, negated|
|
226
|
-
@model.allow_space_access do
|
227
|
-
rhs = an_instance_of(Gecode::Raw::IntVar) if rhs.respond_to? :bind
|
228
|
-
if reif_var.nil?
|
229
|
-
if !negated and relation == Gecode::Raw::IRT_EQ and
|
230
|
-
!rhs.kind_of? Fixnum
|
231
|
-
Gecode::Raw.should_receive(:abs).once.with(
|
232
|
-
an_instance_of(Gecode::Raw::Space),
|
233
|
-
an_instance_of(Gecode::Raw::IntVar),
|
234
|
-
rhs, strength, kind)
|
235
|
-
Gecode::Raw.should_receive(:rel).exactly(0).times
|
236
|
-
else
|
237
|
-
Gecode::Raw.should_receive(:abs).once.with(
|
238
|
-
an_instance_of(Gecode::Raw::Space),
|
239
|
-
an_instance_of(Gecode::Raw::IntVar),
|
240
|
-
an_instance_of(Gecode::Raw::IntVar),
|
241
|
-
strength, kind)
|
242
|
-
Gecode::Raw.should_receive(:rel).once.with(
|
243
|
-
an_instance_of(Gecode::Raw::Space),
|
244
|
-
an_instance_of(Gecode::Raw::IntVar),
|
245
|
-
relation, rhs, strength, kind)
|
246
|
-
end
|
247
|
-
else
|
248
|
-
Gecode::Raw.should_receive(:abs).once.with(
|
249
|
-
an_instance_of(Gecode::Raw::Space),
|
250
|
-
an_instance_of(Gecode::Raw::IntVar),
|
251
|
-
an_instance_of(Gecode::Raw::IntVar),
|
252
|
-
strength, kind)
|
253
|
-
Gecode::Raw.should_receive(:rel).once.with(
|
254
|
-
an_instance_of(Gecode::Raw::Space),
|
255
|
-
an_instance_of(Gecode::Raw::IntVar), relation, rhs,
|
256
|
-
an_instance_of(Gecode::Raw::BoolVar),
|
257
|
-
strength, kind)
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
it 'should constrain the absolute value' do
|
264
|
-
@var.must < 0
|
265
|
-
@var.abs.must == 5
|
266
|
-
@model.solve!.var.value.should == -5
|
267
|
-
end
|
268
|
-
|
269
|
-
it_should_behave_like 'arithmetic constraint'
|
270
|
-
end
|
271
|
-
|
272
|
-
describe Gecode::Constraints::Int::Arithmetic, ' (multiplication)' do
|
273
|
-
before do
|
274
|
-
@model = ArithmeticSampleProblem.new
|
275
|
-
@var = @model.var
|
276
|
-
@var2 = @model.var2
|
277
|
-
@stub = @var * @var2
|
278
|
-
@target = @model.var3
|
279
|
-
|
280
|
-
@expect = arithmetic_expectation(:mult, 2)
|
281
|
-
end
|
282
|
-
|
283
|
-
it 'should constrain the value of the multiplication' do
|
284
|
-
(@var * @var2).must == 56
|
285
|
-
sol = @model.solve!
|
286
|
-
[sol.var.value, sol.var2.value].sort.should == [7, 8]
|
287
|
-
end
|
288
|
-
|
289
|
-
it 'should not interfere with other defined multiplication methods' do
|
290
|
-
(@var * :foo).should be_nil
|
291
|
-
end
|
292
|
-
|
293
|
-
it_should_behave_like 'arithmetic constraint'
|
294
|
-
end
|
295
|
-
|
296
|
-
describe Gecode::Constraints::Int::Arithmetic, ' (squared)' do
|
297
|
-
before do
|
298
|
-
@model = ArithmeticSampleProblem.new
|
299
|
-
@var = @model.var
|
300
|
-
@stub = @var.squared
|
301
|
-
@target = @model.var2
|
302
|
-
|
303
|
-
@expect = arithmetic_expectation(:sqr, 1)
|
304
|
-
end
|
305
|
-
|
306
|
-
it 'should constrain the value of the variable squared' do
|
307
|
-
@var.squared.must == 9
|
308
|
-
sol = @model.solve!
|
309
|
-
sol.var.value.abs.should == 3
|
310
|
-
end
|
311
|
-
|
312
|
-
it_should_behave_like 'arithmetic constraint'
|
313
|
-
end
|
314
|
-
|
315
|
-
describe Gecode::Constraints::Int::Arithmetic, ' (square root)' do
|
316
|
-
before do
|
317
|
-
@model = ArithmeticSampleProblem.new
|
318
|
-
@var = @model.var
|
319
|
-
@stub = @var.square_root
|
320
|
-
@target = @model.var2
|
321
|
-
|
322
|
-
@expect = arithmetic_expectation(:sqrt, 1)
|
323
|
-
end
|
324
|
-
|
325
|
-
it 'should constrain the square root of the variable' do
|
326
|
-
@var.square_root.must == 3
|
327
|
-
sol = @model.solve!
|
328
|
-
Math.sqrt(sol.var.value).floor.should == 3
|
329
|
-
end
|
330
|
-
|
331
|
-
it 'should constrain the square root of the variable (2)' do
|
332
|
-
@var.square_root.must == 0
|
333
|
-
sol = @model.solve!
|
334
|
-
Math.sqrt(sol.var.value).floor.should == 0
|
335
|
-
end
|
336
|
-
|
337
|
-
it 'should constrain the square root of the variable (3)' do
|
338
|
-
@var.must < 0
|
339
|
-
@var.square_root.must == 0
|
340
|
-
@model.solve!.should be_nil
|
341
|
-
end
|
342
|
-
|
343
|
-
it 'should round down the square root' do
|
344
|
-
@var.must > 4
|
345
|
-
@var.square_root.must == 2
|
346
|
-
sol = @model.solve!
|
347
|
-
sol.var.value.should be_between(5,8)
|
348
|
-
end
|
349
|
-
|
350
|
-
it_should_behave_like 'arithmetic constraint'
|
351
|
-
end
|
@@ -1,160 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
require File.dirname(__FILE__) + '/constraint_helper'
|
3
|
-
|
4
|
-
class BoolEnumSampleProblem < Gecode::Model
|
5
|
-
attr :bools
|
6
|
-
attr :b1
|
7
|
-
attr :b2
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
@bools = bool_var_array(4)
|
11
|
-
@b1 = bool_var
|
12
|
-
@b2 = bool_var
|
13
|
-
branch_on @bools
|
14
|
-
branch_on wrap_enum([@b1, @b2])
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# Expects @stub, which contains the started constraint and @compute_result
|
19
|
-
# which computes whether the left hand side is true or not.
|
20
|
-
describe 'bool enum relation constraint', :shared => true do
|
21
|
-
it 'should handle being constrained to be true' do
|
22
|
-
@stub.must_be.true
|
23
|
-
@model.solve!
|
24
|
-
@compute_result.call.should be_true
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should handle being constrained to be negated true' do
|
28
|
-
@stub.must_not_be.true
|
29
|
-
@model.solve!
|
30
|
-
@compute_result.call.should_not be_true
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should handle being constrained to be false' do
|
34
|
-
@stub.must_be.false
|
35
|
-
@model.solve!
|
36
|
-
@compute_result.call.should_not be_true
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should handle being constrained to be negated false' do
|
40
|
-
@stub.must_not_be.false
|
41
|
-
@model.solve!
|
42
|
-
@compute_result.call.should be_true
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should handle being constrained to be equal to a variable' do
|
46
|
-
@stub.must_be == @b1
|
47
|
-
@model.solve!
|
48
|
-
@compute_result.call.should == @b1.value
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'should handle being constrained to not be equal to a variable' do
|
52
|
-
@stub.must_not_be == @b1
|
53
|
-
@model.solve!
|
54
|
-
@compute_result.call.should_not == @b1.value
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should handle being constrained to be equal to be a nested expression' do
|
58
|
-
@stub.must_be == (@b1 | @b2) & @b1
|
59
|
-
@model.solve!
|
60
|
-
@compute_result.call.should == (@b1.value | @b2.value) & @b1.value
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should handle being constrained to not be equal to be a nested expression' do
|
64
|
-
@stub.must_not_be == (@b1 | @b2) & @b1
|
65
|
-
@model.solve!
|
66
|
-
@compute_result.call.should_not == (@b1.value | @b2.value) & @b1.value
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe Gecode::Constraints::BoolEnum::Relation, ' (conjunction)' do
|
71
|
-
before do
|
72
|
-
@model = BoolEnumSampleProblem.new
|
73
|
-
@bools = @model.bools
|
74
|
-
@b1 = @model.b1
|
75
|
-
@b2 = @model.b2
|
76
|
-
|
77
|
-
# For constraint option spec.
|
78
|
-
@invoke_options = lambda do |hash|
|
79
|
-
@bools.conjunction.must.equal(@b1, hash)
|
80
|
-
@model.solve!
|
81
|
-
end
|
82
|
-
@expect_options = option_expectation do |strength, kind, reif_var|
|
83
|
-
@model.allow_space_access do
|
84
|
-
if reif_var.nil?
|
85
|
-
Gecode::Raw.should_receive(:rel).once.with(
|
86
|
-
an_instance_of(Gecode::Raw::Space),
|
87
|
-
Gecode::Raw::BOT_AND,
|
88
|
-
an_instance_of(Gecode::Raw::BoolVarArray),
|
89
|
-
an_instance_of(Gecode::Raw::BoolVar),
|
90
|
-
strength, kind)
|
91
|
-
else
|
92
|
-
Gecode::Raw.should_receive(:rel).once.with(
|
93
|
-
an_instance_of(Gecode::Raw::Space),
|
94
|
-
an_instance_of(Gecode::Raw::BoolVar),
|
95
|
-
anything,
|
96
|
-
an_instance_of(Gecode::Raw::BoolVar),
|
97
|
-
anything, anything)
|
98
|
-
Gecode::Raw.should_receive(:rel).once.with(
|
99
|
-
an_instance_of(Gecode::Raw::Space),
|
100
|
-
Gecode::Raw::BOT_AND,
|
101
|
-
an_instance_of(Gecode::Raw::BoolVarArray),
|
102
|
-
reif_var, strength, kind)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
# For bool enum spec.
|
108
|
-
@stub = @bools.conjunction
|
109
|
-
@compute_result = lambda{ @bools.all?{ |b| b.value } }
|
110
|
-
end
|
111
|
-
|
112
|
-
it_should_behave_like 'bool enum relation constraint'
|
113
|
-
it_should_behave_like 'reifiable constraint'
|
114
|
-
end
|
115
|
-
|
116
|
-
describe Gecode::Constraints::BoolEnum::Relation, ' (disjunction)' do
|
117
|
-
before do
|
118
|
-
@model = BoolEnumSampleProblem.new
|
119
|
-
@bools = @model.bools
|
120
|
-
@b1 = @model.b1
|
121
|
-
@b2 = @model.b2
|
122
|
-
|
123
|
-
# For constraint option spec.
|
124
|
-
@invoke_options = lambda do |hash|
|
125
|
-
@bools.disjunction.must.equal(@b1, hash)
|
126
|
-
@model.solve!
|
127
|
-
end
|
128
|
-
@expect_options = option_expectation do |strength, kind, reif_var|
|
129
|
-
@model.allow_space_access do
|
130
|
-
if reif_var.nil?
|
131
|
-
Gecode::Raw.should_receive(:rel).once.with(
|
132
|
-
an_instance_of(Gecode::Raw::Space),
|
133
|
-
Gecode::Raw::BOT_OR,
|
134
|
-
an_instance_of(Gecode::Raw::BoolVarArray),
|
135
|
-
an_instance_of(Gecode::Raw::BoolVar),
|
136
|
-
strength, kind)
|
137
|
-
else
|
138
|
-
Gecode::Raw.should_receive(:rel).once.with(
|
139
|
-
an_instance_of(Gecode::Raw::Space),
|
140
|
-
an_instance_of(Gecode::Raw::BoolVar),
|
141
|
-
anything,
|
142
|
-
an_instance_of(Gecode::Raw::BoolVar),
|
143
|
-
anything, anything)
|
144
|
-
Gecode::Raw.should_receive(:rel).once.with(
|
145
|
-
an_instance_of(Gecode::Raw::Space),
|
146
|
-
Gecode::Raw::BOT_OR,
|
147
|
-
an_instance_of(Gecode::Raw::BoolVarArray),
|
148
|
-
reif_var, strength, kind)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
# For bool enum spec.
|
154
|
-
@stub = @bools.disjunction
|
155
|
-
@compute_result = lambda{ @bools.any?{ |b| b.value } }
|
156
|
-
end
|
157
|
-
|
158
|
-
it_should_behave_like 'bool enum relation constraint'
|
159
|
-
it_should_behave_like 'reifiable constraint'
|
160
|
-
end
|
@@ -1,157 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
require File.dirname(__FILE__) + '/constraint_helper'
|
3
|
-
|
4
|
-
describe Gecode::Constraints::Set::Cardinality, ' (range)' do
|
5
|
-
before do
|
6
|
-
@model = Gecode::Model.new
|
7
|
-
@set = @model.set_var([], 0..10)
|
8
|
-
@model.branch_on @model.wrap_enum([@set])
|
9
|
-
@range = 1..2
|
10
|
-
@three_dot_range = 1...2
|
11
|
-
|
12
|
-
@invoke_options = lambda do |hash|
|
13
|
-
@set.size.must_be.in(@range, hash)
|
14
|
-
end
|
15
|
-
|
16
|
-
@invoke = lambda do |rhs|
|
17
|
-
@set.size.must_be.in(rhs)
|
18
|
-
@model.solve!
|
19
|
-
end
|
20
|
-
@expect = lambda do |rhs|
|
21
|
-
@model.allow_space_access do
|
22
|
-
Gecode::Raw.should_receive(:cardinality).once.with(
|
23
|
-
an_instance_of(Gecode::Raw::Space),
|
24
|
-
an_instance_of(Gecode::Raw::SetVar), rhs.first, rhs.last)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should translate cardinality constraints with ranges' do
|
30
|
-
@expect.call(@range)
|
31
|
-
@invoke.call(@range)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should translate cardinality constraints with three dot range domains' do
|
35
|
-
@expect.call(@three_dot_range)
|
36
|
-
@invoke.call(@three_dot_range)
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should constrain the cardinality of a set' do
|
40
|
-
@set.size.must_be.in @range
|
41
|
-
@model.solve!
|
42
|
-
@range.should include(@set.value.size)
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should raise error if the right hand side is not a range' do
|
46
|
-
lambda{ @set.size.must_be.in 'hello' }.should raise_error(TypeError)
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'should not shadow the integer variable domain constrain' do
|
50
|
-
Gecode::Raw.should_receive(:dom).with(
|
51
|
-
an_instance_of(Gecode::Raw::Space),
|
52
|
-
an_instance_of(Gecode::Raw::IntVar), 0, 11, Gecode::Raw::ICL_DEF,
|
53
|
-
Gecode::Raw::PK_DEF)
|
54
|
-
Gecode::Raw.should_receive(:dom).with(
|
55
|
-
an_instance_of(Gecode::Raw::Space),
|
56
|
-
an_instance_of(Gecode::Raw::IntVar), an_instance_of(Gecode::Raw::IntSet),
|
57
|
-
an_instance_of(Gecode::Raw::BoolVar), Gecode::Raw::ICL_DEF,
|
58
|
-
Gecode::Raw::PK_DEF)
|
59
|
-
@set.size.must_not_be.in [1,3]
|
60
|
-
@model.solve!
|
61
|
-
end
|
62
|
-
|
63
|
-
it_should_behave_like 'non-reifiable set constraint'
|
64
|
-
end
|
65
|
-
|
66
|
-
describe Gecode::Constraints::Set::Cardinality, ' (composite)' do
|
67
|
-
before do
|
68
|
-
@model = Gecode::Model.new
|
69
|
-
@set = @model.set_var([], 0..10)
|
70
|
-
@target = @var = @model.int_var(0..11)
|
71
|
-
@model.branch_on @model.wrap_enum([@set])
|
72
|
-
@model.branch_on @model.wrap_enum([@var])
|
73
|
-
|
74
|
-
@invoke = lambda do |rhs|
|
75
|
-
@set.size.must == rhs
|
76
|
-
@model.solve!
|
77
|
-
end
|
78
|
-
@expect = lambda do |relation, rhs, strength, kind, reif_var, negated|
|
79
|
-
@model.allow_space_access do
|
80
|
-
rhs = an_instance_of(Gecode::Raw::IntVar) if rhs.respond_to? :bind
|
81
|
-
if reif_var.nil?
|
82
|
-
if !negated and relation == Gecode::Raw::IRT_EQ and
|
83
|
-
!rhs.kind_of? Fixnum
|
84
|
-
Gecode::Raw.should_receive(:cardinality).once.with(
|
85
|
-
an_instance_of(Gecode::Raw::Space),
|
86
|
-
an_instance_of(Gecode::Raw::SetVar), rhs)
|
87
|
-
Gecode::Raw.should_receive(:rel).exactly(0).times
|
88
|
-
else
|
89
|
-
Gecode::Raw.should_receive(:cardinality).once.with(
|
90
|
-
an_instance_of(Gecode::Raw::Space),
|
91
|
-
an_instance_of(Gecode::Raw::SetVar),
|
92
|
-
an_instance_of(Gecode::Raw::IntVar))
|
93
|
-
Gecode::Raw.should_receive(:rel).once.with(
|
94
|
-
an_instance_of(Gecode::Raw::Space),
|
95
|
-
an_instance_of(Gecode::Raw::IntVar), relation, rhs,
|
96
|
-
strength, kind)
|
97
|
-
end
|
98
|
-
else
|
99
|
-
Gecode::Raw.should_receive(:cardinality).once.with(
|
100
|
-
an_instance_of(Gecode::Raw::Space),
|
101
|
-
an_instance_of(Gecode::Raw::SetVar),
|
102
|
-
an_instance_of(Gecode::Raw::IntVar))
|
103
|
-
Gecode::Raw.should_receive(:rel).once.with(
|
104
|
-
an_instance_of(Gecode::Raw::Space),
|
105
|
-
an_instance_of(Gecode::Raw::IntVar), relation, rhs,
|
106
|
-
an_instance_of(Gecode::Raw::BoolVar),
|
107
|
-
strength, kind)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
# For composite spec.
|
113
|
-
@invoke_relation = lambda do |relation, target, negated|
|
114
|
-
if negated
|
115
|
-
@set.size.must_not.send(relation, target)
|
116
|
-
else
|
117
|
-
@set.size.must.send(relation, target)
|
118
|
-
end
|
119
|
-
@model.solve!
|
120
|
-
end
|
121
|
-
@expect_relation = lambda do |relation, target, negated|
|
122
|
-
@expect.call(relation, target, Gecode::Raw::ICL_DEF, Gecode::Raw::PK_DEF,
|
123
|
-
nil, negated)
|
124
|
-
end
|
125
|
-
|
126
|
-
# For options spec.
|
127
|
-
@invoke_options = lambda do |hash|
|
128
|
-
@set.size.must_be.less_than_or_equal_to(17, hash)
|
129
|
-
@model.solve!
|
130
|
-
end
|
131
|
-
@expect_options = option_expectation do |strength, kind, reif_var|
|
132
|
-
@expect.call(Gecode::Raw::IRT_LQ, 17, strength, kind, reif_var, false)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
it 'should constrain the cardinality of a set' do
|
137
|
-
@set.size.must == @var
|
138
|
-
@model.solve!
|
139
|
-
@set.value.size.should == @var.value
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'should constrain the cardinality of a set (2)' do
|
143
|
-
@set.size.must == 2
|
144
|
-
@model.solve!.should_not be_nil
|
145
|
-
@set.value.size.should == 2
|
146
|
-
end
|
147
|
-
|
148
|
-
it 'should constrain the cardinality of a set (3)' do
|
149
|
-
@set.size.must == @var
|
150
|
-
@var.must == 2
|
151
|
-
@model.solve!
|
152
|
-
@set.value.size.should == 2
|
153
|
-
end
|
154
|
-
|
155
|
-
it_should_behave_like 'reifiable constraint'
|
156
|
-
it_should_behave_like 'composite constraint'
|
157
|
-
end
|