Scippy

SCIP

Solving Constraint Integer Programs

Creating, capturing, releasing, and adding data objects

Data objects (variables, constraints, rows, ... ) are subject to reference counting to avoid expensive copying operations. This concept is similar to smart pointers. Creating such an object (e.g., by calling SCIPcreateVar()) will set the reference counter to one. Capturing an object (e.g., by calling SCIPcaptureVar()) increases the reference counter, releasing it (e.g., by calling SCIPreleaseVar()) decreases the counter. If the reference counter gets zero, the object will be destroyed automatically.

Remember that a created data object is automatically captured. If the user doesn't need the object anymore, (s)he has to call the object's release method.

When a data object is added to SCIP (e.g., by calling SCIPaddVar()) , it is captured again, such that a release call does not destroy the object. If SCIP doesn't need the object anymore, it is automatically released.

E.g., if the user calls

SCIPcreateVar(); // reference counter 1
SCIPaddVar(); // reference counter 2
SCIPreleaseVar(); // reference counter 1
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
Definition: scip_prob.c:1668
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
Definition: scip_var.c:1248
SCIP_RETCODE SCIPcreateVar(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_DECL_VARCOPY((*varcopy)), SCIP_VARDATA *vardata)
Definition: scip_var.c:114

the reference counter will be 1 afterwards, and the variable will be destroyed, if SCIP frees the problem. If the user wants to use this variable, e.g. for extracting statistics after SCIP was finished, the user must not call SCIPreleaseVar() right after adding the variable, but before terminating the program.