forum.alglib.net
http://forum.alglib.net/

Incosistent Objective Values Compared to Different Solvers
http://forum.alglib.net/viewtopic.php?f=2&t=4589
Page 1 of 1

Author:  burakozyurek [ Thu Dec 21, 2023 4:06 pm ]
Post subject:  Incosistent Objective Values Compared to Different Solvers

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;
            }
         }
         
         auto start = std::chrono::steady_clock::now();

         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);

Image

Author:  Sergey.Bochkanov [ Sat Dec 23, 2023 1:41 pm ]
Post subject:  Re: Incosistent Objective Values Compared to Different Solve

Hi!

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

Author:  burakozyurek [ Sat Dec 23, 2023 6:23 pm ]
Post subject:  Re: Incosistent Objective Values Compared to Different Solve

Hello Sergei! Thanks for your reply. Here are my results:

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

Author:  Sergey.Bochkanov [ Sun Jan 14, 2024 11:32 pm ]
Post subject:  Re: Incosistent Objective Values Compared to Different Solve

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?

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/