[AMPL 24692] matlab setMatrix need much time

Dear all,

I use matlab to send a matrix data to ampl by DataFrame and setMatrix.
My matrix dim is 460035*2, however, Matlab run function df.setMatrix need much time
(about 1200 seconds),while the solving time of the optimization problem is just 2 seconds.

I want to know whether there are any ways to accelerate the runtime of setMatrix?

Thanks for reporting this issue. We were able to reproduce it and we are currently looking into a way to speed up this operation. Building the dataframe without using setMatrix may however be the fastest approach here as the transformation from 4-D matrix from Matlab to table with 4 indices and 168000 rows is what is taking a long time here.

We have just released amplapi v2.1.4-20230719 with the performance of DataFrame.setMatrix substantially improved. Loading the 168000 rows takes around 2 seconds now.

A = randn(4,600,35,2);
A1 = num2cell(1:4);
A2 = num2cell(1:600);
A3 = num2cell(1:35);
A4 = num2cell(1:2);
df = DataFrame(4, ‘A1’, ‘A2’, ‘A3’, ‘A4’, ‘Value’);
df.setMatrix(A, A1, A2, A3, A4);
df.getNumRows()

ans =

168000