Scippy

SCIP

Solving Constraint Integer Programs

stpbitset.h File Reference

Detailed Description

header only, simple implementation of a bitset

Author
Daniel Rehfeldt

Implements a simple bitset. Should be set to NULL if undefined. NOTE: for efficiency reasons the bitset type is based on an STP_Vector and thus uses a non-SCIP-standard allocation method. In this way we avoid indirections, because we directly access the raw array. todo if too slow use extra fixed-size vector that uses standard memory allocs, or even cache-aligned mallocs

Definition in file stpbitset.h.

#include "scip/scip.h"
#include "stpvector.h"

Go to the source code of this file.

Macros

#define STP_Bitset   STP_Vectype(uint64_t)
 

Functions

static int bitsetinternalPopcount (uint64_t number)
 
static STP_Bitset stpbitset_new (SCIP *scip, int maxnbits)
 
static void stpbitset_free (SCIP *scip, STP_Bitset *bitset)
 
static int stpbitset_getCapacity (STP_Bitset bitset)
 
static void stpbitset_setBitTrue (STP_Bitset bitset, int index)
 
static void stpbitset_setBitFalse (STP_Bitset bitset, int index)
 
static SCIP_Bool stpbitset_setsAreCompatible (STP_Bitset bitset1, STP_Bitset bitset2)
 
static SCIP_Bool stpbitset_haveIntersection (STP_Bitset bitset1, STP_Bitset bitset2)
 
static SCIP_Bool stpbitset_areEqual (STP_Bitset bitset1, STP_Bitset bitset2)
 
static SCIP_Bool stpbitset_bitIsTrue (STP_Bitset bitset, int index)
 
static int stpbitset_getPopcount (STP_Bitset bitset)
 
static STP_Bitset stpbitset_newCopy (SCIP *scip, STP_Bitset bitsetOrg)
 
static void stpbitset_and (SCIP *scip, STP_Bitset bitset1, STP_Bitset bitset2, STP_Bitset bitsetAnd)
 
static void stpbitset_or (SCIP *scip, STP_Bitset bitset1, STP_Bitset bitset2, STP_Bitset bitsetOr)
 
static STP_Bitset stpbitset_newAnd (SCIP *scip, STP_Bitset bitset1, STP_Bitset bitset2)
 
static STP_Bitset stpbitset_newOr (SCIP *scip, STP_Bitset bitset1, STP_Bitset bitset2)
 
static STP_Bitset stpbitset_newXor (SCIP *scip, STP_Bitset bitset1, STP_Bitset bitset2)
 
static STP_Bitset stpbitset_newNot (SCIP *scip, STP_Bitset bitset1, int size)
 
static STP_Bitset stpbitset_newAllTrue (SCIP *scip, int maxnbits)
 
static void stpbitset_print (STP_Bitset bitset)
 
static SCIP_Bool stpbitset_GT (STP_Bitset bitset1, STP_Bitset bitset2)
 
static SCIP_Bool stpbitset_LT (STP_Bitset bitset1, STP_Bitset bitset2)
 

Macro Definition Documentation

◆ STP_Bitset

Function Documentation

◆ bitsetinternalPopcount()

static int bitsetinternalPopcount ( uint64_t  number)
inlinestatic

todo: do that more efficiently; currently just a text-book implementation. probably want to have case distinction for compilers and use intrinsics at least for gcc, clang, and intel

Parameters
numberto get popcount for

Definition at line 51 of file stpbitset.h.

References number.

Referenced by stpbitset_getPopcount().

◆ stpbitset_new()

static STP_Bitset stpbitset_new ( SCIP scip,
int  maxnbits 
)
inlinestatic

initializes clean (all-0) bitset and returns it

Parameters
scipSCIP data structure
maxnbitssize of bitset

Definition at line 75 of file stpbitset.h.

References NULL, STP_Bitset, StpVecPushBack, and StpVecReserve.

Referenced by dpiterAddNewPrepare(), dpsolverInitData(), stpbitset_newAllTrue(), stpbitset_newAnd(), stpbitset_newCopy(), stpbitset_newNot(), stpbitset_newOr(), and stpbitset_newXor().

◆ stpbitset_free()

static void stpbitset_free ( SCIP scip,
STP_Bitset bitset 
)
inlinestatic

frees

Parameters
scipSCIP data structure
bitsetbitset pointer

Definition at line 100 of file stpbitset.h.

References NULL, and StpVecFree.

Referenced by combineWithIntersecting(), dpiterAddNewPrepare(), dpiterFinalizeSol(), dpiterPopSol(), dpmiscFree(), dpterms_dpsubsolFree(), dpterms_streeFree(), subtreesAddNewFinalize(), and updateIncumbent().

◆ stpbitset_getCapacity()

static int stpbitset_getCapacity ( STP_Bitset  bitset)
inlinestatic

◆ stpbitset_setBitTrue()

static void stpbitset_setBitTrue ( STP_Bitset  bitset,
int  index 
)
inlinestatic

sets bit to TRUE (1)

Parameters
bitsetbitset
indexbit index

Definition at line 129 of file stpbitset.h.

References stpbitset_getCapacity().

Referenced by dpiterAddNewPrepare(), dpsolverInitData(), and stpbitset_newAllTrue().

◆ stpbitset_setBitFalse()

static void stpbitset_setBitFalse ( STP_Bitset  bitset,
int  index 
)
inlinestatic

sets bit to FALSE (0)

Parameters
bitsetbitset
indexbit index

Definition at line 143 of file stpbitset.h.

References stpbitset_getCapacity().

◆ stpbitset_setsAreCompatible()

static SCIP_Bool stpbitset_setsAreCompatible ( STP_Bitset  bitset1,
STP_Bitset  bitset2 
)
inlinestatic

◆ stpbitset_haveIntersection()

static SCIP_Bool stpbitset_haveIntersection ( STP_Bitset  bitset1,
STP_Bitset  bitset2 
)
inlinestatic

do bitsets (of same size) intersect?

Parameters
bitset1bitset
bitset2bitset

Definition at line 177 of file stpbitset.h.

References FALSE, stpbitset_setsAreCompatible(), StpVecGetSize, and TRUE.

Referenced by STP_Vectype(), and streeCollectIntersects().

◆ stpbitset_areEqual()

static SCIP_Bool stpbitset_areEqual ( STP_Bitset  bitset1,
STP_Bitset  bitset2 
)
inlinestatic

are bitsets the same?

Parameters
bitset1bitset
bitset2bitset

Definition at line 200 of file stpbitset.h.

References FALSE, stpbitset_setsAreCompatible(), StpVecGetSize, and TRUE.

Referenced by dpiterPopSol().

◆ stpbitset_bitIsTrue()

static SCIP_Bool stpbitset_bitIsTrue ( STP_Bitset  bitset,
int  index 
)
inlinestatic

is bit at given index set?

Parameters
bitsetbitset
indexbit index

Definition at line 223 of file stpbitset.h.

References FALSE, stpbitset_getCapacity(), and TRUE.

Referenced by allExtensionsAreInvalid(), dpiterGetNextSol(), insertData(), nodeIsNonSolTerm(), STP_Vectype(), stpbitset_newAllTrue(), stpbitset_newNot(), stpbitset_print(), and streeCollectIntersects().

◆ stpbitset_getPopcount()

static int stpbitset_getPopcount ( STP_Bitset  bitset)
inlinestatic

gets number of 1-bits

Parameters
bitsetbitset

Definition at line 247 of file stpbitset.h.

References bitsetinternalPopcount(), and StpVecGetSize.

Referenced by combineWithIntersecting(), dpiterPopSol(), dpterms_streeInsert(), insertData(), and subtreesAddNew().

◆ stpbitset_newCopy()

static STP_Bitset stpbitset_newCopy ( SCIP scip,
STP_Bitset  bitsetOrg 
)
inlinestatic

gets copy

Parameters
scipSCIP data structure
bitsetOrgbitset

Definition at line 267 of file stpbitset.h.

References BMScopyMemoryArray, STP_Bitset, stpbitset_getCapacity(), stpbitset_new(), stpbitset_setsAreCompatible(), and StpVecGetSize.

Referenced by combineWithIntersecting(), dpsolverInitData(), insertData(), and subtreesAddNewFinalize().

◆ stpbitset_and()

static void stpbitset_and ( SCIP scip,
STP_Bitset  bitset1,
STP_Bitset  bitset2,
STP_Bitset  bitsetAnd 
)
inlinestatic

sets AND bitset

Parameters
scipSCIP data structure
bitset1bitset
bitset2bitset
bitsetAndbitset to set

Definition at line 286 of file stpbitset.h.

References stpbitset_setsAreCompatible(), and StpVecGetSize.

Referenced by insertData(), and stpbitset_newAnd().

◆ stpbitset_or()

static void stpbitset_or ( SCIP scip,
STP_Bitset  bitset1,
STP_Bitset  bitset2,
STP_Bitset  bitsetOr 
)
inlinestatic

sets OR bitset

Parameters
scipSCIP data structure
bitset1bitset
bitset2bitset
bitsetOrbitset to set

Definition at line 308 of file stpbitset.h.

References stpbitset_setsAreCompatible(), and StpVecGetSize.

Referenced by insertData(), and stpbitset_newOr().

◆ stpbitset_newAnd()

static STP_Bitset stpbitset_newAnd ( SCIP scip,
STP_Bitset  bitset1,
STP_Bitset  bitset2 
)
inlinestatic

gets new AND bitset

Parameters
scipSCIP data structure
bitset1bitset
bitset2bitset

Definition at line 330 of file stpbitset.h.

References STP_Bitset, stpbitset_and(), stpbitset_getCapacity(), stpbitset_new(), and stpbitset_setsAreCompatible().

◆ stpbitset_newOr()

static STP_Bitset stpbitset_newOr ( SCIP scip,
STP_Bitset  bitset1,
STP_Bitset  bitset2 
)
inlinestatic

gets new OR bitset

Parameters
scipSCIP data structure
bitset1bitset
bitset2bitset

Definition at line 348 of file stpbitset.h.

References STP_Bitset, stpbitset_getCapacity(), stpbitset_new(), stpbitset_or(), and stpbitset_setsAreCompatible().

Referenced by combineWithIntersecting().

◆ stpbitset_newXor()

static STP_Bitset stpbitset_newXor ( SCIP scip,
STP_Bitset  bitset1,
STP_Bitset  bitset2 
)
inlinestatic

gets new XOR bitset

Parameters
scipSCIP data structure
bitset1bitset
bitset2bitset

Definition at line 366 of file stpbitset.h.

References STP_Bitset, stpbitset_getCapacity(), stpbitset_new(), stpbitset_setsAreCompatible(), and StpVecGetSize.

◆ stpbitset_newNot()

static STP_Bitset stpbitset_newNot ( SCIP scip,
STP_Bitset  bitset1,
int  size 
)
inlinestatic

gets new Not bitset

Parameters
scipSCIP data structure
bitset1bitset for not
sizesize to apply not operation to

Definition at line 390 of file stpbitset.h.

References STP_Bitset, stpbitset_bitIsTrue(), stpbitset_getCapacity(), stpbitset_new(), and StpVecGetSize.

Referenced by updateIncumbent().

◆ stpbitset_newAllTrue()

static STP_Bitset stpbitset_newAllTrue ( SCIP scip,
int  maxnbits 
)
inlinestatic

initializes all TRUE bitset and returns it todo more efficiently

Parameters
scipSCIP data structure
maxnbitssize of bitset

Definition at line 430 of file stpbitset.h.

References STP_Bitset, stpbitset_bitIsTrue(), stpbitset_getCapacity(), stpbitset_new(), and stpbitset_setBitTrue().

◆ stpbitset_print()

static void stpbitset_print ( STP_Bitset  bitset)
inlinestatic

prints bitset (0,1) ... for debugging

Parameters
bitsetbitset to print

Definition at line 452 of file stpbitset.h.

References stpbitset_bitIsTrue(), and stpbitset_getCapacity().

Referenced by dpiterGetNextSol(), dpterms_streeInsert(), printNodeDebugInfo(), subtreesAddNew(), and updateIncumbent().

◆ stpbitset_GT()

static SCIP_Bool stpbitset_GT ( STP_Bitset  bitset1,
STP_Bitset  bitset2 
)
inlinestatic

bitset1 > bitset2?

Parameters
bitset1bitset
bitset2bitset

Definition at line 473 of file stpbitset.h.

References stpbitset_setsAreCompatible(), and StpVecGetSize.

◆ stpbitset_LT()

static SCIP_Bool stpbitset_LT ( STP_Bitset  bitset1,
STP_Bitset  bitset2 
)
inlinestatic

bitset1 < bitset2?

Parameters
bitset1bitset
bitset2bitset

Definition at line 492 of file stpbitset.h.

References stpbitset_setsAreCompatible(), and StpVecGetSize.