I am trying to use Soplex to solve a problem with zero objective function through C++ code, but I face an error.
My main code is this:
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;
}
The error I faced is
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)
I had no problems doing this for the real case, where I used addColReal
and LPColReal
, but the time taken to solve the problem was too slow. Thus I am experimenting with the Rational functions in Soplex to see if the speed improves.
Is there any way to fix this issue? Thank you!
There is an easy fix for this, you need to set:
mysoplex.setIntParam(SoPlex::SYNCMODE, SoPlex::SYNCMODE_AUTO);
mysoplex.setIntParam(SoPlex::SOLVEMODE, SoPlex::SOLVEMODE_RATIONAL);
However, a warning: Solving the problem in rational mode will almost certainly be slower than normally.