Class: ORTools::CpModel

Inherits:
Object
  • Object
show all
Defined in:
lib/or_tools/cp_model.rb

Instance Method Summary collapse

Instance Method Details

#add(comparison) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/or_tools/cp_model.rb', line 3

def add(comparison)
  case comparison
  when Comparison
    method_name =
      case comparison.op
      when :==
        :add_equality
      when :!=
        :add_not_equal
      when :>
        :add_greater_than
      when :>=
        :add_greater_or_equal
      when :<
        :add_less_than
      when :<=
        :add_less_or_equal
      else
        raise ArgumentError, "Unknown operator: #{comparison.operator}"
      end

    send(method_name, comparison.left, comparison.right)
  when true
    add_bool_or([true_var])
  when false
    add_bool_or([])
  else
    raise TypeError, "Not supported: CpModel#add(#{comparison})"
  end
end

#inspectObject



38
39
40
# File 'lib/or_tools/cp_model.rb', line 38

def inspect
  to_s
end

#sum(arr) ⇒ Object



34
35
36
# File 'lib/or_tools/cp_model.rb', line 34

def sum(arr)
  Expression.new(arr)
end