Scippy

SCIP

Solving Constraint Integer Programs

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 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 "blockmemshell/memory.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"
#include "scip/pub_cons.h"
#include "scip/pub_message.h"
#include "scip/pub_reader.h"
#include "scip/pub_var.h"
#include "scip/reader_ccg.h"
#include "scip/scip_cons.h"
#include "scip/scip_mem.h"
#include "scip/scip_message.h"
#include "scip/scip_reader.h"
#include "scip/scip_var.h"
#include <string.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

◆ READER_NAME

#define READER_NAME   "ccgreader"

Definition at line 61 of file reader_ccg.c.

Referenced by SCIP_DECL_READERCOPY(), and SCIPincludeReaderCcg().

◆ READER_DESC

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

Definition at line 62 of file reader_ccg.c.

Referenced by SCIPincludeReaderCcg().

◆ READER_EXTENSION

#define READER_EXTENSION   "ccg"

Definition at line 63 of file reader_ccg.c.

Referenced by SCIPincludeReaderCcg().

Typedef Documentation

◆ SparseGraph

typedef struct sparseGraph SparseGraph

Definition at line 81 of file reader_ccg.c.

Function Documentation

◆ initGraph()

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 90 of file reader_ccg.c.

References SCIP_CALL, SCIP_OKAY, and SCIPallocBufferArray.

Referenced by SCIPwriteCcg().

◆ freeGraph()

static void freeGraph ( SCIP scip,
SparseGraph G 
)
static

frees graph

Parameters
scipSCIP data structure
Ggraph to free

Definition at line 124 of file reader_ccg.c.

References SCIPfreeBufferArray.

Referenced by SCIPwriteCcg().

◆ ensureEdgeCapacity()

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 146 of file reader_ccg.c.

References SCIP_CALL, SCIP_OKAY, and SCIPreallocBufferArray.

Referenced by createEdgesFromRow().

◆ getActiveVariables()

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 167 of file reader_ccg.c.

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

Referenced by handleLinearCons().

◆ createEdgesFromRow()

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 212 of file reader_ccg.c.

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

Referenced by handleLinearCons().

◆ 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 298 of file reader_ccg.c.

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

Referenced by SCIPwriteCcg().

◆ SCIP_DECL_READERCOPY()

static SCIP_DECL_READERCOPY ( readerCopyCcg  )
static

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

Definition at line 349 of file reader_ccg.c.

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

◆ SCIP_DECL_READERWRITE()

static SCIP_DECL_READERWRITE ( readerWriteCcg  )
static

problem writing method of reader

Definition at line 364 of file reader_ccg.c.

References SCIP_CALL, SCIP_OKAY, and SCIPwriteCcg().