Multiplication of sparse 3D matrix with dense 2D decision variable matrix
進行中I have sparse COO 3D A matrix N*N*M (The third dimension is M) and dense 2D B matrix (N*N), which will be an optimization variable for my solver. I want to multiply A and B to obtain (N*N*M) matrix. Then I need to sum the elements of the resulting 3D matrix to create 2D matrix (N*N).
I am using pydata sparse library to create 3D sparse matrix.
My objective function is to minimize the sum of the elements of the multiplication of sparse A with decision variable matrix B.
How can I do this?
I used
np.sum(A*B)
as the objective function. However, I received the following error.
TypeError: operand type(s) all returned NotImplemented
from __array_ufunc__(<ufunc 'multiply'>, '__call__',
<COO: shape=(5, 1454, 1454), dtype=float64, nnz=100, fill_value=0.0>,
<(1454, 1454) matrix variable>): 'COO', 'MVar'
-
正式なコメント
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi Ker,
Please try to provide a small, reproducible example code with your data structures. PyData sparse does not seem to be a standard Python library, so your best bet is probably to loop over the matrix dimensions and create the objective function iteratively.
Cheers,
Matthias0
投稿コメントは受け付けていません。
コメント
2件のコメント