gecoder-with-gecode 0.8.3 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +15 -0
- data/README +6 -2
- data/example/equation_system.rb +15 -0
- data/example/magic_sequence.rb +7 -7
- data/example/money.rb +36 -0
- data/example/queens.rb +7 -8
- data/example/send_most_money.rb +1 -1
- data/example/square_tiling.rb +2 -2
- data/example/sudoku-set.rb +11 -12
- data/example/sudoku.rb +40 -45
- data/ext/extconf.rb +0 -0
- data/ext/gecode-2.1.1/LICENSE +0 -0
- data/ext/gecode-2.1.1/configure +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/SDFVariableHeuristic.cc +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/SDFVariableHeuristic.hh +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/configure +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/extensivecomparator.cc +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/extensivecomparator.hh +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/heap.cc +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/implicative.cc +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/implicative.hh +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/myspace.cc +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/myspace.hh +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/qecore.cc +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/qecore.hh +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/warner.cc +0 -0
- data/ext/gecode-2.1.1/contribs/qecode/warner.hh +0 -0
- data/ext/gecode-2.1.1/gecode/cpltset/var-imp/cpltset.vis +0 -0
- data/ext/gecode-2.1.1/gecode/int/arithmetic/abs.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/arithmetic/max.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/arithmetic/mult.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/arithmetic/sqr.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/arithmetic/sqrt.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/array.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/array.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/bool/base.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/bool/eq.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/bool/eqv.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/bool/lq.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/bool/or.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/branch/select-val.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/branch/select-view.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/branch.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/branch.hh +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel/base.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel/dom.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel/link-multi.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel/link-multi.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel/link-single.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel/link-single.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel/val.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/channel.hh +0 -0
- data/ext/gecode-2.1.1/gecode/int/circuit/base.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/circuit/dom.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/circuit/val.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/circuit.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/circuit.hh +0 -0
- data/ext/gecode-2.1.1/gecode/int/count/int.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/count/rel.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/count/view.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/distinct/bilink.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/distinct/bnd.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/distinct/combptr.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/distinct/dom.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/distinct/edge.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/distinct/node.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/distinct/ter-dom.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/distinct/val.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/dom/range.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/dom/spec.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/dom.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/dom.hh +0 -0
- data/ext/gecode-2.1.1/gecode/int/element/int.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/element/view.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/element.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/element.hh +0 -0
- data/ext/gecode-2.1.1/gecode/int/exception.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/extensional/dfa.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/extensional/dfa.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/extensional/layered-graph.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/gcc/dom.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/gcc/gccbndsup.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/gcc/lbc.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/gcc/ubc.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/gcc.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/gcc.hh +0 -0
- data/ext/gecode-2.1.1/gecode/int/int-set.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/int-set.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/bool-int.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/bool-post.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/bool-scale.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/bool-view.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/int-bin.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/int-dom.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/int-nary.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/int-post.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/int-ter.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/linear/post.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/propagator.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/rel/eq.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/rel/lex.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/rel/lq-le.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/rel/nq.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/unshare.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/var/bool.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/var-imp/bool.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/var-imp/bool.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/var-imp/bool.vis +0 -0
- data/ext/gecode-2.1.1/gecode/int/var-imp/delta.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/var-imp/int.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/var-imp/int.vis +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/bool.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/constint.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/int.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/iter.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/minus.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/offset.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/print.cc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/rtest.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/scale.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view/zero.icc +0 -0
- data/ext/gecode-2.1.1/gecode/int/view.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-add.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-append.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-array.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-cache.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-compl.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-diff.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-empty.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-inter.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-minmax.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-minus.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-offset.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-operations.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-scale.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-singleton-append.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-singleton.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-union.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/ranges-values.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/values-array.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/values-minus.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/values-offset.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/values-ranges.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/values-singleton.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter/values-unique.icc +0 -0
- data/ext/gecode-2.1.1/gecode/iter.hh +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/advisor.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/array.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/branching.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/exception.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/macros.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/memory-manager.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/modevent.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/propagator.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/shared-array.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/var-traits.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/var.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel/view.icc +0 -0
- data/ext/gecode-2.1.1/gecode/kernel.hh +0 -0
- data/ext/gecode-2.1.1/gecode/minimodel/arithmetic.cc +0 -0
- data/ext/gecode-2.1.1/gecode/minimodel/bool-expr.cc +0 -0
- data/ext/gecode-2.1.1/gecode/minimodel/bool-expr.icc +0 -0
- data/ext/gecode-2.1.1/gecode/minimodel/bool-rel.icc +0 -0
- data/ext/gecode-2.1.1/gecode/minimodel/lin-expr.icc +0 -0
- data/ext/gecode-2.1.1/gecode/minimodel/lin-rel.icc +0 -0
- data/ext/gecode-2.1.1/gecode/minimodel/reg.cc +0 -0
- data/ext/gecode-2.1.1/gecode/minimodel.hh +0 -0
- data/ext/gecode-2.1.1/gecode/search/bab.cc +0 -0
- data/ext/gecode-2.1.1/gecode/search/bab.icc +0 -0
- data/ext/gecode-2.1.1/gecode/search/dfs.cc +0 -0
- data/ext/gecode-2.1.1/gecode/search/dfs.icc +0 -0
- data/ext/gecode-2.1.1/gecode/search/engine-ctrl.icc +0 -0
- data/ext/gecode-2.1.1/gecode/search/lds.cc +0 -0
- data/ext/gecode-2.1.1/gecode/search/lds.icc +0 -0
- data/ext/gecode-2.1.1/gecode/search/options.cc +0 -0
- data/ext/gecode-2.1.1/gecode/search/options.icc +0 -0
- data/ext/gecode-2.1.1/gecode/search/reco-stack.icc +0 -0
- data/ext/gecode-2.1.1/gecode/search/restart.icc +0 -0
- data/ext/gecode-2.1.1/gecode/search/statistics.icc +0 -0
- data/ext/gecode-2.1.1/gecode/search/stop.cc +0 -0
- data/ext/gecode-2.1.1/gecode/search/stop.icc +0 -0
- data/ext/gecode-2.1.1/gecode/set/var-imp/set.vis +0 -0
- data/ext/gecode-2.1.1/gecode/support/block-allocator.icc +0 -0
- data/ext/gecode-2.1.1/gecode/support/cast.icc +0 -0
- data/ext/gecode-2.1.1/gecode/support/exception.cc +0 -0
- data/ext/gecode-2.1.1/gecode/support/exception.icc +0 -0
- data/ext/gecode-2.1.1/gecode/support/macros.icc +0 -0
- data/ext/gecode-2.1.1/gecode/support/marked-pointer.icc +0 -0
- data/ext/gecode-2.1.1/gecode/support/memory.icc +0 -0
- data/ext/gecode-2.1.1/gecode/support/sentinel-stack.icc +0 -0
- data/ext/gecode-2.1.1/gecode/support/static-stack.icc +0 -0
- data/ext/gecode-2.1.1/gecode/support/symbol.cc +0 -0
- data/ext/gecode-2.1.1/gecode/support.hh +0 -0
- data/ext/gecode-2.1.1/install-sh +0 -0
- data/ext/gecode-2.1.1/misc/debian/rules +0 -0
- data/ext/gecode-2.1.1/misc/doxygen/back.png +0 -0
- data/ext/gecode-2.1.1/misc/doxygen/gecode-logo-100.png +0 -0
- data/ext/gecode-2.1.1/misc/genchangelog.perl +0 -0
- data/ext/gecode-2.1.1/misc/genlicense.perl +0 -0
- data/ext/gecode-2.1.1/misc/genstatistics.perl +0 -0
- data/ext/gecode-2.1.1/misc/genvariables.perl +0 -0
- data/ext/gecode-2.1.1/misc/getrevision.perl +0 -0
- data/ext/gecode-2.1.1/misc/makedepend.perl +0 -0
- data/ext/gecode-2.1.1/misc/svn-ignore.txt +0 -0
- data/ext/gecode-2.1.1/variables.vsl +0 -0
- data/lib/gecoder/bindings/bindings.rb +16 -0
- data/lib/gecoder/bindings.rb +42 -0
- data/lib/gecoder/interface/branch.rb +16 -9
- data/lib/gecoder/interface/constraints/bool/boolean.rb +205 -213
- data/lib/gecoder/interface/constraints/bool/channel.rb +4 -5
- data/lib/gecoder/interface/constraints/bool/linear.rb +192 -21
- data/lib/gecoder/interface/constraints/bool_enum/channel.rb +43 -39
- data/lib/gecoder/interface/constraints/bool_enum/extensional.rb +43 -49
- data/lib/gecoder/interface/constraints/bool_enum/relation.rb +38 -71
- data/lib/gecoder/interface/constraints/bool_enum_constraints.rb +73 -22
- data/lib/gecoder/interface/constraints/bool_var_constraints.rb +140 -61
- data/lib/gecoder/interface/constraints/extensional_regexp.rb +4 -4
- data/lib/gecoder/interface/constraints/fixnum_enum/element.rb +63 -0
- data/lib/gecoder/interface/constraints/fixnum_enum/operation.rb +65 -0
- data/lib/gecoder/interface/constraints/fixnum_enum_constraints.rb +42 -0
- data/lib/gecoder/interface/constraints/int/arithmetic.rb +131 -130
- data/lib/gecoder/interface/constraints/int/channel.rb +21 -31
- data/lib/gecoder/interface/constraints/int/domain.rb +45 -42
- data/lib/gecoder/interface/constraints/int/linear.rb +85 -239
- data/lib/gecoder/interface/constraints/int/relation.rb +141 -0
- data/lib/gecoder/interface/constraints/int_enum/arithmetic.rb +55 -64
- data/lib/gecoder/interface/constraints/int_enum/channel.rb +35 -37
- data/lib/gecoder/interface/constraints/int_enum/count.rb +53 -78
- data/lib/gecoder/interface/constraints/int_enum/distinct.rb +36 -46
- data/lib/gecoder/interface/constraints/int_enum/element.rb +39 -57
- data/lib/gecoder/interface/constraints/int_enum/equality.rb +15 -19
- data/lib/gecoder/interface/constraints/int_enum/extensional.rb +65 -72
- data/lib/gecoder/interface/constraints/int_enum/sort.rb +42 -45
- data/lib/gecoder/interface/constraints/int_enum_constraints.rb +79 -22
- data/lib/gecoder/interface/constraints/int_var_constraints.rb +215 -44
- data/lib/gecoder/interface/constraints/reifiable_constraints.rb +14 -14
- data/lib/gecoder/interface/constraints/selected_set/select.rb +120 -0
- data/lib/gecoder/interface/constraints/selected_set_constraints.rb +75 -0
- data/lib/gecoder/interface/constraints/set/cardinality.rb +43 -53
- data/lib/gecoder/interface/constraints/set/channel.rb +26 -29
- data/lib/gecoder/interface/constraints/set/connection.rb +89 -152
- data/lib/gecoder/interface/constraints/set/domain.rb +112 -65
- data/lib/gecoder/interface/constraints/set/include.rb +36 -0
- data/lib/gecoder/interface/constraints/set/operation.rb +96 -110
- data/lib/gecoder/interface/constraints/set/relation.rb +114 -137
- data/lib/gecoder/interface/constraints/set_elements/relation.rb +116 -0
- data/lib/gecoder/interface/constraints/set_elements_constraints.rb +97 -0
- data/lib/gecoder/interface/constraints/set_enum/channel.rb +23 -27
- data/lib/gecoder/interface/constraints/set_enum/distinct.rb +18 -19
- data/lib/gecoder/interface/constraints/set_enum/operation.rb +62 -53
- data/lib/gecoder/interface/constraints/set_enum/select.rb +79 -0
- data/lib/gecoder/interface/constraints/set_enum_constraints.rb +73 -23
- data/lib/gecoder/interface/constraints/set_var_constraints.rb +222 -57
- data/lib/gecoder/interface/constraints.rb +410 -451
- data/lib/gecoder/interface/enum_matrix.rb +4 -4
- data/lib/gecoder/interface/enum_wrapper.rb +71 -22
- data/lib/gecoder/interface/model.rb +167 -12
- data/lib/gecoder/interface/model_sugar.rb +84 -0
- data/lib/gecoder/interface/search.rb +30 -18
- data/lib/gecoder/interface/variables.rb +103 -33
- data/lib/gecoder/interface.rb +2 -1
- data/lib/gecoder/version.rb +2 -2
- data/specs/bool_var.rb +19 -12
- data/specs/constraints/{boolean.rb → bool/boolean.rb} +103 -28
- data/specs/constraints/bool/boolean_properties.rb +51 -0
- data/specs/constraints/bool/linear.rb +213 -0
- data/specs/constraints/bool_enum/bool_enum_relation.rb +117 -0
- data/specs/constraints/bool_enum/channel.rb +102 -0
- data/specs/constraints/{extensional.rb → bool_enum/extensional.rb} +32 -101
- data/specs/constraints/constraint_helper.rb +149 -179
- data/specs/constraints/constraint_receivers.rb +103 -0
- data/specs/constraints/constraints.rb +6 -63
- data/specs/constraints/fixnum_enum/element.rb +58 -0
- data/specs/constraints/fixnum_enum/operation.rb +67 -0
- data/specs/constraints/int/arithmetic.rb +149 -0
- data/specs/constraints/int/channel.rb +101 -0
- data/specs/constraints/int/domain.rb +106 -0
- data/specs/constraints/int/linear.rb +183 -0
- data/specs/constraints/int/linear_properties.rb +97 -0
- data/specs/constraints/int/relation.rb +84 -0
- data/specs/constraints/int_enum/arithmetic.rb +72 -0
- data/specs/constraints/int_enum/channel.rb +57 -0
- data/specs/constraints/int_enum/count.rb +72 -0
- data/specs/constraints/int_enum/distinct.rb +80 -0
- data/specs/constraints/int_enum/element.rb +61 -0
- data/specs/constraints/int_enum/equality.rb +29 -0
- data/specs/constraints/int_enum/extensional.rb +224 -0
- data/specs/constraints/int_enum/sort.rb +167 -0
- data/specs/constraints/operands.rb +264 -0
- data/specs/constraints/property_helper.rb +443 -0
- data/specs/constraints/reification_sugar.rb +4 -5
- data/specs/constraints/selected_set/select.rb +56 -0
- data/specs/constraints/selected_set/select_properties.rb +157 -0
- data/specs/constraints/set/cardinality.rb +58 -0
- data/specs/constraints/set/cardinality_properties.rb +46 -0
- data/specs/constraints/set/channel.rb +77 -0
- data/specs/constraints/set/connection.rb +176 -0
- data/specs/constraints/set/domain.rb +197 -0
- data/specs/constraints/set/include.rb +36 -0
- data/specs/constraints/set/operation.rb +132 -0
- data/specs/constraints/set/relation.rb +117 -0
- data/specs/constraints/set_elements/relation.rb +84 -0
- data/specs/constraints/set_enum/channel.rb +80 -0
- data/specs/constraints/set_enum/distinct.rb +59 -0
- data/specs/constraints/set_enum/operation.rb +111 -0
- data/specs/constraints/set_enum/select.rb +73 -0
- data/specs/enum_wrapper.rb +53 -3
- data/specs/int_var.rb +44 -25
- data/specs/model.rb +58 -1
- data/specs/model_sugar.rb +30 -0
- data/specs/search.rb +24 -5
- data/specs/selected_set.rb +39 -0
- data/specs/set_elements.rb +34 -0
- data/specs/set_var.rb +22 -8
- data/specs/spec_helper.rb +206 -6
- data/tasks/distribution.rake +22 -7
- data/tasks/svn.rake +3 -1
- metadata +219 -135
- data/lib/gecoder/interface/constraints/set_enum/selection.rb +0 -217
- data/specs/constraints/arithmetic.rb +0 -351
- data/specs/constraints/bool_enum_relation.rb +0 -160
- data/specs/constraints/cardinality.rb +0 -157
- data/specs/constraints/channel.rb +0 -454
- data/specs/constraints/connection.rb +0 -369
- data/specs/constraints/count.rb +0 -146
- data/specs/constraints/distinct.rb +0 -164
- data/specs/constraints/element.rb +0 -108
- data/specs/constraints/equality.rb +0 -31
- data/specs/constraints/int_domain.rb +0 -70
- data/specs/constraints/int_relation.rb +0 -82
- data/specs/constraints/linear.rb +0 -340
- data/specs/constraints/selection.rb +0 -292
- data/specs/constraints/set_domain.rb +0 -185
- data/specs/constraints/set_operation.rb +0 -285
- data/specs/constraints/set_relation.rb +0 -197
- data/specs/constraints/sort.rb +0 -179
@@ -0,0 +1,167 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../constraint_helper'
|
2
|
+
|
3
|
+
class SortSampleProblem < Gecode::Model
|
4
|
+
attr :vars
|
5
|
+
attr :sorted
|
6
|
+
attr :indices
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@vars = int_var_array(4, 10..19)
|
10
|
+
@sorted = int_var_array(4, 10..19)
|
11
|
+
@indices = int_var_array(4, 0..9)
|
12
|
+
|
13
|
+
# To make it more interesting
|
14
|
+
@vars.must_be.distinct
|
15
|
+
|
16
|
+
branch_on @vars
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe Gecode::IntEnum::Sort, ' (without :as and :order)' do
|
21
|
+
before do
|
22
|
+
@model = SortSampleProblem.new
|
23
|
+
@vars = @model.vars
|
24
|
+
@sorted = @model.sorted
|
25
|
+
|
26
|
+
@types = [:int_enum]
|
27
|
+
@invoke = lambda do |receiver, hash|
|
28
|
+
receiver.sorted(hash)
|
29
|
+
@model.solve!
|
30
|
+
end
|
31
|
+
@expect = lambda do |var, opts, reif_var|
|
32
|
+
if reif_var.nil?
|
33
|
+
Gecode::Raw.should_receive(:rel).exactly(var.size - 1).times.with(
|
34
|
+
an_instance_of(Gecode::Raw::Space),
|
35
|
+
an_instance_of(Gecode::Raw::IntVar), Gecode::Raw::IRT_LQ,
|
36
|
+
an_instance_of(Gecode::Raw::IntVar), *opts)
|
37
|
+
else
|
38
|
+
Gecode::Raw.should_receive(:rel).once.with(
|
39
|
+
an_instance_of(Gecode::Raw::Space), anything,
|
40
|
+
an_instance_of(Gecode::Raw::BoolVarArray),
|
41
|
+
anything, anything, anything)
|
42
|
+
Gecode::Raw.should_receive(:rel).exactly(var.size - 1).times.with(
|
43
|
+
an_instance_of(Gecode::Raw::Space),
|
44
|
+
an_instance_of(Gecode::Raw::IntVar), Gecode::Raw::IRT_LQ,
|
45
|
+
an_instance_of(Gecode::Raw::IntVar),
|
46
|
+
an_instance_of(Gecode::Raw::BoolVar), *opts)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should constraint variables to be sorted' do
|
52
|
+
@vars.must_be.sorted
|
53
|
+
values = @model.solve!.vars.values
|
54
|
+
values.should == values.sort
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should allow negation' do
|
58
|
+
@vars.must_not_be.sorted
|
59
|
+
@model.solve!
|
60
|
+
values = @vars.values
|
61
|
+
values.should_not == values.sort
|
62
|
+
end
|
63
|
+
|
64
|
+
it_should_behave_like 'reifiable constraint'
|
65
|
+
end
|
66
|
+
|
67
|
+
describe Gecode::IntEnum::Sort, ' (with :as)' do
|
68
|
+
before do
|
69
|
+
@model = SortSampleProblem.new
|
70
|
+
@vars = @model.vars
|
71
|
+
@sorted = @model.sorted
|
72
|
+
|
73
|
+
# Make it a bit more interesting.
|
74
|
+
@vars[0].must > @vars[3] + 1
|
75
|
+
|
76
|
+
@types = [:int_enum, :int_enum]
|
77
|
+
@invoke = lambda do |receiver, int_enum, hash|
|
78
|
+
receiver.sorted hash.update(:as => int_enum)
|
79
|
+
@model.solve!
|
80
|
+
end
|
81
|
+
@expect = lambda do |var1, var2, opts, reif_var|
|
82
|
+
Gecode::Raw.should_receive(:sorted).once.with(
|
83
|
+
an_instance_of(Gecode::Raw::Space),
|
84
|
+
var1, var2, *opts)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should constraint variables to be sorted' do
|
89
|
+
@vars.must_be.sorted(:as => @sorted)
|
90
|
+
@model.solve!
|
91
|
+
values = @sorted.values
|
92
|
+
values.should == values.sort
|
93
|
+
end
|
94
|
+
|
95
|
+
it_should_behave_like 'non-reifiable constraint'
|
96
|
+
it_should_behave_like 'non-negatable constraint'
|
97
|
+
end
|
98
|
+
|
99
|
+
describe Gecode::IntEnum::Sort, ' (with :order)' do
|
100
|
+
before do
|
101
|
+
@model = SortSampleProblem.new
|
102
|
+
@vars = @model.vars
|
103
|
+
@sorted = @model.sorted
|
104
|
+
@indices = @model.indices
|
105
|
+
|
106
|
+
# Make it a bit more interesting.
|
107
|
+
@vars[0].must > @vars[3] + 1
|
108
|
+
|
109
|
+
@types = [:int_enum, :int_enum]
|
110
|
+
@invoke = lambda do |receiver, int_enum, hash|
|
111
|
+
receiver.sorted hash.update(:order => int_enum)
|
112
|
+
@model.solve!
|
113
|
+
end
|
114
|
+
@expect = lambda do |var1, var2, opts, reif_var|
|
115
|
+
Gecode::Raw.should_receive(:sorted).once.with(
|
116
|
+
an_instance_of(Gecode::Raw::Space),
|
117
|
+
var1, an_instance_of(Gecode::Raw::IntVarArray), var2,
|
118
|
+
*opts)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should constraint variables to be sorted with the specified indices' do
|
123
|
+
@vars.must_be.sorted(:order => @indices)
|
124
|
+
@model.solve!
|
125
|
+
sorted_values = @vars.values.sort
|
126
|
+
expected_indices = @vars.map{ |v| sorted_values.index(v.value) }
|
127
|
+
@indices.values.should == expected_indices
|
128
|
+
end
|
129
|
+
|
130
|
+
it_should_behave_like 'non-reifiable constraint'
|
131
|
+
it_should_behave_like 'non-negatable constraint'
|
132
|
+
end
|
133
|
+
|
134
|
+
describe Gecode::IntEnum::Sort, ' (with :order and :as)' do
|
135
|
+
before do
|
136
|
+
@model = SortSampleProblem.new
|
137
|
+
@vars = @model.vars
|
138
|
+
@sorted = @model.sorted
|
139
|
+
@indices = @model.indices
|
140
|
+
|
141
|
+
# Make it a bit more interesting.
|
142
|
+
@vars[0].must > @vars[3] + 1
|
143
|
+
|
144
|
+
@types = [:int_enum, :int_enum, :int_enum]
|
145
|
+
@invoke = lambda do |receiver, int_enum1, int_enum2, hash|
|
146
|
+
receiver.sorted hash.update(:as => int_enum1, :order => int_enum2)
|
147
|
+
@model.solve!
|
148
|
+
end
|
149
|
+
@expect = lambda do |var1, var2, var3, opts, reif_var|
|
150
|
+
Gecode::Raw.should_receive(:sorted).once.with(
|
151
|
+
an_instance_of(Gecode::Raw::Space),
|
152
|
+
var1, var2, var3, *opts)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should constraint variables to be sorted with the specified indices' do
|
157
|
+
@vars.must_be.sorted(:as => @sorted, :order => @indices)
|
158
|
+
@model.solve!
|
159
|
+
sorted_values = @sorted.values
|
160
|
+
sorted_values.should == sorted_values.sort
|
161
|
+
expected_indices = @vars.map{ |v| sorted_values.index(v.value) }
|
162
|
+
@indices.values.should == expected_indices
|
163
|
+
end
|
164
|
+
|
165
|
+
it_should_behave_like 'non-reifiable constraint'
|
166
|
+
it_should_behave_like 'non-negatable constraint'
|
167
|
+
end
|
@@ -0,0 +1,264 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe 'operand', :shared => true do
|
4
|
+
it 'should not shadow method missing' do
|
5
|
+
lambda do
|
6
|
+
@operand.does_not_exist
|
7
|
+
end.should raise_error(NoMethodError)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'variable operand', :shared => true do
|
12
|
+
it 'should fall back to the underlying variable' do
|
13
|
+
lambda do
|
14
|
+
@operand.assigned?
|
15
|
+
end.should_not raise_error
|
16
|
+
end
|
17
|
+
|
18
|
+
it_should_behave_like 'operand'
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'enum operand', :shared => true do
|
22
|
+
it 'should fall back to the underlying enum' do
|
23
|
+
lambda do
|
24
|
+
@operand[0]
|
25
|
+
end.should_not raise_error
|
26
|
+
end
|
27
|
+
|
28
|
+
it_should_behave_like 'operand'
|
29
|
+
end
|
30
|
+
|
31
|
+
describe Gecode::Operand do
|
32
|
+
before do
|
33
|
+
model = Gecode::Model.new
|
34
|
+
@operand = Object.new
|
35
|
+
class <<@operand
|
36
|
+
include Gecode::Operand
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should raise error if #model is not defined' do
|
41
|
+
lambda do
|
42
|
+
@operand.model
|
43
|
+
end.should raise_error(NotImplementedError)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should raise error if #construct_receiver is not defined' do
|
47
|
+
lambda do
|
48
|
+
@operand.must
|
49
|
+
end.should raise_error(NotImplementedError)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe Gecode::Int::IntOperand do
|
54
|
+
before do
|
55
|
+
model = Gecode::Model.new
|
56
|
+
@operand, _ = general_int_operand(model)
|
57
|
+
end
|
58
|
+
|
59
|
+
it_should_behave_like 'variable operand'
|
60
|
+
end
|
61
|
+
|
62
|
+
describe Gecode::Int::ShortCircuitEqualityOperand, ' (not subclassed)' do
|
63
|
+
before do
|
64
|
+
@model = Gecode::Model.new
|
65
|
+
@operand = Gecode::Int::ShortCircuitEqualityOperand.new(@model)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should raise error if #constrain_equal is called' do
|
69
|
+
lambda do
|
70
|
+
@operand.to_int_var
|
71
|
+
@model.solve!
|
72
|
+
end.should raise_error(NotImplementedError)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe Gecode::Int::ShortCircuitRelationsOperand, ' (not subclassed)' do
|
77
|
+
before do
|
78
|
+
@model = Gecode::Model.new
|
79
|
+
@operand = Gecode::Int::ShortCircuitRelationsOperand.new(@model)
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should raise error if #constrain_equal is called' do
|
83
|
+
lambda do
|
84
|
+
@operand.to_int_var
|
85
|
+
@model.solve!
|
86
|
+
end.should raise_error(NotImplementedError)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe Gecode::IntEnum::IntEnumOperand do
|
91
|
+
before do
|
92
|
+
model = Gecode::Model.new
|
93
|
+
@operand, _ = general_int_enum_operand(model)
|
94
|
+
end
|
95
|
+
|
96
|
+
it_should_behave_like 'enum operand'
|
97
|
+
end
|
98
|
+
|
99
|
+
describe Gecode::Bool::BoolOperand do
|
100
|
+
before do
|
101
|
+
model = Gecode::Model.new
|
102
|
+
@operand, _ = general_bool_operand(model)
|
103
|
+
end
|
104
|
+
|
105
|
+
it_should_behave_like 'variable operand'
|
106
|
+
end
|
107
|
+
|
108
|
+
describe Gecode::Bool::ShortCircuitEqualityOperand, ' (not subclassed)' do
|
109
|
+
before do
|
110
|
+
@model = Gecode::Model.new
|
111
|
+
@operand = Gecode::Bool::ShortCircuitEqualityOperand.new(@model)
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should raise error if #constrain_equal is called' do
|
115
|
+
lambda do
|
116
|
+
@operand.to_bool_var
|
117
|
+
@model.solve!
|
118
|
+
end.should raise_error(NotImplementedError)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe Gecode::BoolEnum::BoolEnumOperand do
|
123
|
+
before do
|
124
|
+
model = Gecode::Model.new
|
125
|
+
@operand, _ = general_bool_enum_operand(model)
|
126
|
+
end
|
127
|
+
|
128
|
+
it_should_behave_like 'enum operand'
|
129
|
+
end
|
130
|
+
|
131
|
+
describe Gecode::Set::SetOperand do
|
132
|
+
before do
|
133
|
+
model = Gecode::Model.new
|
134
|
+
@operand, _ = general_set_operand(model)
|
135
|
+
end
|
136
|
+
|
137
|
+
it_should_behave_like 'variable operand'
|
138
|
+
end
|
139
|
+
|
140
|
+
describe Gecode::Set::ShortCircuitEqualityOperand, ' (not subclassed)' do
|
141
|
+
before do
|
142
|
+
@model = Gecode::Model.new
|
143
|
+
@operand = Gecode::Set::ShortCircuitEqualityOperand.new(@model)
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should raise error if #constrain_equal is called' do
|
147
|
+
lambda do
|
148
|
+
@operand.to_set_var
|
149
|
+
@model.solve!
|
150
|
+
end.should raise_error(NotImplementedError)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe Gecode::Set::ShortCircuitRelationsOperand, ' (not subclassed)' do
|
155
|
+
before do
|
156
|
+
@model = Gecode::Model.new
|
157
|
+
@operand = Gecode::Set::ShortCircuitRelationsOperand.new(@model)
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'should raise error if #constrain_equal is called' do
|
161
|
+
lambda do
|
162
|
+
@operand.to_set_var
|
163
|
+
@model.solve!
|
164
|
+
end.should raise_error(NotImplementedError)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe Gecode::SelectedSet::SelectedSetOperand do
|
169
|
+
before do
|
170
|
+
model = Gecode::Model.new
|
171
|
+
@operand, ops = general_selected_set_operand(model)
|
172
|
+
@enum, @set = ops
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should raise error if set enum operand is not given' do
|
176
|
+
lambda do
|
177
|
+
Gecode::SelectedSet::SelectedSetOperand.new(:foo, @set)
|
178
|
+
end.should raise_error(TypeError)
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'should raise error if set operand is not given' do
|
182
|
+
lambda do
|
183
|
+
Gecode::SelectedSet::SelectedSetOperand.new(@enum, :foo)
|
184
|
+
end.should raise_error(TypeError)
|
185
|
+
end
|
186
|
+
|
187
|
+
it_should_behave_like 'operand'
|
188
|
+
end
|
189
|
+
|
190
|
+
describe Gecode::SetElements::SetElementsOperand do
|
191
|
+
before do
|
192
|
+
model = Gecode::Model.new
|
193
|
+
@operand, @set = general_set_elements_operand(model)
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'should raise error if set operand is not given' do
|
197
|
+
lambda do
|
198
|
+
Gecode::SetElements::SetElementsOperand.new(:foo)
|
199
|
+
end.should raise_error(TypeError)
|
200
|
+
end
|
201
|
+
|
202
|
+
it_should_behave_like 'operand'
|
203
|
+
end
|
204
|
+
|
205
|
+
describe Gecode::SetEnum::SetEnumOperand do
|
206
|
+
before do
|
207
|
+
model = Gecode::Model.new
|
208
|
+
@operand, _ = general_set_enum_operand(model)
|
209
|
+
end
|
210
|
+
|
211
|
+
it_should_behave_like 'enum operand'
|
212
|
+
end
|
213
|
+
|
214
|
+
describe Gecode::FixnumEnum::FixnumEnumOperand do
|
215
|
+
before do
|
216
|
+
model = Gecode::Model.new
|
217
|
+
@operand, _ = general_fixnum_enum_operand(model)
|
218
|
+
end
|
219
|
+
|
220
|
+
it 'should raise error if constraint receiver is called' do
|
221
|
+
lambda do
|
222
|
+
@operand.must
|
223
|
+
end.should raise_error(NotImplementedError)
|
224
|
+
end
|
225
|
+
|
226
|
+
it_should_behave_like 'enum operand'
|
227
|
+
end
|
228
|
+
|
229
|
+
# High level sanity check.
|
230
|
+
describe 'operand combination' do
|
231
|
+
it 'should allow placing constraints on complicated combinations of operands' do
|
232
|
+
model = Gecode::Model.new
|
233
|
+
sets = model.set_var_array(2, [], 0..9)
|
234
|
+
set1, set2 = sets
|
235
|
+
(set1.size + set2.size).must == 5
|
236
|
+
set1.size.must > 1
|
237
|
+
set2.size.must > 1
|
238
|
+
model.branch_on sets
|
239
|
+
|
240
|
+
model.solve!
|
241
|
+
|
242
|
+
(set1.value.size + set2.value.size).should == 5
|
243
|
+
set1.value.size.should > 1
|
244
|
+
set2.value.size.should > 1
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'should allow placing constraints on complicated combinations of operands (2)' do
|
248
|
+
model = Gecode::Model.new
|
249
|
+
sets = model.set_var_array(3, [], 0..9)
|
250
|
+
set1, set2, set3 = sets
|
251
|
+
(set1.size + set2.size).must == (set3.size - set1.max)
|
252
|
+
set3.size.must > 3
|
253
|
+
set2.size.must < 3
|
254
|
+
set1.size.must > 0
|
255
|
+
model.branch_on sets
|
256
|
+
|
257
|
+
model.solve!
|
258
|
+
|
259
|
+
(set1.value.size + set2.value.size).should == (set3.value.size - set1.value.max)
|
260
|
+
set3.value.size.should > 3
|
261
|
+
set2.value.size.should < 3
|
262
|
+
set1.value.size.should > 0
|
263
|
+
end
|
264
|
+
end
|