gecoder 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/CHANGES +11 -0
  2. data/README +12 -1
  3. data/example/example_helper.rb +1 -0
  4. data/example/magic_sequence.rb +43 -0
  5. data/example/queens.rb +43 -0
  6. data/example/raw_bindings.rb +42 -0
  7. data/example/send_more_money.rb +43 -0
  8. data/example/sudoku.rb +65 -0
  9. data/ext/missing.cpp +15 -21
  10. data/ext/missing.h +14 -20
  11. data/ext/vararray.cpp +14 -20
  12. data/ext/vararray.h +18 -22
  13. data/lib/gecoder/bindings/bindings.rb +1979 -1969
  14. data/lib/gecoder/interface/binding_changes.rb +123 -2
  15. data/lib/gecoder/interface/constraints/bool/boolean.rb +80 -65
  16. data/lib/gecoder/interface/constraints/bool_enum/boolean.rb +59 -0
  17. data/lib/gecoder/interface/constraints/bool_enum_constraints.rb +8 -0
  18. data/lib/gecoder/interface/constraints/bool_var_constraints.rb +42 -0
  19. data/lib/gecoder/interface/constraints/int/arithmetic.rb +21 -44
  20. data/lib/gecoder/interface/constraints/int/domain.rb +6 -4
  21. data/lib/gecoder/interface/constraints/int_enum/arithmetic.rb +18 -44
  22. data/lib/gecoder/interface/constraints/int_enum/count.rb +3 -18
  23. data/lib/gecoder/interface/constraints/int_enum/distinct.rb +4 -16
  24. data/lib/gecoder/interface/constraints/int_enum/element.rb +9 -20
  25. data/lib/gecoder/interface/constraints/int_var_constraints.rb +28 -0
  26. data/lib/gecoder/interface/constraints/set/cardinality.rb +56 -0
  27. data/lib/gecoder/interface/constraints/set/domain.rb +66 -0
  28. data/lib/gecoder/interface/constraints/set/relation.rb +125 -0
  29. data/lib/gecoder/interface/constraints/set_var_constraints.rb +37 -0
  30. data/lib/gecoder/interface/constraints.rb +229 -65
  31. data/lib/gecoder/interface/enum_wrapper.rb +42 -11
  32. data/lib/gecoder/interface/model.rb +75 -0
  33. data/lib/gecoder/interface/search.rb +4 -9
  34. data/lib/gecoder/interface/variables.rb +36 -2
  35. data/lib/gecoder/version.rb +1 -1
  36. data/specs/bool_var.rb +58 -0
  37. data/specs/constraints/arithmetic.rb +91 -90
  38. data/specs/constraints/bool_enum.rb +130 -0
  39. data/specs/constraints/boolean.rb +95 -2
  40. data/specs/constraints/cardinality.rb +127 -0
  41. data/specs/constraints/constraint_helper.rb +91 -0
  42. data/specs/constraints/constraints.rb +31 -0
  43. data/specs/constraints/element.rb +43 -72
  44. data/specs/constraints/{domain.rb → int_domain.rb} +4 -0
  45. data/specs/constraints/{relation.rb → int_relation.rb} +0 -0
  46. data/specs/constraints/set_domain.rb +165 -0
  47. data/specs/constraints/set_relation.rb +181 -0
  48. data/specs/enum_wrapper.rb +13 -2
  49. data/specs/int_var.rb +33 -1
  50. data/specs/model.rb +80 -0
  51. data/specs/set_var.rb +39 -0
  52. data/specs/spec_helper.rb +35 -0
  53. data/specs/tmp +11 -124
  54. data/tasks/distribution.rake +1 -1
  55. data/vendor/rust/rust/class.rb +10 -10
  56. data/vendor/rust/rust/constants.rb +1 -1
  57. data/vendor/rust/rust/function.rb +5 -5
  58. data/vendor/rust/rust/type.rb +1 -1
  59. data/vendor/rust/test/constants.rb +1 -0
  60. data/vendor/rust/test/cppclass.cc +5 -0
  61. data/vendor/rust/test/cppclass.hh +4 -0
  62. data/vendor/rust/test/lib/extension-test.rb +1 -1
  63. data/vendor/rust/test/operators.cc +41 -0
  64. data/vendor/rust/test/operators.hh +39 -0
  65. data/vendor/rust/test/operators.rb +39 -0
  66. data/vendor/rust/test/test-cwrapper.rb +3 -0
  67. data/vendor/rust/test/test-operators.rb +42 -0
  68. metadata +31 -4
data/CHANGES CHANGED
@@ -1,3 +1,14 @@
1
+ == Version 0.5.0
2
+ This release adds set variables and some of their constraints, along with the
3
+ last of the boolean constraints.
4
+
5
+ * Added exclusive or and implication.
6
+ * Added conjunction and disjunction for boolean enumerations.
7
+ * Added set variables. They are created using Model{#set_var, #set_var_array, #set_var_matrix}.
8
+ * Added domain constraints for set variables.
9
+ * Added relation constraints for set variables.
10
+ * Added set cardinality constraints.
11
+
1
12
  == Version 0.4.0
2
13
  This release adds most of the constraints supported by Gecode for integer
3
14
  variables.
data/README CHANGED
@@ -22,11 +22,22 @@ instructions.
22
22
 
23
23
  gem install gecoder
24
24
 
25
- === Building the gem
25
+ === Installing from source using gem
26
26
 
27
27
  rake gem
28
28
  gem install pkg/gecoder-0.x.x.gem
29
29
 
30
+ === Installing from source without using gem
31
+
32
+ "gecode.so" might have another extension depending on which platform it's
33
+ generated on (replace the extension in the following commands with whatever
34
+ extension it's given).
35
+
36
+ cd ext
37
+ ruby extconf.rb
38
+ make
39
+ mv gecode.so ../lib/
40
+
30
41
  == Running the tests
31
42
 
32
43
  rake specs
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + '/../lib/gecoder'
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/example_helper'
2
+
3
+ # Solves the magic sequence problem.
4
+ class MagicSequence < Gecode::Model
5
+ # n is the length of the sequence.
6
+ def initialize(n)
7
+ # The i:th variable represents the value of the i:th element in the
8
+ # sequence.
9
+ @sequence = int_var_array(n, 0...n)
10
+
11
+ # The basic requirement to qualify as a magic sequence.
12
+ n.times{ |i| @sequence.count(i).must == @sequence[i] }
13
+
14
+ # The following are implied constraints. They do not affect which
15
+ # assignments are solutions, but they do help prune the search space
16
+ # quicker.
17
+
18
+ # The sum must be n. This follows from that there are exactly n elements and
19
+ # that the sum of all elements are the number of occurrences in total, i.e.
20
+ # the number of elements.
21
+ @sequence.sum.must == n
22
+
23
+ # sum(seq[i] * (i-1)) must equal 0 because sum(seq[i]) = n as seen above
24
+ # and sum(i*seq[i]) is just another way to compute sum(seq[i]). So we get
25
+ # sum(seq[i] * (i-1)) = sum(seq[i]) - sum(i*seq[i]) = n - n = 0
26
+ @sequence.zip((-1...n).to_a).map{ |element, c| element*c }.sum.must == 0
27
+
28
+ branch_on @sequence, :variable => :smallest_degree, :value => :split_max
29
+ end
30
+
31
+ def to_s
32
+ @sequence.map{ |element| element.val }.join(', ')
33
+ end
34
+ end
35
+
36
+ class Array
37
+ # Sums all the elements in the array using #+ .
38
+ def sum
39
+ inject{ |sum, element| sum + element }
40
+ end
41
+ end
42
+
43
+ puts((MagicSequence.new(500).solve! || 'Failed').to_s)
data/example/queens.rb ADDED
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/example_helper'
2
+
3
+ # Solves the n-queens problem: http://en.wikipedia.org/wiki/Nqueens . No attempt
4
+ # to break the involved symmetries is made.
5
+ class NQueens < Gecode::Model
6
+ def initialize(n)
7
+ @size = n
8
+
9
+ # The row number that the queen in the i:th column has. By using this as
10
+ # our variables we already make sure that no two queens are in the same
11
+ # column.
12
+ @queen_rows = int_var_array(n, 0...n)
13
+
14
+ # Set up the constraints
15
+ # Queens must not be in the same diagonal (negative slope).
16
+ @queen_rows.with_offsets((0...n).to_a).must_be.distinct
17
+ # Queens must not be in the same diagonal (positive slope).
18
+ @queen_rows.with_offsets((0...n).to_a.reverse).must_be.distinct
19
+ # Queens must not be in the same row.
20
+ @queen_rows.must_be.distinct
21
+
22
+ # Branching, we use first-fail heuristic.
23
+ branch_on @queen_rows, :variable => :smallest_size, :value => :min
24
+ end
25
+
26
+ # Displays the assignment as a chessboard with queens denoted by 'x'.
27
+ def to_s
28
+ rows = @queen_rows.map{ |var| var.val }
29
+
30
+ separator = '+' << '-' * (3 * @size + (@size - 1)) << "+\n"
31
+ res = (0...@size).inject(separator) do |s, i|
32
+ (0...@size).inject(s + '|') do |s, j|
33
+ s << " #{rows[j] == i ? 'x' : ' '} |"
34
+ end << "\n" << separator
35
+ end
36
+ end
37
+ end
38
+
39
+ # Print the first solution. Note that there are 92 solutions, but only 12
40
+ # are rotationally distinct. For any serious use one should place additional
41
+ # constraints to eliminate those symmetries.
42
+ NQueens.new( (ARGV[0] || 8).to_i ).solution{ |sol| puts sol.to_s }
43
+
@@ -0,0 +1,42 @@
1
+ require File.dirname(__FILE__) + '/example_helper'
2
+
3
+ # An example of using the raw bindings. Solves the send+more=money problem.
4
+
5
+ # Variables
6
+ space = Gecode::Raw::Space.new
7
+ letters = Gecode::Raw::IntVarArray.new(space, 8, 0, 9)
8
+ space.own(letters, 'letters')
9
+ s, e, n, d, m, o, r, y = (0..7).to_a.map{ |i| letters.at(i) }
10
+
11
+ # Constraints
12
+ Gecode::Raw::post(space, (s * 1000 + e * 100 + n * 10 + d +
13
+ m * 1000 + o * 100 + r * 10 + e).
14
+ equal(m * 10000 + o * 1000 + n * 100 + e * 10 + y ),
15
+ Gecode::Raw::ICL_DEF)
16
+ Gecode::Raw::rel(space, s, Gecode::Raw::IRT_NQ, 0, Gecode::Raw::ICL_DEF)
17
+ Gecode::Raw::rel(space, m, Gecode::Raw::IRT_NQ, 0, Gecode::Raw::ICL_DEF)
18
+ Gecode::Raw::distinct(space, letters, Gecode::Raw::ICL_DEF)
19
+
20
+ # Branching.
21
+ Gecode::Raw::branch(space, letters,
22
+ Gecode::Raw::BVAR_SIZE_MIN, Gecode::Raw::BVAL_MIN)
23
+
24
+ # Search
25
+ COPY_DIST = 16
26
+ ADAPTATION_DIST = 4
27
+ dfs = Gecode::Raw::DFS.new(space, COPY_DIST, ADAPTATION_DIST,
28
+ Gecode::Raw::Search::Stop.new)
29
+
30
+ space = dfs.next
31
+ if space.nil?
32
+ puts 'Failed'
33
+ else
34
+ puts 'Solution:'
35
+ correct_letters = space.intVarArray('letters')
36
+ arr = []
37
+ correct_letters.size.times do |i|
38
+ arr << correct_letters.at(i).val
39
+ end
40
+ puts arr.join(' ')
41
+ end
42
+
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/example_helper'
2
+
3
+ # Solves the send+more=money problem:
4
+ # http://en.wikipedia.org/wiki/Send%2Bmore%3Dmoney
5
+ class SendMoreMoney < Gecode::Model
6
+ def initialize
7
+ # Set up the variables, 8 letters with domain 0..9.
8
+ s,e,n,d,m,o,r,y = @letters = int_var_array(8, 0..9)
9
+
10
+ # Set up the constraints.
11
+ # The equation must hold.
12
+ (equation_row(s, e, n, d) + equation_row(m, o, r, e)).must ==
13
+ equation_row(m, o, n, e, y)
14
+
15
+ # The initial letters may not be 0.
16
+ s.must_not == 0
17
+ m.must_not == 0
18
+
19
+ # All letters must be assigned different digits.
20
+ @letters.must_be.distinct
21
+
22
+ # Set the branching.
23
+ branch_on @letters, :variable => :smallest_size, :value => :min
24
+ end
25
+
26
+ def to_s
27
+ %w{s e n d m o r y}.zip(@letters).map do |text, letter|
28
+ "#{text}: #{letter.val}"
29
+ end.join(', ')
30
+ end
31
+
32
+ private
33
+
34
+ # A helper to make the linear equation a bit tidier. Takes a number of
35
+ # variables and computes the linear combination as if the variable
36
+ # were digits in a base 10 number. E.g. x,y,z becomes
37
+ # 100*x + 10*y + z .
38
+ def equation_row(*variables)
39
+ variables.inject{ |result, variable| variable + result*10 }
40
+ end
41
+ end
42
+
43
+ puts SendMoreMoney.new.solve!.to_s
data/example/sudoku.rb ADDED
@@ -0,0 +1,65 @@
1
+ require File.dirname(__FILE__) + '/example_helper'
2
+
3
+ # Solves the sudoku problem: http://en.wikipedia.org/wiki/Soduko
4
+ class Sudoku < Gecode::Model
5
+ # Takes a matrix of values in the initial sudoku, 0 if the square is empty.
6
+ # The matrix must be square with a square size.
7
+ def initialize(values)
8
+ # Verify that the input is of a valid size.
9
+ @size = n = values.row_size
10
+ sub_matrix_size = Math.sqrt(n).round
11
+ unless values.square? and sub_matrix_size**2 == n
12
+ raise ArgumentError, 'Incorrect value matrix size.'
13
+ end
14
+ sub_count = sub_matrix_size
15
+
16
+ # Create the squares and initialize them.
17
+ @squares = int_var_matrix(n, n, 1..n)
18
+ values.row_size.times do |i|
19
+ values.column_size.times do |j|
20
+ @squares[i,j].must == values[i,j] unless values[i,j] == 0
21
+ end
22
+ end
23
+
24
+ # Constraints.
25
+ n.times do |i|
26
+ # All rows must contain distinct numbers.
27
+ @squares.row(i).must_be.distinct(:strength => :domain)
28
+ # All columns must contain distinct numbers.
29
+ @squares.column(i).must_be.distinct(:strength => :domain)
30
+ # All sub-matrices must contain distinct numbers.
31
+ @squares.minor(
32
+ (i % sub_count) * sub_matrix_size,
33
+ sub_matrix_size,
34
+ (i / sub_count) * sub_matrix_size,
35
+ sub_matrix_size).must_be.distinct(:strength => :domain)
36
+ end
37
+
38
+ # Branching, we use first-fail heuristic.
39
+ branch_on @squares, :variable => :smallest_size, :value => :min
40
+ end
41
+
42
+ # Display the solved sudoku in a grid.
43
+ def to_s
44
+ separator = '+' << '-' * (3 * @size + (@size - 1)) << "+\n"
45
+ res = (0...@size).inject(separator) do |s, i|
46
+ (0...@size).inject(s + '|') do |s, j|
47
+ s << " #{@squares[i,j].val} |"
48
+ end << "\n" << separator
49
+ end
50
+ end
51
+ end
52
+
53
+ given_squares = Matrix[
54
+ [0,0,0, 2,0,5, 0,0,0],
55
+ [0,9,0, 0,0,0, 7,3,0],
56
+ [0,0,2, 0,0,9, 0,6,0],
57
+
58
+ [2,0,0, 0,0,0, 4,0,9],
59
+ [0,0,0, 0,7,0, 0,0,0],
60
+ [6,0,9, 0,0,0, 0,0,1],
61
+
62
+ [0,8,0, 4,0,0, 1,0,0],
63
+ [0,6,3, 0,0,0, 0,8,0],
64
+ [0,0,0, 6,0,8, 0,0,0]]
65
+ puts Sudoku.new(given_squares).solve!.to_s
data/ext/missing.cpp CHANGED
@@ -1,26 +1,20 @@
1
- /** Copyright (c) 2007, David Cuadrado <krawek@gmail.com>
2
- * All rights reserved.
1
+ /**
2
+ * Gecode/R, a Ruby interface to Gecode.
3
+ * Copyright (C) 2007 The Gecode/R development team.
3
4
  *
4
- * Redistribution and use in source and binary forms, with or without
5
- * modification, are permitted provided that the following conditions are met:
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
6
9
  *
7
- * 1. Redistributions of source code must retain the above copyright notice,
8
- * this list of conditions and the following disclaimer.
9
- * 2. Redistributions in binary form must reproduce the above copyright
10
- * notice, this list of conditions and the following disclaimer in the
11
- * documentation and/or other materials provided with the distribution.
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
12
14
  *
13
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
17
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23
- * POSSIBILITY OF SUCH DAMAGE.
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
18
  **/
25
19
 
26
20
  #include "missing.h"
@@ -164,7 +158,7 @@ MSpace::MSpace(MSpace& s, bool share) : Gecode::Space(share, s), d(new Private)
164
158
 
165
159
  for(it = s.d->setArrays.begin(); it != eend; it++)
166
160
  {
167
- Gecode::MSetVarArray *sva = new Gecode::MSetVarArray;
161
+ Gecode::MSetVarArray *sva = new Gecode::MSetVarArray(this, (*it).second->ptr()->size());
168
162
  sva->ptr()->update(this, share, *(*it).second->ptr() );
169
163
 
170
164
  own(sva, (*it).first);
data/ext/missing.h CHANGED
@@ -1,26 +1,20 @@
1
- /** Copyright (c) 2007, David Cuadrado <krawek@gmail.com>
2
- * All rights reserved.
1
+ /**
2
+ * Gecode/R, a Ruby interface to Gecode.
3
+ * Copyright (C) 2007 The Gecode/R development team.
3
4
  *
4
- * Redistribution and use in source and binary forms, with or without
5
- * modification, are permitted provided that the following conditions are met:
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
6
9
  *
7
- * 1. Redistributions of source code must retain the above copyright notice,
8
- * this list of conditions and the following disclaimer.
9
- * 2. Redistributions in binary form must reproduce the above copyright
10
- * notice, this list of conditions and the following disclaimer in the
11
- * documentation and/or other materials provided with the distribution.
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
12
14
  *
13
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
17
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23
- * POSSIBILITY OF SUCH DAMAGE.
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
18
  **/
25
19
 
26
20
  #ifndef __MISSING_CLASSES_H
data/ext/vararray.cpp CHANGED
@@ -1,26 +1,20 @@
1
- /** Copyright (c) 2007, David Cuadrado <krawek@gmail.com>
2
- * All rights reserved.
1
+ /**
2
+ * Gecode/R, a Ruby interface to Gecode.
3
+ * Copyright (C) 2007 The Gecode/R development team.
3
4
  *
4
- * Redistribution and use in source and binary forms, with or without
5
- * modification, are permitted provided that the following conditions are met:
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
6
9
  *
7
- * 1. Redistributions of source code must retain the above copyright notice,
8
- * this list of conditions and the following disclaimer.
9
- * 2. Redistributions in binary form must reproduce the above copyright
10
- * notice, this list of conditions and the following disclaimer in the
11
- * documentation and/or other materials provided with the distribution.
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
12
14
  *
13
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
17
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23
- * POSSIBILITY OF SUCH DAMAGE.
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
18
  **/
25
19
 
26
20
  #include "vararray.h"
data/ext/vararray.h CHANGED
@@ -1,30 +1,24 @@
1
- /** Copyright (c) 2007, David Cuadrado <krawek@gmail.com>
2
- * All rights reserved.
1
+ /**
2
+ * Gecode/R, a Ruby interface to Gecode.
3
+ * Copyright (C) 2007 The Gecode/R development team.
3
4
  *
4
- * Redistribution and use in source and binary forms, with or without
5
- * modification, are permitted provided that the following conditions are met:
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
6
9
  *
7
- * 1. Redistributions of source code must retain the above copyright notice,
8
- * this list of conditions and the following disclaimer.
9
- * 2. Redistributions in binary form must reproduce the above copyright
10
- * notice, this list of conditions and the following disclaimer in the
11
- * documentation and/or other materials provided with the distribution.
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
12
14
  *
13
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
17
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23
- * POSSIBILITY OF SUCH DAMAGE.
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
18
  **/
25
19
 
26
20
  #ifndef _VARARRAY_H
27
- #define _VARARRAT_H
21
+ #define _VARARRAY_H
28
22
 
29
23
  #include <gecode/int.hh>
30
24
  #include <gecode/set.hh>
@@ -95,7 +89,7 @@ class MBoolVarArray : public MVarArray
95
89
  Gecode::BoolVar &at(int index);
96
90
  Gecode::BoolVar &operator[](int index);
97
91
 
98
- void push(const Gecode::BoolVar& intvar);
92
+ void push(const Gecode::BoolVar& boolvar);
99
93
 
100
94
  void debug() const;
101
95
 
@@ -133,6 +127,8 @@ class MSetVarArray : public MVarArray
133
127
  Gecode::SetVar &at(int index);
134
128
  Gecode::SetVar &operator[](int index);
135
129
 
130
+ void push(const Gecode::SetVar& setvar);
131
+
136
132
  void debug() const;
137
133
 
138
134
  private: