gecoder-with-gecode 0.8.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,264 +1,234 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
# Every constraint should have a spec that specs the following:
|
|
4
|
+
#
|
|
5
|
+
# * An example where the constraint is used to constrain a sample
|
|
6
|
+
# problem (and one for negation if deemed necessary).
|
|
7
|
+
# * should_behave_like [non-reifiable|reifiable] constraint (possibly
|
|
8
|
+
# indirect).
|
|
9
|
+
# * Those constraints that do not support negation must
|
|
10
|
+
# should_behave_like 'non-negatable constraint'
|
|
11
|
+
#
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# These specs assume that the following variables are defined:
|
|
15
|
+
# [@expect] A proc that creates an expectation corresponding to
|
|
16
|
+
# constraint. It should take three parameter. The
|
|
17
|
+
# first is an array of operands of types specified by
|
|
18
|
+
# @types. The second is whether or not the constraint
|
|
19
|
+
# should be negated. The third is a hash that can
|
|
20
|
+
# have values for the keys :icl (ICL_*), :pk (PK_*),
|
|
21
|
+
# and :bool (bound reification variable). Any values
|
|
22
|
+
# not provided are assumed to be default values (nil
|
|
23
|
+
# in the case of :bool).
|
|
24
|
+
# [@invoke] A proc that invokes the constraint to be tested, It
|
|
25
|
+
# should have arity arity(@types) + 1. The first
|
|
26
|
+
# parameter is a constraint receiver (type decided by
|
|
27
|
+
# @types). The next arity(@types)-1 parameters are
|
|
28
|
+
# given operands of types specified by @types. The
|
|
29
|
+
# last parameter is a hash of options (with at most
|
|
30
|
+
# the keys :strength, :kind and :reify)..
|
|
31
|
+
# [@types] An array of symbols signaling what types of
|
|
32
|
+
# arguments @ accepts. The symbols
|
|
33
|
+
# must be one of: :int, :bool, :set, :int_enum,
|
|
34
|
+
# :bool_enum, :set_enum, :fixnum_enum.
|
|
14
35
|
# [@model] The model instance that contains the aspects being tested.
|
|
15
|
-
# [@expect_relation] A method that takes a relation, right hand side, and
|
|
16
|
-
# whether it's negated, as arguments and sets up the
|
|
17
|
-
# corresponding expectations.
|
|
18
|
-
# [@invoke_relation] A method that takes a relation, right hand side, and
|
|
19
|
-
# whether it's negated, as arguments and adds the
|
|
20
|
-
# corresponding constraint and invokes it.
|
|
21
|
-
# [@target] A legal right hand side that can be used as argument to
|
|
22
|
-
# the above two methods.
|
|
23
36
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
@invoke_options.call(:strength => name)
|
|
37
|
+
def expect(variables, options)
|
|
38
|
+
bool = options[:bool]
|
|
39
|
+
bool = @model.allow_space_access{ bool.bind } unless bool.nil?
|
|
40
|
+
args = @model.allow_space_access do
|
|
41
|
+
variables.map do |var|
|
|
42
|
+
if var.respond_to? :bind
|
|
43
|
+
var.bind
|
|
44
|
+
else
|
|
45
|
+
var.bind_array
|
|
46
|
+
end
|
|
35
47
|
end
|
|
36
48
|
end
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
49
|
+
args << [options[:icl] || Gecode::Raw::ICL_DEF,
|
|
50
|
+
options[:pk] || Gecode::Raw::PK_DEF]
|
|
51
|
+
args << bool
|
|
52
|
+
@expect.call(*args)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def invoke(operands, options)
|
|
56
|
+
base_op = operands.first
|
|
57
|
+
if options.delete(:negate)
|
|
58
|
+
receiver = base_op.must_not
|
|
59
|
+
else
|
|
60
|
+
receiver = base_op.must
|
|
41
61
|
end
|
|
42
|
-
|
|
43
|
-
|
|
62
|
+
args = ([receiver] + operands[1..-1]) << options
|
|
63
|
+
@invoke.call(*args)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe 'reifiable constraint', :shared => true do
|
|
67
|
+
it_should_behave_like 'constraint with default options'
|
|
68
|
+
it_should_behave_like 'constraint with reification option'
|
|
69
|
+
it_should_behave_like 'constraint'
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe 'non-reifiable constraint', :shared => true do
|
|
73
|
+
it 'should raise errors if reification is used' do
|
|
74
|
+
operands, variables = produce_general_arguments(@types)
|
|
44
75
|
lambda do
|
|
45
|
-
|
|
76
|
+
invoke(operands, :reify => @model.bool_var)
|
|
46
77
|
end.should raise_error(ArgumentError)
|
|
47
78
|
end
|
|
79
|
+
|
|
80
|
+
it_should_behave_like 'constraint with default options'
|
|
81
|
+
it_should_behave_like 'constraint'
|
|
48
82
|
end
|
|
49
83
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
:speed => Gecode::Raw::PK_SPEED,
|
|
54
|
-
:memory => Gecode::Raw::PK_MEMORY
|
|
55
|
-
}.each_pair do |name, gecode_value|
|
|
56
|
-
it "should translate propagation kind #{name}" do
|
|
57
|
-
@expect_options.call(:pk => gecode_value)
|
|
58
|
-
@invoke_options.call(:kind => name)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it 'should default to using default as propagation kind' do
|
|
63
|
-
@expect_options.call({})
|
|
64
|
-
@invoke_options.call({})
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it 'should raise errors for unrecognized propagation kinds' do
|
|
84
|
+
describe 'non-negatable constraint', :shared => true do
|
|
85
|
+
it 'should raise errors if negation is used' do
|
|
86
|
+
operands, variables = produce_general_arguments(@types)
|
|
68
87
|
lambda do
|
|
69
|
-
|
|
70
|
-
end.should raise_error(
|
|
88
|
+
invoke(operands, :negate => true)
|
|
89
|
+
end.should raise_error(Gecode::MissingConstraintError)
|
|
71
90
|
end
|
|
72
91
|
end
|
|
73
92
|
|
|
93
|
+
describe 'constraint', :shared => true do
|
|
94
|
+
it 'should raise errors if parameters of the incorrect type are given' do
|
|
95
|
+
operands, variables = produce_general_arguments(@types)
|
|
96
|
+
(1...operands.size).each do |i|
|
|
97
|
+
bogus_operands = operands.clone
|
|
98
|
+
bogus_operands[i] = Object.new
|
|
99
|
+
lambda do
|
|
100
|
+
invoke(bogus_operands, {})
|
|
101
|
+
end.should raise_error(TypeError)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
74
105
|
|
|
75
|
-
# Requires @invoke_options and @expect_options.
|
|
76
106
|
describe 'constraint with reification option', :shared => true do
|
|
77
107
|
it 'should translate reification' do
|
|
108
|
+
operands, variables = produce_general_arguments(@types)
|
|
78
109
|
var = @model.bool_var
|
|
79
|
-
|
|
80
|
-
|
|
110
|
+
expect(variables, :bool => var)
|
|
111
|
+
invoke(operands, :reify => var)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it 'should translate reification with arbitrary bool operand' do
|
|
115
|
+
operands, variables = produce_general_arguments(@types)
|
|
116
|
+
op, bool_var = general_bool_operand(@model)
|
|
117
|
+
expect(variables, :bool => bool_var)
|
|
118
|
+
invoke(operands, :reify => op)
|
|
81
119
|
end
|
|
82
120
|
|
|
83
121
|
it 'should raise errors for reification variables of incorrect type' do
|
|
122
|
+
operands, variables = produce_general_arguments(@types)
|
|
84
123
|
lambda do
|
|
85
|
-
|
|
124
|
+
invoke(operands, :reify => 'foo')
|
|
86
125
|
end.should raise_error(TypeError)
|
|
87
126
|
end
|
|
88
127
|
end
|
|
89
128
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
it_should_behave_like 'constraint with reification option'
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
# Requires @invoke_options, @expect_options and @model.
|
|
97
|
-
describe 'non-reifiable constraint', :shared => true do
|
|
98
|
-
it 'should raise errors if reification is used' do
|
|
129
|
+
describe 'constraint with default options', :shared => true do
|
|
130
|
+
it 'should raise errors for unrecognized options' do
|
|
131
|
+
operands, variables = produce_general_arguments(@types)
|
|
99
132
|
lambda do
|
|
100
|
-
|
|
133
|
+
invoke(operands, :does_not_exist => :foo)
|
|
101
134
|
end.should raise_error(ArgumentError)
|
|
102
135
|
end
|
|
103
|
-
|
|
104
|
-
it_should_behave_like 'constraint with default options'
|
|
105
|
-
end
|
|
106
136
|
|
|
107
|
-
# Requires @invoke_options and @expect_options.
|
|
108
|
-
describe 'constraint with default options', :shared => true do
|
|
109
|
-
it 'should raise errors for unrecognized options' do
|
|
110
|
-
lambda{ @invoke_options.call(:does_not_exist => :foo) }.should(
|
|
111
|
-
raise_error(ArgumentError))
|
|
112
|
-
end
|
|
113
|
-
|
|
114
137
|
it_should_behave_like 'constraint with strength option'
|
|
115
138
|
it_should_behave_like 'constraint with kind option'
|
|
116
139
|
end
|
|
117
140
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
it "should translate #{relation} with variable target" do
|
|
129
|
-
@expect_relation.call(type, @target, false)
|
|
130
|
-
@invoke_relation.call(relation, @target, false)
|
|
141
|
+
describe 'constraint with strength option', :shared => true do
|
|
142
|
+
{ :default => Gecode::Raw::ICL_DEF,
|
|
143
|
+
:value => Gecode::Raw::ICL_VAL,
|
|
144
|
+
:bounds => Gecode::Raw::ICL_BND,
|
|
145
|
+
:domain => Gecode::Raw::ICL_DOM
|
|
146
|
+
}.each_pair do |name, gecode_value|
|
|
147
|
+
it "should translate propagation strength #{name}" do
|
|
148
|
+
operands, variables = produce_general_arguments(@types)
|
|
149
|
+
expect(variables, :icl => gecode_value)
|
|
150
|
+
invoke(operands, :strength => name)
|
|
131
151
|
end
|
|
132
152
|
end
|
|
133
153
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
end
|
|
154
|
+
it 'should default to using default as propagation strength' do
|
|
155
|
+
operands, variables = produce_general_arguments(@types)
|
|
156
|
+
expect(variables, {})
|
|
157
|
+
invoke(operands, {})
|
|
139
158
|
end
|
|
140
159
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
@expect_relation.call(type, @target, true)
|
|
144
|
-
@invoke_relation.call(relation, @target, true)
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
it 'should raise error if the target is of the wrong type' do
|
|
160
|
+
it 'should raise errors for unrecognized propagation strengths' do
|
|
161
|
+
operands, variables = produce_general_arguments(@types)
|
|
149
162
|
lambda do
|
|
150
|
-
|
|
151
|
-
end.should raise_error(
|
|
163
|
+
invoke(operands, :strength => :does_not_exist)
|
|
164
|
+
end.should raise_error(ArgumentError)
|
|
152
165
|
end
|
|
153
166
|
end
|
|
154
167
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
Gecode::Constraints::Util::SET_RELATION_TYPES.each_pair do |relation, type|
|
|
165
|
-
it "should translate #{relation} with variable target" do
|
|
166
|
-
@expect_relation.call(type, @target, false)
|
|
167
|
-
@invoke_relation.call(relation, @target, false)
|
|
168
|
+
describe 'constraint with kind option', :shared => true do
|
|
169
|
+
{ :default => Gecode::Raw::PK_DEF,
|
|
170
|
+
:speed => Gecode::Raw::PK_SPEED,
|
|
171
|
+
:memory => Gecode::Raw::PK_MEMORY
|
|
172
|
+
}.each_pair do |name, gecode_value|
|
|
173
|
+
it "should translate propagation kind #{name}" do
|
|
174
|
+
operands, variables = produce_general_arguments(@types)
|
|
175
|
+
expect(variables, :pk => gecode_value)
|
|
176
|
+
invoke(operands, :kind => name)
|
|
168
177
|
end
|
|
169
178
|
end
|
|
170
179
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
end
|
|
180
|
+
it 'should default to using default as propagation kind' do
|
|
181
|
+
operands, variables = produce_general_arguments(@types)
|
|
182
|
+
expect(variables, {})
|
|
183
|
+
invoke(operands, {})
|
|
176
184
|
end
|
|
177
185
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
@expect_relation.call(type, @target, true)
|
|
181
|
-
@invoke_relation.call(relation, @target, true)
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
it 'should raise error if the target is of the wrong type' do
|
|
186
|
+
it 'should raise errors for unrecognized propagation kinds' do
|
|
187
|
+
operands, variables = produce_general_arguments(@types)
|
|
186
188
|
lambda do
|
|
187
|
-
|
|
188
|
-
end.should raise_error(
|
|
189
|
+
invoke(operands, :kind => :does_not_exist)
|
|
190
|
+
end.should raise_error(ArgumentError)
|
|
189
191
|
end
|
|
190
192
|
end
|
|
191
193
|
|
|
192
194
|
describe 'set constraint', :shared => true do
|
|
193
195
|
it 'should not accept strength option' do
|
|
196
|
+
operands, variables = produce_general_arguments(@types)
|
|
194
197
|
lambda do
|
|
195
|
-
|
|
198
|
+
invoke(operands, :strength => :default)
|
|
196
199
|
end.should raise_error(ArgumentError)
|
|
197
200
|
end
|
|
198
201
|
|
|
199
202
|
it 'should not accept kind option' do
|
|
203
|
+
operands, variables = produce_general_arguments(@types)
|
|
200
204
|
lambda do
|
|
201
|
-
|
|
205
|
+
invoke(operands, :kind => :default)
|
|
202
206
|
end.should raise_error(ArgumentError)
|
|
203
207
|
end
|
|
204
208
|
|
|
205
209
|
it 'should raise errors for unrecognized options' do
|
|
210
|
+
operands, variables = produce_general_arguments(@types)
|
|
206
211
|
lambda do
|
|
207
|
-
|
|
212
|
+
invoke(operands, :does_not_exist => :foo)
|
|
208
213
|
end.should raise_error(ArgumentError)
|
|
209
214
|
end
|
|
215
|
+
|
|
216
|
+
it_should_behave_like 'constraint'
|
|
210
217
|
end
|
|
211
218
|
|
|
212
|
-
# Requires @invoke_options and @model.
|
|
213
219
|
describe 'non-reifiable set constraint', :shared => true do
|
|
214
220
|
it 'should not accept reification option' do
|
|
215
221
|
bool = @model.bool_var
|
|
222
|
+
operands, variables = produce_general_arguments(@types)
|
|
216
223
|
lambda do
|
|
217
|
-
|
|
224
|
+
invoke(operands, :reify => bool)
|
|
218
225
|
end.should raise_error(ArgumentError)
|
|
219
226
|
end
|
|
220
227
|
|
|
221
228
|
it_should_behave_like 'set constraint'
|
|
222
229
|
end
|
|
223
230
|
|
|
224
|
-
# Requires @invoke_options, @expect_options and @model.
|
|
225
231
|
describe 'reifiable set constraint', :shared => true do
|
|
226
232
|
it_should_behave_like 'set constraint'
|
|
227
233
|
it_should_behave_like 'constraint with reification option'
|
|
228
234
|
end
|
|
229
|
-
|
|
230
|
-
# Help methods for the GecodeR specs.
|
|
231
|
-
module GecodeR::Specs
|
|
232
|
-
module SetHelper
|
|
233
|
-
module_function
|
|
234
|
-
|
|
235
|
-
# Returns the arguments that should be used in a partial mock to expect the
|
|
236
|
-
# specified constant set (possibly an array of arguments).
|
|
237
|
-
def expect_constant_set(constant_set)
|
|
238
|
-
if constant_set.kind_of? Range
|
|
239
|
-
return constant_set.first, constant_set.last
|
|
240
|
-
elsif constant_set.kind_of? Fixnum
|
|
241
|
-
constant_set
|
|
242
|
-
else
|
|
243
|
-
an_instance_of(Gecode::Raw::IntSet)
|
|
244
|
-
end
|
|
245
|
-
end
|
|
246
|
-
end
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
# Helper for creating @expect_option. Creates a method which takes a hash that
|
|
250
|
-
# may have values for the keys :icl (ICL_*), :pk (PK_*), and :bool (reification
|
|
251
|
-
# variable). Expectations corresponding to the hash values are given to the
|
|
252
|
-
# specified block in the order of icl, pk and bool. Default values are provided
|
|
253
|
-
# if the hash doesn't specify anything else.
|
|
254
|
-
def option_expectation(&block)
|
|
255
|
-
lambda do |hash|
|
|
256
|
-
bool = hash[:bool]
|
|
257
|
-
# We loosen the expectation some to avoid practical problems with expecting
|
|
258
|
-
# specific variables not under our control.
|
|
259
|
-
bool = an_instance_of(Gecode::Raw::BoolVar) unless bool.nil?
|
|
260
|
-
yield(hash[:icl] || Gecode::Raw::ICL_DEF,
|
|
261
|
-
hash[:pk] || Gecode::Raw::PK_DEF,
|
|
262
|
-
bool)
|
|
263
|
-
end
|
|
264
|
-
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'constraint receiver', :shared => true do
|
|
4
|
+
it 'should raise error unless an operand of the correct type is given as lhs' do
|
|
5
|
+
lambda do
|
|
6
|
+
op = Object.new
|
|
7
|
+
class <<op
|
|
8
|
+
include Gecode::Operand
|
|
9
|
+
end
|
|
10
|
+
@receiver.new(@model, {:lhs => op, :negate => false})
|
|
11
|
+
end.should raise_error(TypeError)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe Gecode::ConstraintReceiver do
|
|
16
|
+
before do
|
|
17
|
+
@model = Gecode::Model.new
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'should raise error if the negate params is not given' do
|
|
21
|
+
lambda do
|
|
22
|
+
Gecode::ConstraintReceiver.new(@model, {:lhs => nil})
|
|
23
|
+
end.should raise_error(ArgumentError)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should raise error if the lhs params is not given' do
|
|
27
|
+
lambda do
|
|
28
|
+
Gecode::ConstraintReceiver.new(@model, {:lhs => nil})
|
|
29
|
+
end.should raise_error(ArgumentError)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe Gecode::Int::IntConstraintReceiver, ' (not subclassed)' do
|
|
34
|
+
before do
|
|
35
|
+
@model = Gecode::Model.new
|
|
36
|
+
@receiver = Gecode::Int::IntConstraintReceiver
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it_should_behave_like 'constraint receiver'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe Gecode::IntEnum::IntEnumConstraintReceiver do
|
|
43
|
+
before do
|
|
44
|
+
@model = Gecode::Model.new
|
|
45
|
+
@receiver = Gecode::IntEnum::IntEnumConstraintReceiver
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it_should_behave_like 'constraint receiver'
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe Gecode::Bool::BoolConstraintReceiver do
|
|
52
|
+
before do
|
|
53
|
+
@model = Gecode::Model.new
|
|
54
|
+
@receiver = Gecode::Bool::BoolConstraintReceiver
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it_should_behave_like 'constraint receiver'
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe Gecode::BoolEnum::BoolEnumConstraintReceiver do
|
|
61
|
+
before do
|
|
62
|
+
@model = Gecode::Model.new
|
|
63
|
+
@receiver = Gecode::BoolEnum::BoolEnumConstraintReceiver
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it_should_behave_like 'constraint receiver'
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
describe Gecode::Set::SetConstraintReceiver do
|
|
70
|
+
before do
|
|
71
|
+
@model = Gecode::Model.new
|
|
72
|
+
@receiver = Gecode::Set::SetConstraintReceiver
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it_should_behave_like 'constraint receiver'
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe Gecode::SelectedSet::SelectedSetConstraintReceiver do
|
|
79
|
+
before do
|
|
80
|
+
@model = Gecode::Model.new
|
|
81
|
+
@receiver = Gecode::SelectedSet::SelectedSetConstraintReceiver
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it_should_behave_like 'constraint receiver'
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
describe Gecode::SetElements::SetElementsConstraintReceiver do
|
|
88
|
+
before do
|
|
89
|
+
@model = Gecode::Model.new
|
|
90
|
+
@receiver = Gecode::SetElements::SetElementsConstraintReceiver
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it_should_behave_like 'constraint receiver'
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
describe Gecode::SetEnum::SetEnumConstraintReceiver do
|
|
97
|
+
before do
|
|
98
|
+
@model = Gecode::Model.new
|
|
99
|
+
@receiver = Gecode::SetEnum::SetEnumConstraintReceiver
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it_should_behave_like 'constraint receiver'
|
|
103
|
+
end
|
|
@@ -1,83 +1,26 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
2
|
|
|
3
|
-
describe Gecode::
|
|
4
|
-
it 'should raise error if it doesn\'t get all parameters for initialization' do
|
|
5
|
-
lambda do
|
|
6
|
-
Gecode::Constraints::Expression.new(Gecode::Model.new, :negate => false)
|
|
7
|
-
end.should raise_error(ArgumentError)
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe Gecode::Constraints::IntEnum::Expression do
|
|
12
|
-
it 'should raise error unless lhs is an int enum' do
|
|
13
|
-
lambda do
|
|
14
|
-
Gecode::Constraints::IntEnum::Expression.new(Gecode::Model.new,
|
|
15
|
-
:lhs => 'foo', :negate => false)
|
|
16
|
-
end.should raise_error(TypeError)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe Gecode::Constraints::BoolEnum::Expression do
|
|
21
|
-
it 'should raise error unless lhs is a bool enum' do
|
|
22
|
-
lambda do
|
|
23
|
-
Gecode::Constraints::BoolEnum::Expression.new(Gecode::Model.new,
|
|
24
|
-
:lhs => 'foo', :negate => false)
|
|
25
|
-
end.should raise_error(TypeError)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
describe Gecode::Constraints::SetEnum::Expression do
|
|
30
|
-
it 'should raise error unless lhs is a set enum' do
|
|
31
|
-
lambda do
|
|
32
|
-
Gecode::Constraints::SetEnum::Expression.new(Gecode::Model.new,
|
|
33
|
-
:lhs => 'foo', :negate => false)
|
|
34
|
-
end.should raise_error(TypeError)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe Gecode::Constraints::Int::CompositeStub, ' (not subclassed)' do
|
|
39
|
-
before do
|
|
40
|
-
@con = Gecode::Constraints::Int::CompositeStub.new(Gecode::Model.new, {})
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it 'should raise error when calling #constrain_equal' do
|
|
44
|
-
lambda do
|
|
45
|
-
@con.instance_eval{ constrain_equal(nil, {}, false) }
|
|
46
|
-
end.should raise_error(NoMethodError)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
describe Gecode::Constraints::Constraint, ' (not subclassed)' do
|
|
3
|
+
describe Gecode::Constraint, ' (not subclassed)' do
|
|
51
4
|
before do
|
|
52
|
-
@con = Gecode::
|
|
5
|
+
@con = Gecode::Constraint.new(Gecode::Model.new, {})
|
|
53
6
|
end
|
|
54
7
|
|
|
55
8
|
it 'should raise error when calling #post because it\'s not overridden' do
|
|
56
|
-
lambda{ @con.post }.should raise_error(
|
|
9
|
+
lambda{ @con.post }.should raise_error(NotImplementedError)
|
|
57
10
|
end
|
|
58
11
|
end
|
|
59
12
|
|
|
60
|
-
describe Gecode::
|
|
13
|
+
describe Gecode::Util do
|
|
61
14
|
it 'should raise error when giving incorrect set to #constant_set_to_params' do
|
|
62
15
|
lambda do
|
|
63
|
-
Gecode::
|
|
16
|
+
Gecode::Util.constant_set_to_params('hello')
|
|
64
17
|
end.should raise_error(TypeError)
|
|
65
18
|
end
|
|
66
19
|
|
|
67
20
|
it 'should raise error when giving incorrect set to #constant_set_to_int_set' do
|
|
68
21
|
lambda do
|
|
69
|
-
Gecode::
|
|
22
|
+
Gecode::Util.constant_set_to_int_set('hello')
|
|
70
23
|
end.should raise_error(TypeError)
|
|
71
24
|
end
|
|
72
25
|
end
|
|
73
26
|
|
|
74
|
-
describe Gecode::Constraints::CompositeExpression do
|
|
75
|
-
it 'should raise error if a method doesn\'t exist' do
|
|
76
|
-
expression = Gecode::Constraints::CompositeExpression.new(
|
|
77
|
-
Gecode::Constraints::Int::Expression, Gecode::FreeIntVar,
|
|
78
|
-
lambda{ }, Gecode::Model.new, {:lhs => nil, :negate => false}){}
|
|
79
|
-
lambda do
|
|
80
|
-
expression.this_method_does_not_exist
|
|
81
|
-
end.should raise_error(NoMethodError)
|
|
82
|
-
end
|
|
83
|
-
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../property_helper'
|
|
2
|
+
|
|
3
|
+
class FixnumElementSampleProblem < Gecode::Model
|
|
4
|
+
attr :prices
|
|
5
|
+
attr :store
|
|
6
|
+
attr :price
|
|
7
|
+
|
|
8
|
+
def initialize
|
|
9
|
+
prices = [17, 63, 45, 63]
|
|
10
|
+
@prices = wrap_enum(prices)
|
|
11
|
+
@store = int_var(0...prices.size)
|
|
12
|
+
@price = int_var(prices)
|
|
13
|
+
branch_on @store
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe Gecode::FixnumEnum::Element do
|
|
18
|
+
before do
|
|
19
|
+
@model = FixnumElementSampleProblem.new
|
|
20
|
+
@price = @model.price
|
|
21
|
+
@store = @model.store
|
|
22
|
+
@enum = @model.prices
|
|
23
|
+
|
|
24
|
+
# For int operand producing property spec.
|
|
25
|
+
@property_types = [:fixnum_enum, :int]
|
|
26
|
+
@select_property = lambda do |fixnum_enum, int|
|
|
27
|
+
fixnum_enum[int]
|
|
28
|
+
end
|
|
29
|
+
@selected_property = @enum[@store]
|
|
30
|
+
@constraint_class = Gecode::BlockConstraint
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'should not disturb normal array access' do
|
|
34
|
+
@enum[2].should_not be_nil
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'should constrain the selected element' do
|
|
38
|
+
@enum[@store].must == @enum[2]
|
|
39
|
+
@model.solve!.should_not be_nil
|
|
40
|
+
@store.value.should equal(2)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'should be translated into an element constraint' do
|
|
44
|
+
@enum[@store].must == @price
|
|
45
|
+
@model.allow_space_access do
|
|
46
|
+
Gecode::Raw.should_receive(:element).once.with(
|
|
47
|
+
an_instance_of(Gecode::Raw::Space),
|
|
48
|
+
an_instance_of(Array),
|
|
49
|
+
@store.bind, @price.bind,
|
|
50
|
+
Gecode::Raw::ICL_DEF,
|
|
51
|
+
Gecode::Raw::PK_DEF)
|
|
52
|
+
end
|
|
53
|
+
@model.solve!
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it_should_behave_like(
|
|
57
|
+
'property that produces int operand by short circuiting equality')
|
|
58
|
+
end
|