ankane / or-tools-ruby

Operations research tools for Ruby
Apache License 2.0
179 stars 25 forks source link

Cannot sum bool vars into model #62

Closed joegaudet closed 3 months ago

joegaudet commented 3 months ago
          model = ORTools::CpModel.new
          a = model.new_bool_var('a')
          b = model.new_bool_var('b')
          c = model.new_bool_var('c')
          model.add([a,b,c].sum < 1)
 undefined method `+' for an instance of ORTools::BoolVar (NoMethodError)
ankane commented 3 months ago

Hi @joegaudet, for the constraint solver, you'll need to use model.sum([a, b, c]) instead of [a, b, c].sum.