Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable name with space in solution file #97

Open
igorbanfi opened this issue Jul 15, 2024 · 0 comments
Open

Variable name with space in solution file #97

igorbanfi opened this issue Jul 15, 2024 · 0 comments

Comments

@igorbanfi
Copy link

I noticed that solution files with variables that include space character are read incorrectly with SCIPreadSol.

Example code to reproduce.

#include <scip/scip.h>
#include <scip/scipdefplugins.h>

using namespace std;

int
main(
     int args,
     char ** argv
     )
{

   SCIP* scip = NULL;

   SCIP_CALL( SCIPcreate(&scip) );

   SCIP_CALL( SCIPincludeDefaultPlugins(scip) );

   SCIP_CALL( SCIPcreateProb(scip, "test", NULL, NULL, NULL, NULL, NULL, NULL, NULL) );

   SCIP_CALL( SCIPsetObjsense(scip, SCIP_OBJSENSE_MAXIMIZE) );

   SCIP_VAR* var;
   std::string var_name = "x   1";

   SCIP_CALL( SCIPcreateVar(scip, & var, var_name.c_str(), 0.0, 1.0, 1.0, SCIP_VARTYPE_BINARY, TRUE, FALSE, NULL, NULL, NULL, NULL, NULL) );

   SCIP_CALL( SCIPaddVar(scip, var) );

   SCIP_CALL( SCIPsolve(scip) );

   FILE *  file;
   if ((file = fopen("Solution.sol", "w")) != nullptr)
   {
      SCIP_CALL( SCIPprintBestSol(scip, file, FALSE) );
   }

   SCIP_CALL( SCIPfreeReoptSolve( scip ) );

   SCIP_CALL( SCIPreadSol(scip, "Solution.sol") );
   
   return EXIT_SUCCESS;
}

Output when trying to read the generated Solution.sol:

unknown variable <x> in line 2 of solution file <Solution.sol>
  (further unknown variables are ignored)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant