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

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.