I am still having an issue with the Boolean sum. The solver is essential converting the BoolVar into an integer.
var1 = solver.BoolVar('var1')
var2 = solver.BoolVar('var2')
var3 = solver.BoolVar('var3')
sum1 = solver.BoolVar('sum1')
solver.Add(sum1 == solver.Sum([var1, var2, var3]))
sum1 has a max value of 1, so only one of the vars can be true at a time...
I can, of course, set sum1 as an IntVar.
sum1 = solver.IntVar(0, 3, 'sum1')
but then I do not know how to set the coefficient in the objective function
objective = solver.Objective()
objective.SetCoefficient(sum1, 80)
This now sets all the vars to True, sum1 is three and the objective function comes out at 240.
I would like to add 80 if and only if sum1 is not 0.
Is there a way to do this? Or does break the linearity?
I was expecting the solver.Sum to obey Boolean Algebra:
0+0+0 = 0
1+0+0 = 1
1+1+0 = 1
1+1+1 = 0
Regards
Rhys