SCIP Doxygen Documentation
Loading...
Searching...
No Matches
pattern.c File Reference

Detailed Description

pattern data for Ringpacking Problem

Author
Benjamin Mueller

This file implements the handling of patterns. Each pattern has a SCIP_PATTERNTYPE, accessible by SCIPpatternGetPatternType(), which indicates whether it is a circular or rectangular pattern.

Definition in file pattern.c.

#include "pattern.h"
#include "probdata_rpa.h"

Go to the source code of this file.

Functions

static SCIP_RETCODE ensureElemSize (SCIP_PATTERN *pattern, int size)
static SCIP_RETCODE createPattern (SCIP *scip, SCIP_PATTERN **pattern, SCIP_PATTERNTYPE patterntype, int type)
SCIP_RETCODE SCIPpatternCreateCircular (SCIP *scip, SCIP_PATTERN **pattern, int type)
SCIP_RETCODE SCIPpatternCreateRectangular (SCIP *scip, SCIP_PATTERN **pattern)
void SCIPpatternCapture (SCIP_PATTERN *pattern)
void SCIPpatternRelease (SCIP *scip, SCIP_PATTERN **pattern)
SCIP_RETCODE SCIPpatternCopy (SCIP *scip, SCIP_PATTERN *pattern, SCIP_PATTERN **copy)
SCIP_RETCODE SCIPpatternAddElement (SCIP_PATTERN *pattern, int type, SCIP_Real x, SCIP_Real y)
void SCIPpatternRemoveLastElements (SCIP_PATTERN *pattern, int k)
int SCIPpatternGetNElemens (SCIP_PATTERN *pattern)
int SCIPpatternGetElementType (SCIP_PATTERN *pattern, int i)
int SCIPpatternCountElements (SCIP_PATTERN *pattern, int type)
SCIP_Real SCIPpatternGetElementPosX (SCIP_PATTERN *pattern, int elem)
SCIP_Real SCIPpatternGetElementPosY (SCIP_PATTERN *pattern, int elem)
void SCIPpatternSetElementPos (SCIP_PATTERN *pattern, int elem, SCIP_Real x, SCIP_Real y)
SCIP_PATTERNTYPE SCIPpatternGetPatternType (SCIP_PATTERN *pattern)
int SCIPpatternGetCircleType (SCIP_PATTERN *pattern)
void SCIPpatternSetType (SCIP_PATTERN *pattern, int type)
SCIP_PACKABLE SCIPpatternGetPackableStatus (SCIP_PATTERN *pattern)
void SCIPpatternSetPackableStatus (SCIP_PATTERN *pattern, SCIP_PACKABLE packable)

Function Documentation

◆ ensureElemSize()

SCIP_RETCODE ensureElemSize ( SCIP_PATTERN * pattern,
int size )
static

ensures that there is enough memory to store elements

Parameters
patternpattern
sizerequired size

Definition at line 45 of file pattern.c.

References assert(), SCIP_Pattern::blkmem, BMSreallocBlockMemoryArray, ensureElemSize(), MAX, NULL, SCIP_ALLOC, SCIP_OKAY, SCIP_Pattern::size, SCIP_Pattern::types, SCIP_Pattern::xs, and SCIP_Pattern::ys.

Referenced by ensureElemSize(), SCIPpatternAddElement(), and SCIPpatternCopy().

◆ createPattern()

SCIP_RETCODE createPattern ( SCIP * scip,
SCIP_PATTERN ** pattern,
SCIP_PATTERNTYPE patterntype,
int type )
static

auxiliary function to create a pattern

Parameters
scipSCIP data structure
patternpointer to store pattern
patterntypepattern type
typecircle type (not needed for rectangular patterns)

Definition at line 68 of file pattern.c.

References assert(), BMSclearMemory, createPattern(), NULL, SCIP_CALL, SCIP_OKAY, SCIP_PACKABLE_UNKNOWN, SCIPallocBlockMemory, SCIPblkmem(), and SCIPpatternCapture().

Referenced by createPattern(), SCIPpatternCopy(), SCIPpatternCreateCircular(), and SCIPpatternCreateRectangular().

◆ SCIPpatternCreateCircular()

SCIP_RETCODE SCIPpatternCreateCircular ( SCIP * scip,
SCIP_PATTERN ** pattern,
int type )

creates an empty circular pattern

Parameters
scipSCIP data structure
patternpointer to store pattern
typecircle type (not needed for rectangular patterns)

Definition at line 97 of file pattern.c.

References createPattern(), SCIP_PATTERNTYPE_CIRCULAR, and SCIPpatternCreateCircular().

Referenced by SCIPpatternCreateCircular(), and SCIPprobdataEnumeratePatterns().

◆ SCIPpatternCreateRectangular()

SCIP_RETCODE SCIPpatternCreateRectangular ( SCIP * scip,
SCIP_PATTERN ** pattern )

creates an empty rectangular pattern

Parameters
scipSCIP data structure
patternpointer to store pattern

Definition at line 107 of file pattern.c.

References createPattern(), SCIP_PATTERNTYPE_RECTANGULAR, and SCIPpatternCreateRectangular().

Referenced by addVariable(), SCIPpatternCreateRectangular(), and setupProblem().

◆ SCIPpatternCapture()

void SCIPpatternCapture ( SCIP_PATTERN * pattern)

captures a pattern

Parameters
patternpattern

Definition at line 116 of file pattern.c.

References assert(), SCIP_Pattern::nlocks, NULL, and SCIPpatternCapture().

Referenced by createPattern(), probdataCreate(), and SCIPpatternCapture().

◆ SCIPpatternRelease()

void SCIPpatternRelease ( SCIP * scip,
SCIP_PATTERN ** pattern )
Parameters
scipSCIP data structure
patternpointer to free pattern

Definition at line 126 of file pattern.c.

References assert(), NULL, SCIPfreeBlockMemory, SCIPfreeBlockMemoryArrayNull, and SCIPpatternRelease().

Referenced by addVariable(), filterPatterns(), probdataFree(), SCIPpatternRelease(), SCIPprobdataEnumeratePatterns(), and setupProblem().

◆ SCIPpatternCopy()

SCIP_RETCODE SCIPpatternCopy ( SCIP * scip,
SCIP_PATTERN * pattern,
SCIP_PATTERN ** copy )

copies a pattern

Parameters
scipSCIP data structure
patternpattern to copy
copypointer to store the copy

Definition at line 152 of file pattern.c.

References assert(), createPattern(), ensureElemSize(), i, SCIP_Pattern::nelems, NULL, SCIP_Pattern::packable, SCIP_Pattern::patterntype, SCIP_CALL, SCIP_OKAY, SCIPpatternAddElement(), SCIPpatternCopy(), SCIP_Pattern::type, SCIP_Pattern::types, SCIP_Pattern::xs, and SCIP_Pattern::ys.

Referenced by SCIPpatternCopy(), and SCIPprobdataAddVar().

◆ SCIPpatternAddElement()

SCIP_RETCODE SCIPpatternAddElement ( SCIP_PATTERN * pattern,
int type,
SCIP_Real x,
SCIP_Real y )

adds an element of a given type to a pattern; packable status does not change

Parameters
patternpattern
typeelement of a given type
xx-coordinate (SCIP_INVALID: unknown)
yy-coordinate (SCIP_INVALID: unknown)

Definition at line 182 of file pattern.c.

References assert(), ensureElemSize(), SCIP_Pattern::nelems, NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPpatternAddElement(), SCIP_Pattern::types, x, SCIP_Pattern::xs, y, and SCIP_Pattern::ys.

Referenced by addVariable(), enumeratePatterns(), SCIPpatternAddElement(), SCIPpatternCopy(), and setupProblem().

◆ SCIPpatternRemoveLastElements()

void SCIPpatternRemoveLastElements ( SCIP_PATTERN * pattern,
int k )

removes the last k elements

Parameters
patternpattern
knumber of elements to remove

Definition at line 203 of file pattern.c.

References assert(), SCIP_Pattern::nelems, NULL, and SCIPpatternRemoveLastElements().

Referenced by enumeratePatterns(), and SCIPpatternRemoveLastElements().

◆ SCIPpatternGetNElemens()

int SCIPpatternGetNElemens ( SCIP_PATTERN * pattern)

returns the total number of elements

returns the total number of elements of a given type in the pattern

Parameters
patternpattern

Definition at line 215 of file pattern.c.

References assert(), SCIP_Pattern::nelems, NULL, and SCIPpatternGetNElemens().

Referenced by createPatternVars(), enumeratePatterns(), isPatternDominating(), SCIP_DECL_EVENTEXEC(), SCIPcheckPattern(), SCIPpatternGetNElemens(), SCIPverifyCircularPatternHeuristic(), and SCIPverifyCircularPatternNLP().

◆ SCIPpatternGetElementType()

int SCIPpatternGetElementType ( SCIP_PATTERN * pattern,
int i )

◆ SCIPpatternCountElements()

int SCIPpatternCountElements ( SCIP_PATTERN * pattern,
int type )

returns the total number of elements of a given type

Parameters
patternpattern
typetype

Definition at line 237 of file pattern.c.

References assert(), i, SCIP_Pattern::nelems, NULL, SCIPpatternCountElements(), and SCIP_Pattern::types.

Referenced by SCIPpatternCountElements(), and setupProblem().

◆ SCIPpatternGetElementPosX()

SCIP_Real SCIPpatternGetElementPosX ( SCIP_PATTERN * pattern,
int elem )

returns the x-coordinate of an element

Parameters
patternpattern
elemindex of the element

Definition at line 257 of file pattern.c.

References assert(), NULL, SCIP_Real, SCIPpatternGetElementPosX(), and SCIP_Pattern::xs.

Referenced by SCIP_DECL_EVENTEXEC(), SCIPcheckPattern(), and SCIPpatternGetElementPosX().

◆ SCIPpatternGetElementPosY()

SCIP_Real SCIPpatternGetElementPosY ( SCIP_PATTERN * pattern,
int elem )

returns the y-coordinate of an element

Parameters
patternpattern
elemindex of the element

Definition at line 269 of file pattern.c.

References assert(), NULL, SCIP_Real, SCIPpatternGetElementPosY(), and SCIP_Pattern::ys.

Referenced by SCIP_DECL_EVENTEXEC(), SCIPcheckPattern(), and SCIPpatternGetElementPosY().

◆ SCIPpatternSetElementPos()

void SCIPpatternSetElementPos ( SCIP_PATTERN * pattern,
int elem,
SCIP_Real x,
SCIP_Real y )

sets the (x,y) position of an element

Parameters
patternpattern
elemindex of the element
xx-coordinate
yy-coordinate

Definition at line 281 of file pattern.c.

References assert(), NULL, SCIP_Real, SCIPpatternSetElementPos(), x, SCIP_Pattern::xs, y, and SCIP_Pattern::ys.

Referenced by SCIPpatternSetElementPos(), SCIPverifyCircularPatternHeuristic(), and SCIPverifyCircularPatternNLP().

◆ SCIPpatternGetPatternType()

SCIP_PATTERNTYPE SCIPpatternGetPatternType ( SCIP_PATTERN * pattern)

◆ SCIPpatternGetCircleType()

int SCIPpatternGetCircleType ( SCIP_PATTERN * pattern)

returns the type of the boundary circle

Note
this function can only be called for circular patterns
Parameters
patternpattern

Definition at line 309 of file pattern.c.

References assert(), NULL, SCIP_Pattern::patterntype, SCIP_PATTERNTYPE_CIRCULAR, SCIPpatternGetCircleType(), and SCIP_Pattern::type.

Referenced by createPatternVars(), enumeratePatterns(), isPatternDominating(), SCIP_DECL_EVENTEXEC(), SCIPcheckPattern(), SCIPpatternGetCircleType(), SCIPverifyCircularPatternHeuristic(), SCIPverifyCircularPatternNLP(), and setupProblem().

◆ SCIPpatternSetType()

void SCIPpatternSetType ( SCIP_PATTERN * pattern,
int type )

sets the type of the boundary circle

Note
this function can only be called for circular patterns
Parameters
patternpattern
typetype

Definition at line 323 of file pattern.c.

References assert(), NULL, SCIP_Pattern::patterntype, SCIP_PATTERNTYPE_CIRCULAR, SCIPpatternSetType(), and SCIP_Pattern::type.

Referenced by SCIPpatternSetType(), and SCIPprobdataEnumeratePatterns().

◆ SCIPpatternGetPackableStatus()

◆ SCIPpatternSetPackableStatus()

void SCIPpatternSetPackableStatus ( SCIP_PATTERN * pattern,
SCIP_PACKABLE packable )

sets the packable status of a pattern

Parameters
patternpattern
packablepackable status

Definition at line 345 of file pattern.c.

References assert(), NULL, SCIP_Pattern::packable, and SCIPpatternSetPackableStatus().

Referenced by addVariable(), enumeratePatterns(), SCIPpatternSetPackableStatus(), SCIPverifyCircularPatternHeuristic(), SCIPverifyCircularPatternNLP(), and setupProblem().