I'm trying to build a sum based on binary variables and coefficients, but the resulting expression doesn't seem to be correct.
let weights = vec![1.1, 1.2, 1.0, 0.9];
let mut vars = variables!();
let xs = vars.add_vector(variable().binary(), weights.len());
let objective = Expression::sum((0..weights.len()).iter().map(|i| xs[i].mul(weights[i])));
I would expect the xs variables to interpreted as ones or zeroes in the sum, i.e., the objective being the sum of the weights of the variables set to 1. However, it appears that the objective is capped at a value smaller than the sum of the weights.
I'm trying to build a sum based on binary variables and coefficients, but the resulting expression doesn't seem to be correct.
I would expect the
xs
variables to interpreted as ones or zeroes in the sum, i.e., the objective being the sum of the weights of the variables set to 1. However, it appears that the objective is capped at a value smaller than the sum of the weights.