# forum.alglib.net

ALGLIB forum
 It is currently Thu Aug 15, 2024 9:02 pm

 All times are UTC

### Forum rules

1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Incosistent Objective Values Compared to Different SolversPosted: Thu Dec 21, 2023 4:06 pm

Joined: Sun Nov 19, 2023 7:23 pm
Posts: 4
Hello.
I am currently using minlp package from Alglib for Flux balance analysis. The problem is I am getting different values when compared to Alglib with Gurobi. Small model which containt only 19 equations return very close values. But for large-scale problems(~10K equations) the optimized values are completely different. Is it expected? Or am I missing something? Here are my codes and comparison for diffrent solvers.
Thanks!

Code:
alglib::sparsematrix A;
alglib::sparsecreate(real_row, real_col, A);
for (int i = 0; i < S_matrix.size(); i++)
{
{
// cout<<S_matrix[i][0]<<endl;
sparseset(A, S_matrix[i][0], S_matrix[i][1], S_matrix[i][2]);
}
}

// ALGLIB PARAMETERS
alglib::real_1d_array x;
alglib::minlpreport rep;
alglib::minlpstate state;

// SET LINEAR SOLVER
alglib::minlpcreate(real_col, state);

// OBJECTIVE FUNCTION
std::vector<double> f(real_col, 0);
f[13000] = -1;
alglib::real_1d_array C = "[]";
C.setcontent(real_col, f.data());
alglib::minlpsetcost(state, C);

// SET BOUNDS
alglib::real_1d_array bndl = "[]";
alglib::real_1d_array bndu = "[]";
for (int j = 0; j < reduced_reactions.size(); j++)
{

for (int i = 0; i < reduced_reactions[j].size(); i++)
{
if (reduced_reactions[0][i] == 0)
{
// cout<<reduced_reactions[0][i]<<endl;
lb[i] = 0;
ub[i] = 0;
}
}

bndl.setcontent(real_col, lb.data());
bndu.setcontent(real_col, ub.data());
alglib::minlpsetbc(state, bndl, bndu);

// SET LINEAR CONSTRAINTS(all is '=' in this case)
std::vector<double> lower(real_row, 0);
std::vector<double> upper(real_row, 0);
// lower[3356] = 0.8;
// upper[3356] = 1;
alglib::real_1d_array d1 = "[]";
alglib::real_1d_array d2 = "[]";
vector<double> d_vec(real_row, 0);
d1.setcontent(real_row, d_vec.data());
d2.setcontent(real_row, d_vec.data());

//SCALING
std::vector<double> scale(real_col, 1);
scale[13000] = 1;
alglib::real_1d_array s = "[]";
s.setcontent(real_col, scale.data());
// minlpsetscale(state, s);
// minlpsetalgodss(state, 0.0000001);
// minlpsetalgoipm(state, 0.001);

alglib::minlpsetlc2(state, A, d1, d2, real_row);

// SOLVE
alglib::minlpoptimize(state);

Top

 Post subject: Re: Incosistent Objective Values Compared to Different SolvePosted: Sat Dec 23, 2023 1:41 pm

Joined: Fri May 07, 2010 7:06 am
Posts: 922
Hi!

Would you like to tell me the following values from the MINLP report:
* rep.primalerror
* rep.dualerror
* rep.slackerror
* rep.iterationscount
* rep.terminationtype

Top

 Post subject: Re: Incosistent Objective Values Compared to Different SolvePosted: Sat Dec 23, 2023 6:23 pm

Joined: Sun Nov 19, 2023 7:23 pm
Posts: 4

primalerror: 1.83434e-10
dualerror: 1.04083e-17
slackerror: 6.64747e-16
iterationscount: 16087
terminationtype: 1

Top

 Post subject: Re: Incosistent Objective Values Compared to Different SolvePosted: Sun Jan 14, 2024 11:32 pm

Joined: Fri May 07, 2010 7:06 am
Posts: 922
Hi! Sorry, probably my reply is too late, I accidentally marked the topic as read and did not notice your update. So I mostly write for other people who read this topic.

The solver seems to converge well, primal/dual/slackness errors are low. The situation you described may happen if you optimize for one linear function, and measure value of some other linear function. Is it the case?

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 4 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Bing [Bot] and 86 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for: