如何使用 Soplex 解决具有零 objective 函数的问题?

How to use Soplex to solve problems with a zero objective function?

我正在尝试使用 Soplex 通过 C++ 代码解决零 objective 函数的问题,但我遇到了错误。

我的主要代码是这样的:

int main(int argc, char* argv[])
{
   if (argc <= 1 || argc >= 3) /*Anything <=1 or >=3 arguments in command line will tell user the right way to use*/
  {
    std::cerr << "Usage: " << argv[0] << " [input_file]" << std::endl;
    return 1;
  }

   XLib::DIMACSCache cache;
   cache.read(argv[1]);
  
  /*Initialising Soplex object to store the LP relaxation*/
   int nvars = cache.nVariables(); //For use in making objective function and primal solution vector
   SoPlex mysoplex; //Initialising the Soplex object
   mysoplex.setIntParam(SoPlex::OBJSENSE, SoPlex::OBJSENSE_MINIMIZE); //Minimisation objective, min 0
   DSVectorRational obj_func(0); //Dynamic sparse vector for the objective function, 0 to initialise, can add more elements
   
   /*First, make the number of columns in the coefficient matrix and their bounds*/
   for (int i = 1; i<=nvars; ++i)
   {
      std::cout << i << std::endl; //Fails here 6/10/21
      mysoplex.addColRational(LPColRational(0, obj_func, 1, 0)); //mysoplex.addColRational(LPColRational(coefficient, obj_func, var_UB, var_LB))
   }
   std::cout << "Objective function made \n";

   ~Rest of main~
   return 0;
}

我遇到的错误是

main: soplex.hpp:2734: void soplex::SoPlexBase<R>::addColRational(const LPColRational&) [with R = double; soplex::LPColRational = soplex::LPColBase<soplex::Rational>]: Assertion `_rationalLP != 0' failed.
Aborted (core dumped)

我在实际案例中没有遇到任何问题,我使用了 addColRealLPColReal,但是解决问题所花费的时间太慢了。因此,我正在 Soplex 中试验 Rational 函数,看看速度是否有所提高。

有什么办法可以解决这个问题吗?谢谢!

有一个简单的解决方法,您需要设置:

mysoplex.setIntParam(SoPlex::SYNCMODE, SoPlex::SYNCMODE_AUTO);
mysoplex.setIntParam(SoPlex::SOLVEMODE, SoPlex::SOLVEMODE_RATIONAL);

但是,警告:在理性模式下解决问题几乎肯定会比正常情况下慢。