Scippy

SCIP

Solving Constraint Integer Programs

reader_ccg.c File Reference

Detailed Description

Graph file reader (actually, only a writer)

Author
Marc Pfetsch

Write a weighted column/variable graph, i.e., the nodes correspond to the columns (variables) of the constraint matrix. Two nodes are adjacent if the corresponding columns/variables have appear in a common row/constraint (with nonzero coefficient). The weight is obtained by summing for each row that produces an edge the absolute values of coefficients in the row; hence, we avoid parallel edges.

This graph gives an indication of the connectivity structure of the constraint matrix.

The graph is output in DIMACS graph format.

Definition in file reader_ccg.c.

#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "scip/reader_ccg.h"
#include "scip/cons_knapsack.h"
#include "scip/cons_linear.h"
#include "scip/cons_logicor.h"
#include "scip/cons_setppc.h"
#include "scip/cons_varbound.h"

Go to the source code of this file.

Macros

#define READER_NAME   "ccgreader"
 
#define READER_DESC   "file writer for column connectivity graph file format"
 
#define READER_EXTENSION   "ccg"
 

Typedefs

typedef struct sparseGraph SparseGraph
 

Functions

static SCIP_RETCODE initGraph (SCIP *scip, SparseGraph *G, unsigned int nNodes, unsigned int initSize)
 
static void freeGraph (SCIP *scip, SparseGraph *G)
 
static SCIP_RETCODE ensureEdgeCapacity (SCIP *scip, SparseGraph *G, unsigned int node)
 
static SCIP_RETCODE getActiveVariables (SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, SCIP_Real *constant, SCIP_Bool transformed)
 
static SCIP_RETCODE createEdgesFromRow (SCIP *scip, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SparseGraph *G)
 
static SCIP_RETCODE handleLinearCons (SCIP *scip, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Bool transformed, SparseGraph *G)
 
static SCIP_DECL_READERCOPY (readerCopyCcg)
 
static SCIP_DECL_READERWRITE (readerWriteCcg)
 
SCIP_RETCODE SCIPincludeReaderCcg (SCIP *scip)
 
SCIP_RETCODE SCIPwriteCcg (SCIP *scip, FILE *file, const char *name, SCIP_Bool transformed, SCIP_VAR **vars, int nvars, SCIP_CONS **conss, int nconss, SCIP_RESULT *result)
 

Macro Definition Documentation

#define READER_NAME   "ccgreader"

Definition at line 44 of file reader_ccg.c.

Referenced by SCIP_DECL_READERCOPY(), and SCIPincludeReaderCcg().

#define READER_DESC   "file writer for column connectivity graph file format"

Definition at line 45 of file reader_ccg.c.

Referenced by SCIPincludeReaderCcg().

#define READER_EXTENSION   "ccg"

Definition at line 46 of file reader_ccg.c.

Referenced by SCIPincludeReaderCcg().

Typedef Documentation

typedef struct sparseGraph SparseGraph

Definition at line 64 of file reader_ccg.c.

Function Documentation

static SCIP_RETCODE initGraph ( SCIP scip,
SparseGraph G,
unsigned int  nNodes,
unsigned int  initSize 
)
static

initialize graph

Parameters
scipSCIP data structure
Ggraph to free
nNodesnumber of nodes
initSizeinitial size of lists

Definition at line 73 of file reader_ccg.c.

References SCIP_CALL, SCIP_OKAY, and SCIPallocBufferArray.

Referenced by SCIPwriteCcg().

static void freeGraph ( SCIP scip,
SparseGraph G 
)
static

frees graph

Parameters
scipSCIP data structure
Ggraph to free

Definition at line 107 of file reader_ccg.c.

References SCIPfreeBufferArray.

Referenced by SCIPwriteCcg().

static SCIP_RETCODE ensureEdgeCapacity ( SCIP scip,
SparseGraph G,
unsigned int  node 
)
static

check whether there is enough capacity for one additional edge in the given adjacency list

Parameters
scipSCIP data structure
Ggraph
nodelist for node

Definition at line 129 of file reader_ccg.c.

References SCIP_CALL, SCIP_OKAY, and SCIPreallocBufferArray.

Referenced by createEdgesFromRow().

static SCIP_RETCODE getActiveVariables ( SCIP scip,
SCIP_VAR **  vars,
SCIP_Real scalars,
int *  nvars,
SCIP_Real constant,
SCIP_Bool  transformed 
)
static

transforms given variables, scalars, and constant to the corresponding active variables, scalars, and constant

Parameters
scipSCIP data structure
varsvars array to get active variables for
scalarsscalars a_1, ..., a_n inrc/scip/reader_graph.c linear sum a_1*x_1 + ... + a_n*x_n + c
nvarspointer to number of variables and values in vars and vals array
constantpointer to constant c in linear sum a_1*x_1 + ... + a_n*x_n + c
transformedtransformed constraint?

Definition at line 150 of file reader_ccg.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPgetProbvarLinearSum(), SCIPreallocBufferArray, SCIPvarGetOrigvarSum(), and TRUE.

Referenced by handleLinearCons().

static SCIP_RETCODE createEdgesFromRow ( SCIP scip,
SCIP_VAR **  vars,
SCIP_Real vals,
int  nvars,
SparseGraph G 
)
static
Parameters
scipSCIP data structure
varsarray of constraint variables
valsarray of constraint values
nvarsnumber of constraint variables
Ggraph

Definition at line 195 of file reader_ccg.c.

References ensureEdgeCapacity(), NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, and SCIPvarGetProbindex().

Referenced by handleLinearCons().

static SCIP_RETCODE handleLinearCons ( SCIP scip,
SCIP_VAR **  vars,
SCIP_Real vals,
int  nvars,
SCIP_Bool  transformed,
SparseGraph G 
)
static

handle given linear constraint information

Parameters
scipSCIP data structure
varsarray of variables
valsarray of coefficients values (or NULL if all coefficient values are 1)
nvarsnumber of variables
transformedtransformed constraint?
Ggraph

Definition at line 281 of file reader_ccg.c.

References createEdgesFromRow(), getActiveVariables(), NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPduplicateBufferArray, and SCIPfreeBufferArray.

Referenced by SCIPwriteCcg().

static SCIP_DECL_READERCOPY ( readerCopyCcg  )
static

copy method for reader plugins (called when SCIP copies plugins)

Definition at line 332 of file reader_ccg.c.

References NULL, READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPincludeReaderCcg(), and SCIPreaderGetName().

static SCIP_DECL_READERWRITE ( readerWriteCcg  )
static

problem writing method of reader

Definition at line 347 of file reader_ccg.c.

References SCIP_CALL, SCIP_OKAY, and SCIPwriteCcg().

SCIP_RETCODE SCIPincludeReaderCcg ( SCIP scip)

includes the ccg file reader in SCIP

Parameters
scipSCIP data structure

Definition at line 360 of file reader_ccg.c.

References NULL, READER_DESC, READER_EXTENSION, READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPincludeReaderBasic(), SCIPsetReaderCopy(), and SCIPsetReaderWrite().

Referenced by SCIP_DECL_READERCOPY(), and SCIPincludeDefaultPlugins().

SCIP_RETCODE SCIPwriteCcg ( SCIP scip,
FILE *  file,
const char *  name,
SCIP_Bool  transformed,
SCIP_VAR **  vars,
int  nvars,
SCIP_CONS **  conss,
int  nconss,
SCIP_RESULT result 
)

writes problem to file

Parameters
scipSCIP data structure
fileoutput file, or NULL if standard output should be used
nameproblem name
transformedTRUE iff problem is the transformed problem
varsarray with active variables ordered binary, integer, implicit, continuous
nvarsnumber of active variables in the problem
conssarray with constraints of the problem
nconssnumber of constraints in the problem
resultpointer to store the result of the file writing call

Definition at line 380 of file reader_ccg.c.

References freeGraph(), handleLinearCons(), initGraph(), NULL, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIP_SUCCESS, SCIPallocBufferArray, SCIPconsGetHdlr(), SCIPconshdlrGetName(), SCIPconsIsEnabled(), SCIPconsIsTransformed(), SCIPfreeBufferArray, SCIPgetNVarsKnapsack(), SCIPgetNVarsLinear(), SCIPgetNVarsLogicor(), SCIPgetNVarsSetppc(), SCIPgetValsLinear(), SCIPgetVarsKnapsack(), SCIPgetVarsLinear(), SCIPgetVarsLogicor(), SCIPgetVarsSetppc(), SCIPgetVarVarbound(), SCIPgetVbdcoefVarbound(), SCIPgetVbdvarVarbound(), SCIPgetWeightsKnapsack(), SCIPinfoMessage(), SCIPprintCons(), and SCIPwarningMessage().

Referenced by SCIP_DECL_READERWRITE().