Closed GalPerelman closed 1 year ago
Update:
In the above example, the shape of b is in form of (n, 1)
print(b.shape)
>>> (4, 1)
When reshaping the vector to numpy (n, )
the problem is solved. For example:
b = np.squeeze(b)
print(b.shape)
>>> (4, )
Hi @GalPerelman, please note that RSOME is consistent with NumPy array operations, so in the example you provided, the left-hand-side is a one-dimensional array, which is recognized as a one-row array, with the shape to be (4, ). The right-hand-side array is a two-dimensional array, and its shape is (4, 1). According to the broadcasting rule of NumPy arrays, operations between the two arrays gives a two-dimensional array and its shape is (4, 4). That is why the constraints are duplicated. Please check this figure: https://numpy.org/doc/stable/_images/broadcasting_4.png
To fix this problem, you can reshape or squeeze the right-hand-side vector to be (4, ). Alternatively, we can reshape the left-hand-side array from (4, ) to (4, 1), then element-wise constraints are constructed without using broadcasting.
@XiongPengNUS Thank you for the clarification about the reasons behind this behavior.
Hi, I'm experiencing strange behavior with the package and wonder whether it is a mistake of mine or a bug Consider the following LHS matrix and RHS vector:
When I try to add the constraint to my model as:
Then, by using
model.do_math()
I get a matrix that duplicates the LHS for each value of the RHS vector (see below) instead of assigning the RHS values to the corresponding rows of the LHS matrix