GOBNILP
f164d83
|
Contains functions related to managing ParentSetData. More...
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include "parent_set_data.h"
#include "utils.h"
#include "vector.h"
#include "vectorlist.h"
#include "stack.h"
#include "scip/pub_var.h"
Functions | |
static SCIP_RETCODE | findStronglyConnectedComponents (int n, int current_node, int *current_index, SCIP_Bool **adj_matrix, Vector *index_array, Vector *lowlink, Stack *s, VectorList *components) |
Finds strongly connected components in an adjacency matrix. More... | |
SCIP_RETCODE | PS_copyParentSetData (SCIP *scip, ParentSetData *original, ParentSetData **duplicate) |
Makes a deep copy of a ParentSetData structure. More... | |
SCIP_RETCODE | PS_deallocateParentSetData (SCIP *scip, ParentSetData **psd, SCIP_Bool releasevars) |
Deallocates the memory associated with a ParentSetData structure. More... | |
SCIP_RETCODE | PS_parse (SCIP *scip, char *str, ParentSetData **psd) |
Parses a ParentSetData structure from a sting. More... | |
SCIP_RETCODE | PS_specialiseFor (SCIP *scip, ParentSetData *original, int *nodes, int num_nodes, ParentSetData **specialisation) |
Creates a subset of parent set data mentioning only the given nodes. More... | |
SCIP_RETCODE | PS_splitToComponents (SCIP *scip, ParentSetData *original, int *num_components, ParentSetData ***components) |
Splits a single set of parent set data in to its strongly connected components. More... | |
SCIP_RETCODE | PS_writeToFile (SCIP *scip, FILE *file, ParentSetData *psd) |
Writes a ParentSetData structure to file. More... | |
Contains functions related to managing ParentSetData.
|
static |
Finds strongly connected components in an adjacency matrix.
The algorithm used is Tarjan's Algorithm. See the Wikipedia page for details. See PS_splitToComponents() to see how the intermediate data structures should be intialised.
n | The number of nodes. |
current_node | The node to consider next. |
current_index | The current depth index. |
adj_matrix | The adjacency matrix to calculate on. |
index_array | An intermediate data structure. |
lowlink | An intermediate data structure. |
s | An intermediate datastructure. |
components | The strongly connected components found in the matrix. |
References Vector::items, StackContains(), StackPop(), StackPush(), StackSize(), VectorAppend(), VectorCreate(), and VectorListAppend().
Referenced by PS_splitToComponents().
SCIP_RETCODE PS_copyParentSetData | ( | SCIP * | scip, |
ParentSetData * | original, | ||
ParentSetData ** | duplicate | ||
) |
Makes a deep copy of a ParentSetData structure.
scip | The SCIP instance to which the data belongs. |
original | The original data structure. |
duplicate | A pointer to the duplicated data structure. |
References ParentSetData::arrow, ParentSetData::edge, get_arrow(), get_edge(), hashtableCreateArrow(), ParentSetData::n, ParentSetData::nodeNames, ParentSetData::nParents, ParentSetData::nParentSets, ParentSetData::ParentSets, ParentSetData::PaVars, put_arrow(), and put_edge().
Referenced by createConsData(), and MD_setParentSetData().
SCIP_RETCODE PS_deallocateParentSetData | ( | SCIP * | scip, |
ParentSetData ** | psd, | ||
SCIP_Bool | releasevars | ||
) |
Deallocates the memory associated with a ParentSetData structure.
scip | The SCIP instance which the data refers to. |
psd | A pointer to the data structure to deallocate. |
releasevars | Whether to release the variables (family, arrow and edge) |
References get_arrow(), get_edge(), and hashtablefreeArrow().
Referenced by addAcyclicityConstraints(), DC_tryToSplit(), SCIP_DECL_CONSDELETE(), SCIP_DECL_CONSFREE(), SCIP_DECL_CONSPARSE(), and SCIP_DECL_PROBDELORIG().
SCIP_RETCODE PS_parse | ( | SCIP * | scip, |
char * | str, | ||
ParentSetData ** | psd | ||
) |
Parses a ParentSetData structure from a sting.
scip | The SCIP instance the data will belong to. |
str | The string to parse. |
psd | A pointer to the data structure resulting from parsing. |
References hashtableCreateArrow(), put_arrow(), put_edge(), UT_parseArray(), UT_parseIntArray(), UT_parseIntArrayArray(), UT_parseIntArrayArrayArray(), UT_parseStringArray(), and UT_parseVarArrayArray().
Referenced by SCIP_DECL_CONSPARSE().
SCIP_RETCODE PS_specialiseFor | ( | SCIP * | scip, |
ParentSetData * | original, | ||
int * | nodes, | ||
int | num_nodes, | ||
ParentSetData ** | specialisation | ||
) |
Creates a subset of parent set data mentioning only the given nodes.
scip | The SCIP instance the parent set dtaa is used in. |
original | The original data from which the subset will be taken. |
nodes | The nodes which the new subset should be limited to. |
num_nodes | The number of nodes the subset will be limited to. |
specialisation | The subset of the parent set data containing only references to the requested nodes. |
References get_arrow(), get_edge(), hashtableCreateArrow(), ParentSetData::n, ParentSetData::nodeNames, ParentSetData::nParents, ParentSetData::nParentSets, ParentSetData::ParentSets, ParentSetData::PaVars, put_arrow(), and put_edge().
Referenced by PS_splitToComponents().
SCIP_RETCODE PS_splitToComponents | ( | SCIP * | scip, |
ParentSetData * | original, | ||
int * | num_components, | ||
ParentSetData *** | components | ||
) |
Splits a single set of parent set data in to its strongly connected components.
If any variables are fixed at zero locally, the parent set the variable refers to is treated as if it did not exist for the purposes of finding the components.
scip | The SCIP instance being used. |
original | The parent set data to search for components in. |
num_components | The number of strongly connected components found. |
components | The strongly connected components of the data. |
References findStronglyConnectedComponents(), Vector::items, VectorList::items, ParentSetData::n, ParentSetData::nParents, ParentSetData::nParentSets, ParentSetData::ParentSets, ParentSetData::PaVars, PS_specialiseFor(), Vector::size, VectorList::size, StackCreate(), StackDelete(), VectorCreate(), VectorDelete(), VectorListCreate(), and VectorListDelete().
Referenced by addAcyclicityConstraints(), and DC_tryToSplit().
SCIP_RETCODE PS_writeToFile | ( | SCIP * | scip, |
FILE * | file, | ||
ParentSetData * | psd | ||
) |
Writes a ParentSetData structure to file.
scip | The SCIP instance the data belongs to. |
file | The file to write to. |
psd | The data to write. |
References ParentSetData::n.
Referenced by SCIP_DECL_CONSPRINT().