Graph file reader (actually, only a writer)
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 <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) |
#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 struct sparseGraph SparseGraph |
Definition at line 64 of file reader_ccg.c.
|
static |
initialize graph
scip | SCIP data structure |
G | graph to free |
nNodes | number of nodes |
initSize | initial size of lists |
Definition at line 73 of file reader_ccg.c.
References SCIP_CALL, SCIP_OKAY, and SCIPallocBufferArray.
Referenced by SCIPwriteCcg().
|
static |
frees graph
scip | SCIP data structure |
G | graph to free |
Definition at line 107 of file reader_ccg.c.
References SCIPfreeBufferArray.
Referenced by SCIPwriteCcg().
|
static |
check whether there is enough capacity for one additional edge in the given adjacency list
scip | SCIP data structure |
G | graph |
node | list for node |
Definition at line 129 of file reader_ccg.c.
References SCIP_CALL, SCIP_OKAY, and SCIPreallocBufferArray.
Referenced by createEdgesFromRow().
|
static |
transforms given variables, scalars, and constant to the corresponding active variables, scalars, and constant
scip | SCIP data structure |
vars | vars array to get active variables for |
scalars | scalars a_1, ..., a_n inrc/scip/reader_graph.c linear sum a_1*x_1 + ... + a_n*x_n + c |
nvars | pointer to number of variables and values in vars and vals array |
constant | pointer to constant c in linear sum a_1*x_1 + ... + a_n*x_n + c |
transformed | transformed constraint? |
Definition at line 150 of file reader_ccg.c.
References SCIP_CALL, SCIP_OKAY, SCIPgetProbvarLinearSum(), SCIPreallocBufferArray, SCIPvarGetOrigvarSum(), and TRUE.
Referenced by handleLinearCons().
|
static |
scip | SCIP data structure |
vars | array of constraint variables |
vals | array of constraint values |
nvars | number of constraint variables |
G | graph |
Definition at line 195 of file reader_ccg.c.
References ensureEdgeCapacity(), SCIP_CALL, SCIP_OKAY, SCIP_Real, and SCIPvarGetProbindex().
Referenced by handleLinearCons().
|
static |
handle given linear constraint information
scip | SCIP data structure |
vars | array of variables |
vals | array of coefficients values (or NULL if all coefficient values are 1) |
nvars | number of variables |
transformed | transformed constraint? |
G | graph |
Definition at line 281 of file reader_ccg.c.
References createEdgesFromRow(), getActiveVariables(), SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPduplicateBufferArray, and SCIPfreeBufferArray.
Referenced by SCIPwriteCcg().
|
static |
copy method for reader plugins (called when SCIP copies plugins)
Definition at line 332 of file reader_ccg.c.
References READER_NAME, SCIP_CALL, SCIP_OKAY, SCIPincludeReaderCcg(), and SCIPreaderGetName().
|
static |
problem writing method of reader
Definition at line 347 of file reader_ccg.c.
References SCIP_CALL, SCIP_OKAY, and SCIPwriteCcg().