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
|
@@ -13,9 +13,9 @@ module Gecode
|
|
|
13
13
|
|
|
14
14
|
def inspect
|
|
15
15
|
if assigned?
|
|
16
|
-
"#<#{self.class} #{
|
|
16
|
+
"#<#{self.class} #{domain_string}>"
|
|
17
17
|
else
|
|
18
|
-
"#<#{self.class} #{
|
|
18
|
+
"#<#{self.class} #{domain_string}>"
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -36,11 +36,11 @@ module Gecode
|
|
|
36
36
|
|
|
37
37
|
# Creates a class for a free variable that can be bound into the specified
|
|
38
38
|
# class using the specified method in a space.
|
|
39
|
-
def Gecode::FreeVar(bound_class, space_bind_method)
|
|
39
|
+
def Gecode::FreeVar(bound_class, space_bind_method) #:nodoc:
|
|
40
40
|
clazz = Class.new(FreeVarBase)
|
|
41
41
|
clazz.class_eval <<-"end_method_definitions"
|
|
42
|
-
# Binds the
|
|
43
|
-
# returning the bound
|
|
42
|
+
# Binds the variable to the currently active space of the model,
|
|
43
|
+
# returning the bound variable.
|
|
44
44
|
def bind
|
|
45
45
|
active_space.method(:#{space_bind_method}).call(@index)
|
|
46
46
|
end
|
|
@@ -64,12 +64,25 @@ module Gecode
|
|
|
64
64
|
return clazz
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
# Describes an integer variable.
|
|
69
|
-
#
|
|
70
|
-
# An integer variable
|
|
71
|
-
#
|
|
72
|
-
|
|
67
|
+
IntVar = FreeVar(Gecode::Raw::IntVar, :int_var)
|
|
68
|
+
# Describes an integer variable.
|
|
69
|
+
#
|
|
70
|
+
# An integer variable can take the value of any integer in its
|
|
71
|
+
# domain, which is specified upon constructing the variable and
|
|
72
|
+
# further constrained by placing constraints on the variable.
|
|
73
|
+
# An integer variable is said to be assigned once the domain only
|
|
74
|
+
# contains a single element, at which point #value can be used to
|
|
75
|
+
# retrieve the value.
|
|
76
|
+
#
|
|
77
|
+
# Integer variables are integer operands and hence respond to
|
|
78
|
+
# everything that Gecode::Int::IntOperand responds to.
|
|
79
|
+
# Any constraint found in
|
|
80
|
+
# Gecode::Int::IntConstraintReceiver can thereby be
|
|
81
|
+
# placed on integer variables.
|
|
82
|
+
class IntVar
|
|
83
|
+
include Gecode::Int::IntOperand
|
|
84
|
+
attr :model
|
|
85
|
+
|
|
73
86
|
# Gets the minimum value still in the domain of the variable.
|
|
74
87
|
delegate :min
|
|
75
88
|
# Gets the maximum value still in the domain of the variable.
|
|
@@ -97,11 +110,27 @@ module Gecode
|
|
|
97
110
|
raise 'No value is assigned.' unless assigned?
|
|
98
111
|
send_bound(:val)
|
|
99
112
|
end
|
|
113
|
+
|
|
114
|
+
# Returns the receiver.
|
|
115
|
+
def to_int_var
|
|
116
|
+
self
|
|
117
|
+
end
|
|
100
118
|
|
|
119
|
+
# Returns an enumeration corresponding to the domain.
|
|
120
|
+
def domain
|
|
121
|
+
if range?
|
|
122
|
+
min..max
|
|
123
|
+
else
|
|
124
|
+
(min..max).select do |i|
|
|
125
|
+
include? i
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
101
130
|
private
|
|
102
131
|
|
|
103
|
-
# Returns a string representation of the
|
|
104
|
-
def
|
|
132
|
+
# Returns a string representation of the range of the variable's domain.
|
|
133
|
+
def domain_string #:nodoc:
|
|
105
134
|
if assigned?
|
|
106
135
|
"range: #{value.to_s}"
|
|
107
136
|
else
|
|
@@ -110,10 +139,20 @@ module Gecode
|
|
|
110
139
|
end
|
|
111
140
|
end
|
|
112
141
|
|
|
113
|
-
|
|
114
|
-
# Describes a boolean variable.
|
|
115
|
-
#
|
|
116
|
-
|
|
142
|
+
BoolVar = FreeVar(Gecode::Raw::BoolVar, :bool_var)
|
|
143
|
+
# Describes a boolean variable.
|
|
144
|
+
#
|
|
145
|
+
# A boolean variable can be either true or false.
|
|
146
|
+
#
|
|
147
|
+
# Boolean variables are boolean operands and hence respond to
|
|
148
|
+
# everything that Gecode::Bool::BoolOperand responds to.
|
|
149
|
+
# Any constraint found in
|
|
150
|
+
# Gecode::Bool::BoolConstraintReceiver can thereby be
|
|
151
|
+
# placed on boolean variables.
|
|
152
|
+
class BoolVar
|
|
153
|
+
include Gecode::Bool::BoolOperand
|
|
154
|
+
attr :model
|
|
155
|
+
|
|
117
156
|
# Checks whether the variable has been assigned.
|
|
118
157
|
delegate :assigned?, :assigned
|
|
119
158
|
|
|
@@ -123,11 +162,16 @@ module Gecode
|
|
|
123
162
|
raise 'No value is assigned.' unless assigned?
|
|
124
163
|
send_bound(:val) == 1
|
|
125
164
|
end
|
|
165
|
+
|
|
166
|
+
# Returns the receiver.
|
|
167
|
+
def to_bool_var
|
|
168
|
+
self
|
|
169
|
+
end
|
|
126
170
|
|
|
127
171
|
private
|
|
128
172
|
|
|
129
173
|
# Returns a string representation of the the variable's domain.
|
|
130
|
-
def
|
|
174
|
+
def domain_string
|
|
131
175
|
if assigned?
|
|
132
176
|
value.to_s
|
|
133
177
|
else
|
|
@@ -136,24 +180,37 @@ module Gecode
|
|
|
136
180
|
end
|
|
137
181
|
end
|
|
138
182
|
|
|
139
|
-
|
|
183
|
+
SetVar = FreeVar(Gecode::Raw::SetVar, :set_var)
|
|
140
184
|
# Describes a set variable.
|
|
141
185
|
#
|
|
142
|
-
# A set variable's domain, i.e. possible values that it can take, are
|
|
143
|
-
# represented with a greatest lower bound (GLB) and a least upper
|
|
144
|
-
# The set variable may then take any set value S such
|
|
145
|
-
# the least upper bound and the greatest lower
|
|
186
|
+
# A set variable's domain, i.e. possible values that it can take, are
|
|
187
|
+
# represented with a greatest lower bound (GLB) and a least upper
|
|
188
|
+
# bound (LUB). The set variable may then take any set value S such
|
|
189
|
+
# that S is a subset of the least upper bound and the greatest lower
|
|
190
|
+
# bound is a subset of S.
|
|
146
191
|
#
|
|
147
|
-
# If for instance the set has a greatest lower bound {1} and least
|
|
148
|
-
# {1,3,5} then the assigned set may be any of the
|
|
149
|
-
# {1,3}, {1,5}, {1,3,5}.
|
|
192
|
+
# If for instance the set has a greatest lower bound {1} and least
|
|
193
|
+
# upper bound {1,3,5} then the assigned set may be any of the
|
|
194
|
+
# following four sets: {1}, {1,3}, {1,5}, {1,3,5}.
|
|
150
195
|
#
|
|
151
|
-
# The domain of a set variable may also specify the cardinality of the
|
|
152
|
-
# i.e. the number of elements that the set may contains.
|
|
153
|
-
|
|
196
|
+
# The domain of a set variable may also specify the cardinality of the
|
|
197
|
+
# set, i.e. the number of elements that the set may contains.
|
|
198
|
+
#
|
|
199
|
+
# Set variables are set operands and hence respond to everything that
|
|
200
|
+
# Gecode::Set::SetOperand responds to. Any constraint
|
|
201
|
+
# found in Gecode::Set::SetConstraintReceiver can thereby
|
|
202
|
+
# be placed on set variables.
|
|
203
|
+
class SetVar
|
|
204
|
+
include Gecode::Set::SetOperand
|
|
205
|
+
attr :model
|
|
206
|
+
|
|
154
207
|
# Checks whether the variable has been assigned.
|
|
155
208
|
delegate :assigned?, :assigned
|
|
156
|
-
|
|
209
|
+
# Checks whether a value is included in the set.
|
|
210
|
+
delegate :in_lower_bound?, :contains
|
|
211
|
+
# Checks whether a value is not included in the set.
|
|
212
|
+
delegate :not_in_upper_bound?, :notContains
|
|
213
|
+
|
|
157
214
|
# Gets all the elements located in the greatest lower bound of the set (an
|
|
158
215
|
# Enumerable).
|
|
159
216
|
def lower_bound
|
|
@@ -185,14 +242,27 @@ module Gecode
|
|
|
185
242
|
send_bound(:cardMin)..send_bound(:cardMax)
|
|
186
243
|
end
|
|
187
244
|
|
|
245
|
+
# Returns the receiver.
|
|
246
|
+
def to_set_var
|
|
247
|
+
self
|
|
248
|
+
end
|
|
249
|
+
|
|
188
250
|
private
|
|
189
251
|
|
|
190
252
|
# Returns a string representation of the the variable's domain.
|
|
191
|
-
def
|
|
253
|
+
def domain_string
|
|
192
254
|
if assigned?
|
|
193
|
-
lower_bound.
|
|
255
|
+
if lower_bound.size < 100
|
|
256
|
+
lower_bound.to_a.inspect
|
|
257
|
+
else
|
|
258
|
+
"the domain is too large to display"
|
|
259
|
+
end
|
|
194
260
|
else
|
|
195
|
-
|
|
261
|
+
if upper_bound.size < 100
|
|
262
|
+
"glb-range: #{lower_bound.to_a.inspect}, lub-range: #{upper_bound.to_a.inspect}"
|
|
263
|
+
else
|
|
264
|
+
"the domain is too large to display"
|
|
265
|
+
end
|
|
196
266
|
end
|
|
197
267
|
end
|
|
198
268
|
end
|
data/lib/gecoder/interface.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
require 'gecoder/interface/binding_changes'
|
|
2
|
-
require 'gecoder/interface/variables'
|
|
3
2
|
require 'gecoder/interface/enum_matrix'
|
|
4
3
|
require 'gecoder/interface/model'
|
|
5
4
|
require 'gecoder/interface/search'
|
|
6
5
|
require 'gecoder/interface/constraints'
|
|
6
|
+
require 'gecoder/interface/variables'
|
|
7
7
|
require 'gecoder/interface/enum_wrapper'
|
|
8
8
|
require 'gecoder/interface/branch'
|
|
9
|
+
require 'gecoder/interface/model_sugar'
|
data/lib/gecoder/version.rb
CHANGED
data/specs/bool_var.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
|
2
|
+
require File.dirname(__FILE__) + '/constraints/property_helper'
|
|
2
3
|
|
|
3
4
|
describe 'non-empty bool variable', :shared => true do
|
|
4
5
|
it 'should give a NoMethodError when calling a method that doesn\'t exist' do
|
|
@@ -6,10 +7,10 @@ describe 'non-empty bool variable', :shared => true do
|
|
|
6
7
|
end
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
describe Gecode::
|
|
10
|
+
describe Gecode::BoolVar, '(not assigned)' do
|
|
10
11
|
before do
|
|
11
|
-
model = Gecode::Model.new
|
|
12
|
-
@var = model.bool_var
|
|
12
|
+
@model = Gecode::Model.new
|
|
13
|
+
@operand = @var = @model.bool_var
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
it_should_behave_like 'non-empty bool variable'
|
|
@@ -25,14 +26,16 @@ describe Gecode::FreeBoolVar, '(not assigned)' do
|
|
|
25
26
|
it 'should raise error when trying to access assigned value' do
|
|
26
27
|
lambda{ @var.value }.should raise_error(RuntimeError)
|
|
27
28
|
end
|
|
29
|
+
|
|
30
|
+
it_should_behave_like 'bool var operand'
|
|
28
31
|
end
|
|
29
32
|
|
|
30
|
-
describe Gecode::
|
|
33
|
+
describe Gecode::BoolVar, '(assigned true)' do
|
|
31
34
|
before do
|
|
32
|
-
model = Gecode::Model.new
|
|
33
|
-
@var = model.bool_var
|
|
35
|
+
@model = Gecode::Model.new
|
|
36
|
+
@operand = @var = @model.bool_var
|
|
34
37
|
@var.must_be.true
|
|
35
|
-
model.solve!
|
|
38
|
+
@model.solve!
|
|
36
39
|
end
|
|
37
40
|
|
|
38
41
|
it_should_behave_like 'non-empty bool variable'
|
|
@@ -48,14 +51,16 @@ describe Gecode::FreeBoolVar, '(assigned true)' do
|
|
|
48
51
|
it "should say that it's true when inspecting" do
|
|
49
52
|
@var.inspect.should include('true')
|
|
50
53
|
end
|
|
54
|
+
|
|
55
|
+
it_should_behave_like 'bool var operand'
|
|
51
56
|
end
|
|
52
57
|
|
|
53
|
-
describe Gecode::
|
|
58
|
+
describe Gecode::BoolVar, '(assigned false)' do
|
|
54
59
|
before do
|
|
55
|
-
model = Gecode::Model.new
|
|
56
|
-
@var = model.bool_var
|
|
60
|
+
@model = Gecode::Model.new
|
|
61
|
+
@operand = @var = @model.bool_var
|
|
57
62
|
@var.must_be.false
|
|
58
|
-
model.solve!
|
|
63
|
+
@model.solve!
|
|
59
64
|
end
|
|
60
65
|
|
|
61
66
|
it_should_behave_like 'non-empty bool variable'
|
|
@@ -71,4 +76,6 @@ describe Gecode::FreeBoolVar, '(assigned false)' do
|
|
|
71
76
|
it "should say that it's false when inspecting" do
|
|
72
77
|
@var.inspect.should include('false')
|
|
73
78
|
end
|
|
74
|
-
|
|
79
|
+
|
|
80
|
+
it_should_behave_like 'bool var operand'
|
|
81
|
+
end
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../
|
|
2
|
-
require File.dirname(__FILE__) + '/constraint_helper'
|
|
1
|
+
require File.dirname(__FILE__) + '/../constraint_helper'
|
|
3
2
|
|
|
4
3
|
class BoolSampleProblem < Gecode::Model
|
|
5
4
|
attr :b1
|
|
@@ -13,29 +12,114 @@ class BoolSampleProblem < Gecode::Model
|
|
|
13
12
|
end
|
|
14
13
|
end
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@expect_options = option_expectation do |strength, kind, reif_var|
|
|
29
|
-
@model.allow_space_access do
|
|
15
|
+
[:true, :false].each do |type|
|
|
16
|
+
describe Gecode::Bool, " (must be #{type})" do
|
|
17
|
+
before do
|
|
18
|
+
@model = Gecode::Model.new
|
|
19
|
+
@bool = @model.bool_var
|
|
20
|
+
|
|
21
|
+
@types = [:bool]
|
|
22
|
+
@invoke = lambda do |receiver, hash|
|
|
23
|
+
receiver.method(type).call(hash)
|
|
24
|
+
@model.solve!
|
|
25
|
+
end
|
|
26
|
+
@expect = lambda do |var, opts, reif_var|
|
|
30
27
|
# We only test the non-MiniModel parts.
|
|
31
28
|
unless reif_var.nil?
|
|
32
29
|
Gecode::Raw.should_receive(:rel).once.with(
|
|
33
30
|
an_instance_of(Gecode::Raw::Space),
|
|
34
|
-
an_instance_of(Gecode::Raw::BoolVar),
|
|
35
|
-
|
|
31
|
+
an_instance_of(Gecode::Raw::BoolVar),
|
|
32
|
+
(type == :true) ? Gecode::Raw::IRT_EQ : Gecode::Raw::IRT_NQ,
|
|
33
|
+
reif_var, *opts)
|
|
36
34
|
end
|
|
37
35
|
end
|
|
38
36
|
end
|
|
37
|
+
|
|
38
|
+
it "should constrain variables to be #{type}" do
|
|
39
|
+
@bool.must.method(type).call
|
|
40
|
+
@model.solve!
|
|
41
|
+
@bool.value.should == (type == :true)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should make negation constrain variables to not be #{type}" do
|
|
45
|
+
@bool.must_not.method(type).call
|
|
46
|
+
@model.solve!
|
|
47
|
+
@bool.value.should == (type != :true)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it_should_behave_like 'reifiable constraint'
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe Gecode::Bool, " (implies)" do
|
|
55
|
+
before do
|
|
56
|
+
@model = Gecode::Model.new
|
|
57
|
+
@b1 = @model.bool_var
|
|
58
|
+
@b2 = @model.bool_var
|
|
59
|
+
@model.branch_on @model.wrap_enum([@b1, @b2])
|
|
60
|
+
|
|
61
|
+
@types = [:bool, :bool]
|
|
62
|
+
@invoke = lambda do |receiver, op, hash|
|
|
63
|
+
receiver.imply(op, hash)
|
|
64
|
+
@model.solve!
|
|
65
|
+
end
|
|
66
|
+
@expect = lambda do |var1, var2, opts, reif_var|
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "should constrain variables to imply each other" do
|
|
71
|
+
@b1.must.imply @b2
|
|
72
|
+
@model.solve!
|
|
73
|
+
(!@b1.value || @b2.value).should be_true
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "should, when negated, constrain variables to not imply each other" do
|
|
77
|
+
@b1.must_not.imply @b2
|
|
78
|
+
@model.solve!
|
|
79
|
+
@b1.value.should be_true
|
|
80
|
+
@b2.value.should_not be_true
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it_should_behave_like 'reifiable constraint'
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe Gecode::Bool, " (equality)" do
|
|
87
|
+
before do
|
|
88
|
+
@model = Gecode::Model.new
|
|
89
|
+
@b1 = @model.bool_var
|
|
90
|
+
@b2 = @model.bool_var
|
|
91
|
+
@model.branch_on @model.wrap_enum([@b1, @b2])
|
|
92
|
+
|
|
93
|
+
@types = [:bool, :bool]
|
|
94
|
+
@invoke = lambda do |receiver, op, hash|
|
|
95
|
+
receiver.equal(op, hash)
|
|
96
|
+
@model.solve!
|
|
97
|
+
end
|
|
98
|
+
@expect = lambda do |var1, var2, opts, reif_var|
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "should constrain variables to equal each other" do
|
|
103
|
+
@b1.must == @b2
|
|
104
|
+
@model.solve!
|
|
105
|
+
@b1.value.should == @b2.value
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "should, when negated, constrain variables to not equal each other" do
|
|
109
|
+
@b1.must_not == @b2
|
|
110
|
+
@model.solve!
|
|
111
|
+
@b1.value.should_not == @b2.value
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it_should_behave_like 'reifiable constraint'
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
describe Gecode::Bool do
|
|
118
|
+
before do
|
|
119
|
+
@model = BoolSampleProblem.new
|
|
120
|
+
@b1 = @model.b1
|
|
121
|
+
@b2 = @model.b2
|
|
122
|
+
@b3 = @model.b3
|
|
39
123
|
end
|
|
40
124
|
|
|
41
125
|
it 'should handle single variables constrainted to be true' do
|
|
@@ -229,14 +313,5 @@ describe Gecode::Constraints::Bool do
|
|
|
229
313
|
sol = @model.solve!
|
|
230
314
|
sol.b3.value.should be_true
|
|
231
315
|
end
|
|
232
|
-
|
|
233
|
-
it 'should raise error on right hand sides of incorrect type given to #==' do
|
|
234
|
-
lambda{ @b1.must == 'hello' }.should raise_error(TypeError)
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
it 'should raise error on right hand sides of incorrect type given to #imply' do
|
|
238
|
-
lambda{ @b1.must.imply 'hello' }.should raise_error(TypeError)
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
it_should_behave_like 'reifiable constraint'
|
|
242
316
|
end
|
|
317
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../property_helper'
|
|
2
|
+
|
|
3
|
+
[:&, :|, :^].each do |property|
|
|
4
|
+
describe Gecode::Bool, " (#{property} property)" do
|
|
5
|
+
before do
|
|
6
|
+
@model = Gecode::Model.new
|
|
7
|
+
@b1 = @model.bool_var
|
|
8
|
+
@b2 = @model.bool_var
|
|
9
|
+
@model.branch_on @model.wrap_enum([@b1, @b2])
|
|
10
|
+
|
|
11
|
+
# For bool operand producing property spec.
|
|
12
|
+
@property_types = [:bool, :bool]
|
|
13
|
+
@select_property = lambda do |bool1, bool2|
|
|
14
|
+
bool1.method(property).call bool2
|
|
15
|
+
end
|
|
16
|
+
@selected_property = @b1.method(property).call @b2
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'should constrain the conjunction/disjunction/exclusive disjunction' do
|
|
20
|
+
(@b1.method(property).call @b2).must_be.true
|
|
21
|
+
@model.solve!
|
|
22
|
+
@b1.value.method(property).call(@b2.value).should be_true
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it_should_behave_like 'property that produces bool operand'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe Gecode::Bool, ' (#implies property)' do
|
|
30
|
+
before do
|
|
31
|
+
@model = Gecode::Model.new
|
|
32
|
+
@b1 = @model.bool_var
|
|
33
|
+
@b2 = @model.bool_var
|
|
34
|
+
@model.branch_on @model.wrap_enum([@b1, @b2])
|
|
35
|
+
|
|
36
|
+
# For bool operand producing property spec.
|
|
37
|
+
@property_types = [:bool, :bool]
|
|
38
|
+
@select_property = lambda do |bool1, bool2|
|
|
39
|
+
bool1.implies bool2
|
|
40
|
+
end
|
|
41
|
+
@selected_property = @b1.implies @b2
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'should constrain the implication' do
|
|
45
|
+
(@b1.implies @b2).must_be.true
|
|
46
|
+
@model.solve!
|
|
47
|
+
(!@b1.value | @b2.value).should be_true
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it_should_behave_like 'property that produces bool operand'
|
|
51
|
+
end
|