forum.alglib.net

ALGLIB forum
It is currently Thu Nov 14, 2024 8:38 am

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.



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Incosistent Objective Values Compared to Different Solvers
PostPosted: Thu Dec 21, 2023 4:06 pm 
Offline

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


Top
 Profile  
 
 Post subject: Re: Incosistent Objective Values Compared to Different Solve
PostPosted: Sat Dec 23, 2023 1:41 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 925
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
 Profile  
 
 Post subject: Re: Incosistent Objective Values Compared to Different Solve
PostPosted: Sat Dec 23, 2023 6:23 pm 
Offline

Joined: Sun Nov 19, 2023 7:23 pm
Posts: 4
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


Top
 Profile  
 
 Post subject: Re: Incosistent Objective Values Compared to Different Solve
PostPosted: Sun Jan 14, 2024 11:32 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 925
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
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group