I have been working with different formulations and variations of the bin packing problem. All of my experiments for this infamous problem were done with Python 3+ and cvxpy (vers 1.1.5). While testing my code I came across the following that IMHO is an inconsistency in defining a cvxpy constraint. Of course, I know that “True” has a value of “1”; but, there is only a single True for the 2nd constraint shown, while the 1st constraint is for m-True’s. The constraint in question has the following form:

\sum_{j=1}^n X_{i,j} = 1; \ i = 1,2,...,m

Here are two different forms of this constraint that I have used:

X = cvxpy.Variable((m,n),boolean=True)

u = numpy.ones((n,1))

e = numpy.ones((m,1))

cst = [X @ u == e] # works as expected (right side is an m x 1 array)

and the other,

cst = [X @ u == 1] # also works but why? (right side is a scalar)

This is the CVX forum. CVXPY is a different tool, and has a forum at https://groups.google.com/forum/#!forum/cvxpy

This is called broadcasting and is completely standard. It will apply your scalar constraint to each entry of the vector (or bigger shape).

Please be aware Mark that I am a member of the cvxpy forum and this is where I submitted my message – perhaps I am missing something. Please provide information on exactly how I should submit a question to the cvxpy forum.

Thanks

Thank you Michal. I am aware of “broadcasting” but was unaware that this feature was part of cvxpy. Would you please point me to where this information is provided in the cvxpy documentation.

Thanks again

If you are posting at https://groups.google.com/forum/#!forum/cvxpy and the post is showing up here, something is wrong. http://ask.cvxr.com/ is the CVX forum, NOT the CVXPY forum.

Sorry Mark,

I have now found the proper way to submit my comment to the cvxpy forum. I will try to not let this happen again

I have been looking through the API documentation for cvxpy and did find the following:

…shape (3, 2), then X[:,0] has shape (3,). CVXPY behavior follows NumPy semantics in all cases, with the exception that broadcasting only works when one argument is 0D. Several CVXPY atoms have been renamed: mul_elemwise to multiply ma…

What is 0D? and when was this change made?