Optimization for binary weights