Skip to content

Instantly share code, notes, and snippets.

@rschwarz
Created January 15, 2019 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rschwarz/4a64a7a690a44919d3ec88330021405b to your computer and use it in GitHub Desktop.
Save rschwarz/4a64a7a690a44919d3ec88330021405b to your computer and use it in GitHub Desktop.
use SCIPdelVar for variable which is still in constraint (failed assertion / segfault)
#include "scip/scip.h"
#include "scip/scipdefplugins.h"
// compile with:
// gcc -lscip del_var.c -o del_var
int main() {
SCIP* scip;
SCIP_CALL(SCIPcreate(&scip));
SCIP_CALL(SCIPincludeDefaultPlugins(scip));
SCIP_CALL(SCIPcreateProbBasic(scip, ""));
SCIP_VAR* var;
SCIP_CALL(SCIPcreateVarBasic(scip, &var, "", 0.0, 1.0, 0.0,
SCIP_VARTYPE_CONTINUOUS));
SCIP_CALL(SCIPaddVar(scip, var));
SCIP_CONS* cons;
SCIP_CALL(SCIPcreateConsBasicLinear(scip, &cons, "", 0, NULL, NULL, 0.0, 0.0));
SCIP_CALL(SCIPaddCoefLinear(scip, cons, var, 1.0));
SCIP_CALL(SCIPaddCons(scip, cons));
SCIP_Bool feasible;
SCIP_CALL(SCIPdelVar(scip, var, &feasible));
printf("SCIPdelVar feasible: %d\n", feasible);
SCIP_CALL(SCIPsolve(scip));
}
$ ./del_var
SCIPdelVar feasible: 1
[1] 18634 segmentation fault ./del_var
$ LD_LIBRARY_PATH=/home/rs/opt/scipoptsuite-6.0.0/build/lib ./del_var
SCIPdelVar feasible: 1
del_var: /home/rs/opt/scipoptsuite-6.0.0/scip/src/scip/cons_linear.c:1025: consdataCreate: Assertion `(*consdata)->vars[v] != NULL' failed.
[1] 21785 abort LD_LIBRARY_PATH=/home/rs/opt/scipoptsuite-6.0.0/build/lib ./del_var
@rschwarz
Copy link
Author

The output from the optimized SCIP is actually version 6.0.1. I don't think there is a difference to 6.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment