CMR  1.3.0
Classes | Enumerations | Functions
camion.c File Reference
#include <cmr/camion.h>
#include "camion_internal.h"
#include "matrix_internal.h"
#include "block_decomposition.h"
#include "env_internal.h"
#include <assert.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>

Classes

struct  GRAPH_NODE
 Graph node for BFS in signing algorithm. More...
 
struct  OrientationSearchEdgeData
 
struct  OrientationSearchNodeData
 

Enumerations

enum  OrientationSearchStage { UNKNOWN = 0 , SEEN = 1 , COMPLETED = 2 , BASIC = 3 }
 

Functions

CMR_ERROR CMRcamionStatsInit (CMR_CAMION_STATISTICS *stats)
 Initializes all statistics for Camion-signing algorithm. More...
 
CMR_ERROR CMRcamionStatsPrint (FILE *stream, CMR_CAMION_STATISTICS *stats, const char *prefix)
 Prints statistics for Camion-signing algorithm. More...
 
CMR_ERROR CMRcamionComputeSignSequentiallyConnected (CMR *cmr, CMR_CHRMAT *matrix, CMR_CHRMAT *transpose, bool change, char *pmodification, CMR_SUBMAT **psubmatrix, double timeLimit)
 Ensures that sequentially connected matrix \( M \) is Camion-signed. More...
 
static CMR_ERROR signCamion (CMR *cmr, CMR_CHRMAT *matrix, bool change, bool *pisCamionSigned, CMR_SUBMAT **psubmatrix, CMR_CAMION_STATISTICS *stats, double timeLimit)
 Signs a given matrix. More...
 
CMR_ERROR CMRcamionTestSigns (CMR *cmr, CMR_CHRMAT *matrix, bool *pisCamionSigned, CMR_SUBMAT **psubmatrix, CMR_CAMION_STATISTICS *stats, double timeLimit)
 Tests a matrix \( M \) for being a Camion-signed. More...
 
CMR_ERROR CMRcamionComputeSigns (CMR *cmr, CMR_CHRMAT *matrix, bool *pwasCamionSigned, CMR_SUBMAT **psubmatrix, CMR_CAMION_STATISTICS *stats, double timeLimit)
 Computes a Camion-signed version of a given ternary matrix \( M \). More...
 
static CMR_ERROR constructNonCamionSubmatrix (CMR *cmr, CMR_GRAPH *cograph, OrientationSearchEdgeData *edgeData, CMR_GRAPH_EDGE conflictEdge1, CMR_GRAPH_EDGE conflictEdge2, CMR_SUBMAT **psubmatrix)
 
CMR_ERROR CMRcamionCographicOrient (CMR *cmr, CMR_CHRMAT *matrix, CMR_GRAPH *cograph, CMR_GRAPH_EDGE *forestEdges, CMR_GRAPH_EDGE *coforestEdges, bool *arcsReversed, bool *pisCamionSigned, CMR_SUBMAT **psubmatrix, CMR_CAMION_STATISTICS *stats)
 Orients the edges of the graph cograph such that the matrix matrix \( M \) is the corresponding network matrix, which implicitly tests if matrix is Camion-signed. More...
 

Enumeration Type Documentation

◆ OrientationSearchStage

Enumerator
UNKNOWN 

The node was not considered by the shortest-path, yet.

SEEN 

Some path to the node is known.

COMPLETED 

The shortest path to the node is known.

BASIC 

The rootEdge of that node belongs to the spanning forest.

Function Documentation

◆ CMRcamionCographicOrient()

CMR_ERROR CMRcamionCographicOrient ( CMR cmr,
CMR_CHRMAT matrix,
CMR_GRAPH cograph,
CMR_GRAPH_EDGE forestEdges,
CMR_GRAPH_EDGE coforestEdges,
bool *  arcsReversed,
bool *  pisCamionSigned,
CMR_SUBMAT **  psubmatrix,
CMR_CAMION_STATISTICS stats 
)

Orients the edges of the graph cograph such that the matrix matrix \( M \) is the corresponding network matrix, which implicitly tests if matrix is Camion-signed.

The cograph \( G = (V,E) \) has a spanning tree \( T \subseteq E \) indexed by the columns of \( M \). Its complement \( E \setminus T \) is indexed by the rows of \( M \). The function assumes that \( supp(M) = M(G,T)^\textsf{T} \) holds and attempts to compute an orientation \( A \) of the edges \( E \) (which is stored in arcsReversed) that corresponds to the signs of \( M \). *pisCamionSigned indicates success. If successful, \( M \) is the network matrix of the digraph \( D = (V,A) \). Otherwise, *psubmatrix will indicate a violating submatrix (if not NULL).

Parameters
cmrCMR environment.
matrixMatrix \( M \).
cographCograph \( G = (V,E) \) claimed to correspond to \( M \).
forestEdges\( T \), ordered by the columns of \( M \).
coforestEdges\( E \setminus T \), ordered by the rows of \( M \).
arcsReversedIndicates, for each edge \( \{u, v\} \in E\), whether \( (u,v) \in A \) (if false) or \( (v,u) \in A \) (if true).
pisCamionSignedPointer for storing whether \( M \) is [Camion-signed](Camion's Signing Algorithm).
psubmatrixPointer for storing a non-Camion submatrix (may be NULL).
statsStatistics for the computation (may be NULL).

◆ CMRcamionComputeSigns()

CMR_ERROR CMRcamionComputeSigns ( CMR cmr,
CMR_CHRMAT matrix,
bool *  pwasCamionSigned,
CMR_SUBMAT **  psubmatrix,
CMR_CAMION_STATISTICS stats,
double  timeLimit 
)

Computes a Camion-signed version of a given ternary matrix \( M \).

Parameters
cmrCMR environment.
matrixMatrix \( M \) to be modified.
pwasCamionSignedPointer for storing whether \( M \) was already [Camion-signed](Camion's Signing Algorithm).
psubmatrixPointer for storing a non-Camion submatrix (may be NULL).
statsStatistics for the computation (may be NULL).
timeLimitTime limit to impose.

◆ CMRcamionComputeSignSequentiallyConnected()

CMR_ERROR CMRcamionComputeSignSequentiallyConnected ( CMR cmr,
CMR_CHRMAT matrix,
CMR_CHRMAT transpose,
bool  change,
char *  pmodification,
CMR_SUBMAT **  psubmatrix,
double  timeLimit 
)

Ensures that sequentially connected matrix \( M \) is Camion-signed.

The matrix \( M \) is assumed to be ternary. If sign changes are necessary, only matrix is modified. In particular, transpose remains unchanged.

If submatrix is not NULL and sign changes are necessary, then a submatrix with determinant -2 or +2 is stored in *psubmatrix and the caller must use CMRsubmatFree() to free its memory. It is set to NULL if no sign changes are needed.

Parameters
cmrCMR environment.
matrixThe matrix to be signed.
transposeThe transpose of matrix.
changeWhether to modify the matrix.
pmodificationPointer for storing which matrix was modified.
psubmatrixPointer for storing a submatrix with bad determinant (may be NULL).
timeLimitTime limit to impose.

◆ CMRcamionStatsInit()

CMR_ERROR CMRcamionStatsInit ( CMR_CAMION_STATISTICS stats)

Initializes all statistics for Camion-signing algorithm.

Parameters
statsPointer to statistics.

◆ CMRcamionStatsPrint()

CMR_ERROR CMRcamionStatsPrint ( FILE *  stream,
CMR_CAMION_STATISTICS stats,
const char *  prefix 
)

Prints statistics for Camion-signing algorithm.

Parameters
streamFile stream to print to.
statsPointer to statistics.
prefixPrefix string to prepend to each printed line (may be NULL).

◆ CMRcamionTestSigns()

CMR_ERROR CMRcamionTestSigns ( CMR cmr,
CMR_CHRMAT matrix,
bool *  pisCamionSigned,
CMR_SUBMAT **  psubmatrix,
CMR_CAMION_STATISTICS stats,
double  timeLimit 
)

Tests a matrix \( M \) for being a Camion-signed.

Parameters
cmrCMR environment.
matrixMatrix \( M \).
pisCamionSignedPointer for storing whether \( M \) is [Camion-signed](Camion's Signing Algorithm).
psubmatrixPointer for storing a non-Camion submatrix (may be NULL).
statsStatistics for the computation (may be NULL).
timeLimitTime limit to impose.

◆ constructNonCamionSubmatrix()

static CMR_ERROR constructNonCamionSubmatrix ( CMR cmr,
CMR_GRAPH cograph,
OrientationSearchEdgeData edgeData,
CMR_GRAPH_EDGE  conflictEdge1,
CMR_GRAPH_EDGE  conflictEdge2,
CMR_SUBMAT **  psubmatrix 
)
static
Parameters
cmrCMR environment.
cographCograph we consider.
edgeDataEdge data array.
conflictEdge1First edge of conflict.
conflictEdge2Second edge of conflict.
psubmatrixPointer for storing the submatrix.

◆ signCamion()

static CMR_ERROR signCamion ( CMR cmr,
CMR_CHRMAT matrix,
bool  change,
bool *  pisCamionSigned,
CMR_SUBMAT **  psubmatrix,
CMR_CAMION_STATISTICS stats,
double  timeLimit 
)
static

Signs a given matrix.

Parameters
cmrCMR environment.
matrixMatrix \( M \).
changeWhether the signs of \( M \) shall be modified.
pisCamionSignedPointer for storing whether \( M \) was already [Camion-signed](Camion's Signing Algorithm).
psubmatrixPointer for storing a non-camion submatrix (may be NULL).
statsStatistics for the computation (may be NULL).
timeLimitTime limit to impose.