Hello everyone!
I am a biologist and trying to perform flux balance analysis(a biological simulation technique with constraint based linear optimization) with Alglib & C++. I was used minlpsetlc() function but I want to use minlpsetlc2() with sparse matrix because of performance issues. But minlpsetlc2() function returns a vector with size 3 instead of 13K(=columnsize). I was able to get vector with size 13K when using minlpsetlc. I expected that the function can inference the real size of my dense matrix which is approximately 8K x 13K. You can find my code below.
One other thing: I assumed minlpsetlc2() perform calculations way faster than the other one. If not it is unnecessary to use this function for me. Thanks!
Code:
std::vector<std::vector<double>> S(rowsize, std::vector<double>(colsize, 0));
int rowsize = 8460, colsize=12969;
alglib::sparsematrix A;
alglib::sparsecreate(rowsize, colsize, A);
// Fill sparse matrix
for (int i = 0; i < rowsize[code][/code]; i++)
{
for (int j = 0; j < colsize-1; j++)
{
S[i][j] = S_matrix[i * colsize + j];
alglib::sparseset(A, i, j, S[i][j]);
}
}
// ALGLIB PARAMETERS
alglib::real_1d_array x;
alglib::minlpreport rep;
alglib::minlpstate state;
// SET LINEAR SOLVER
alglib::minlpcreate(3, state);
// OBJECTIVE FUNCTION
std::vector<double> f(colsize, 0);
//f[12790] = -1;
alglib::real_1d_array C = "[]";
C.setcontent(colsize, f.data());
alglib::minlpsetcost(state, C);
std::vector<double> dummy(rowsize, 0);
alglib::real_1d_array d1 = "[]";
alglib::real_1d_array d2 = "[]";
d1.setcontent(rowsize-1, dummy.data());
d2.setcontent(rowsize-1, dummy.data());
minlpsetalgoipm(state, 0);
alglib::minlpsetlc2(state, A, d1, d2, rowsize);
//real_1d_array s = "[55557,3]";
//minlpsetscale(state,s);
// SOLVE
// alglib::minlpsetalgodss(state, 0.9);
alglib::minlpoptimize(state);
// FLUX OUYPUTS
alglib::minlpresults(state, x, rep);
// set_single_behavior(pCell, "cycle entry", x[9]);
// PRINT THE RESULTS
printf("%s\n", x.tostring(2).c_str());