GOBNILP  f164d83
Functions
output.c File Reference

Contains all the functions related to writing data to files. More...

#include "output.h"
#include "parent_set_data.h"
#include "pedigrees.h"
#include "utils.h"
#include "probdata_bn.h"
#include "versiongit.h"
#include <string.h>
#include <time.h>
#include "scip/scipdefplugins.h"
#include <scip/cons_countsols.h>
Include dependency graph for output.c:

Functions

static char * createFilename (char *filename, const char *probname, int nbns, int iteration)
 Constructs a filename for output for a particular iteration of the program. More...
 
static int findExtension (char *filename)
 Finds the location in a string of the file extension. More...
 
SCIP_RETCODE IO_addOutputParameters (SCIP *scip)
 Adds the parameters to SCIP related to outputing results. More...
 
SCIP_RETCODE IO_doIterativePrint (SCIP *scip, MA_info *ma_info, ParentSetData *psd, int run)
 Prints appropriate information about each optimal solution obtained. More...
 
SCIP_RETCODE IO_printcountsols (SCIP *scip, ParentSetData *psd, char *filename)
 Prints solutions found using countsols. More...
 
SCIP_RETCODE IO_printHeader (SCIP *scip)
 Prints a header which describes the GOBNILP and SCIP systems being used. More...
 
SCIP_RETCODE IO_printParameters (SCIP *scip)
 Prints any of the current SCIP or GOBNILP parameters not at their default value. More...
 
SCIP_RETCODE IO_printProblem (SCIP *scip, int run)
 Prints the current problem in cip format. More...
 
SCIP_RETCODE IO_printScoresInJKLFormat (SCIP *scip, ParentSetData *psd, SCIP_Real **scores)
 Conditionally, prints the scores to file. More...
 
SCIP_RETCODE IO_printScoresInPSSFormat (SCIP *scip, ParentSetData *psd, PropertyData *prop)
 
static SCIP_Bool isRecognisedMETA (const char *name)
 
static void lookupAndPrintMetaLine (SCIP *scip, FILE *file, PropertyData *prop, int individual, const char *name)
 
static SCIP_RETCODE printAverages (SCIP *scip, MA_info *ma_info, ParentSetData *psd, char *filename, char *format)
 Prints the model average data. More...
 
static void printBlankLine (FILE *file)
 
static void printCommentLine (FILE *file, const char *comment)
 
static void printMetaLine (FILE *file, const char *name, const char *value)
 
static SCIP_RETCODE printSCIPSolution (SCIP *scip)
 
static void printScoreLine (FILE *file, SCIP_VAR *var, int num_parents, int *parents, char **names)
 
static SCIP_RETCODE printSolution (SCIP *scip, ParentSetData *psd, char *filename, char *format)
 Prints the solution of the problem after solving. More...
 
static SCIP_RETCODE printSolutionAdjacencyMatrixFormat (SCIP *scip, ParentSetData *psd, SCIP_Real **Scores, SCIP_Bool **selected, SCIP_Real total_score, FILE *stream)
 Prints the solution as an adjacency matrix. More...
 
static SCIP_RETCODE printSolutionBNFormat (SCIP *scip, ParentSetData *psd, SCIP_Real **Scores, SCIP_Bool **selected, SCIP_Real total_score, FILE *stream)
 Prints the solution in a Bayesian network format. More...
 
static SCIP_RETCODE printSolutionDotFormat (SCIP *scip, ParentSetData *psd, SCIP_Real **Scores, SCIP_Bool **selected, SCIP_Real total_score, FILE *stream)
 Prints the solution as a file suitable for plotting using the dot command from graphviz. More...
 
static SCIP_RETCODE printSolutionLegacyFormat (SCIP *scip, ParentSetData *psd, SCIP_Real **Scores, SCIP_Bool **selected, SCIP_Real total_score, FILE *stream)
 Prints the solution in the traditional GOBNILP format. More...
 
static SCIP_RETCODE printSolutionMECFormat (SCIP *scip, ParentSetData *psd, SCIP_Real **Scores, SCIP_Bool **selected, SCIP_Real total_score, FILE *stream)
 Prints the Markov equivalance class of the solution. More...
 
static SCIP_RETCODE printSolutionScoreAndTimeFormat (SCIP *scip, ParentSetData *psd, SCIP_Real **Scores, SCIP_Bool **selected, SCIP_Real total_score, FILE *stream, SCIP_Real soltime)
 Prints just the objective value of the given solution and the time taken to find the solution. More...
 
static SCIP_RETCODE printToFile (SCIP *scip, ParentSetData *psd, SCIP_Real **Scores, SCIP_Bool **selected, char *filename, char *format, SCIP_Real soltime, SCIP_Real total_score, SCIP_Bool *pedVals)
 Prints a solution to the problem. More...
 
static void printVariableLine (FILE *file, const char *name)
 

Detailed Description

Contains all the functions related to writing data to files.

Function Documentation

◆ createFilename()

static char* createFilename ( char *  filename,
const char *  probname,
int  nbns,
int  iteration 
)
static

Constructs a filename for output for a particular iteration of the program.

The filename constructed will be the input filename the iteration number appearing before the file extension or appended if there is no extension. If there is only a single network to find, then the iteration number is not inserted. For special values ("" and "stdout"), the value returned is the same value as given as input. Any occurrence of <probname> will be replaced with the basename of the problem.

Parameters
filenameThe filename to insert the string in to.
probnameThe basename of the problem.
nbnsThe number of Bayesian networks that the program is trying to find.
iterationThe current iteration of the program.
Returns
The filename that should be used for output.

References findExtension().

Referenced by IO_printProblem(), and IO_printScoresInJKLFormat().

Here is the call graph for this function:

◆ findExtension()

static int findExtension ( char *  filename)
static

Finds the location in a string of the file extension.

Parameters
filenameThe filename to inspect.
Returns
The location of the "." marking the beginning of the file extension, or -1 if there is no extension.

Referenced by createFilename().

◆ IO_addOutputParameters()

SCIP_RETCODE IO_addOutputParameters ( SCIP *  scip)

Adds the parameters to SCIP related to outputing results.

These parameters consist of all those of the form gobnilp/outputfile/<param> . Some other output parameters exist, but these can be currently found in probdata_bn.c .

Parameters
scipThe SCIP instance to which parameters should be added.
Returns
SCIP_OKAY if all the parameters were added successfully, or an error otherwise.

References UT_addBoolParam(), UT_addIntParam(), and UT_addStringParam().

Referenced by BN_addParameters().

Here is the call graph for this function:

◆ IO_doIterativePrint()

SCIP_RETCODE IO_doIterativePrint ( SCIP *  scip,
MA_info ma_info,
ParentSetData psd,
int  run 
)

Prints appropriate information about each optimal solution obtained.

Parameters
scipThe SCIP instance for which the solution has been found.
runThe iteration of the main loop that the solution was found on.
psdThe parentage data for the problem.
Returns
SCIP_OKAY if printing succeeded or an appropriate error code otherwise.

Referenced by BN_doIterativePrint().

◆ IO_printcountsols()

SCIP_RETCODE IO_printcountsols ( SCIP *  scip,
ParentSetData psd,
char *  filename 
)

Prints solutions found using countsols.

Parameters
scipThe SCIP instance to print solutions for.
filenameThe name of the file where solutions will be put.
Returns
SCIP_OKAY if printing succeeded or an error otherwise.

References ParentSetData::n, ParentSetData::nParentSets, ParentSetData::PaVars, and printSolutionLegacyFormat().

Referenced by BN_printcountsols().

Here is the call graph for this function:

◆ IO_printHeader()

SCIP_RETCODE IO_printHeader ( SCIP *  scip)

Prints a header which describes the GOBNILP and SCIP systems being used.

Parameters
scipThe SCIP instance that is being used.
Returns
SCIP_OKAY if printing succeeded or an error code otherwise.

Referenced by BN_printHeader().

◆ IO_printParameters()

SCIP_RETCODE IO_printParameters ( SCIP *  scip)

Prints any of the current SCIP or GOBNILP parameters not at their default value.

Parameters
scipThe SCIP instance to consult the parameters of.
Returns
SCIP_OKAY if the parameters were printed correctly, or an error code otherwise.

Referenced by BN_printParameters().

◆ IO_printProblem()

SCIP_RETCODE IO_printProblem ( SCIP *  scip,
int  run 
)

Prints the current problem in cip format.

Parameters
scipThe SCIP instance for which to print the problem.
runThe iteration of the main loop that the problem is to be solved on.
Returns
SCIP_OKAY if the problem was printed correctly or an appropriate error message otherwise.

References createFilename().

Referenced by BN_printProblem().

Here is the call graph for this function:

◆ IO_printScoresInJKLFormat()

SCIP_RETCODE IO_printScoresInJKLFormat ( SCIP *  scip,
ParentSetData psd,
SCIP_Real **  scores 
)

Conditionally, prints the scores to file.

Parameters
scipThe SCIP instance the scores belong to.
psdThe parent set data to print the data for.
scoresLocal scores (only used if SCIP variables have not been created)
Returns
SCIP_OKAY if printing succeeded, or an error code otherwsie.

References createFilename(), ParentSetData::n, ParentSetData::nodeNames, ParentSetData::nParents, ParentSetData::nParentSets, ParentSetData::ParentSets, and ParentSetData::PaVars.

Referenced by BN_printScores(), and readProblemInNonCIPFormat().

Here is the call graph for this function:

◆ printAverages()

static SCIP_RETCODE printAverages ( SCIP *  scip,
MA_info ma_info,
ParentSetData psd,
char *  filename,
char *  format 
)
static

Prints the model average data.

Parameters
scipThe SCIP instance for which to print the averages.
psdThe parentage data for the problem.
filenameThe filename to output to, "stdout" for stdout or "" for nowhere.
formatThe format in which to print the averages. Recognised values are dot, pedigree, scoreandtime, legacy, adjacencymatrx and normal.
Returns
SCIP_OKAY if the averages were printed correctly or an appropriate error message otherwise.

References MA_getAverageValue(), MA_getTotalAveragesScore(), MA_getTotalAveragesTime(), ParentSetData::n, ParentSetData::nParentSets, ParentSetData::PaVars, and printToFile().

Here is the call graph for this function:

◆ printSolution()

static SCIP_RETCODE printSolution ( SCIP *  scip,
ParentSetData psd,
char *  filename,
char *  format 
)
static

Prints the solution of the problem after solving.

Parameters
scipThe SCIP instance for which to print the solution.
psdThe parentage data for the problem.vvv
filenameThe filename to output to, "stdout" for stdout or "" for nowhere.
formatThe format in which to print the solution. Recognised values are dot, pedigree, scoreandtime, legacy, adjacencymatrx and normal.
Returns
SCIP_OKAY if the solution was printed correctly or an appropriate error message otherwise.

References ParentSetData::n, ParentSetData::nParentSets, ParentSetData::PaVars, PD_getCurrentPedigreeVarValues(), PD_inPedigreeMode(), and printToFile().

Here is the call graph for this function:

◆ printSolutionAdjacencyMatrixFormat()

static SCIP_RETCODE printSolutionAdjacencyMatrixFormat ( SCIP *  scip,
ParentSetData psd,
SCIP_Real **  Scores,
SCIP_Bool **  selected,
SCIP_Real  total_score,
FILE *  stream 
)
static

Prints the solution as an adjacency matrix.

Parameters
scipThe SCIP instance to which the solution belongs.
psdThe problem data used by the solution.
ScoresThe score data to use for the solution.
selectedWhether each of the variables is selected in the solution.
total_scoreThe overall score of this solution.
streamWhere to print the solution.
Returns
SCIP_OKAY if the solution was printed correctly or an appropriate error message otherwise.

References ParentSetData::n, ParentSetData::nParents, ParentSetData::nParentSets, and ParentSetData::ParentSets.

Referenced by printToFile().

◆ printSolutionBNFormat()

static SCIP_RETCODE printSolutionBNFormat ( SCIP *  scip,
ParentSetData psd,
SCIP_Real **  Scores,
SCIP_Bool **  selected,
SCIP_Real  total_score,
FILE *  stream 
)
static

Prints the solution in a Bayesian network format.

Parameters
scipThe SCIP instance to which the solution belongs.
psdThe problem data used by the solution.
ScoresThe score data to use for the solution.
selectedWhether each of the variables is selected in the solution.
total_scoreThe overall score of this solution.
streamWhere to print the solution.
Returns
SCIP_OKAY if the solution was printed correctly or an appropriate error message otherwise.

References ParentSetData::n, ParentSetData::nodeNames, ParentSetData::nParents, ParentSetData::nParentSets, and ParentSetData::ParentSets.

Referenced by printToFile().

◆ printSolutionDotFormat()

static SCIP_RETCODE printSolutionDotFormat ( SCIP *  scip,
ParentSetData psd,
SCIP_Real **  Scores,
SCIP_Bool **  selected,
SCIP_Real  total_score,
FILE *  stream 
)
static

Prints the solution as a file suitable for plotting using the dot command from graphviz.

Parameters
scipThe SCIP instance to which the solution belongs.
psdThe problem data used by the solution.
ScoresThe score data to use for the solution.
selectedWhether each of the variables is selected in the solution.
total_scoreThe overall score of this solution.
streamWhere to print the solution.
Returns
SCIP_OKAY if the solution was printed correctly or an appropriate error message otherwise.

References ParentSetData::n, ParentSetData::nodeNames, ParentSetData::nParents, ParentSetData::nParentSets, and ParentSetData::ParentSets.

Referenced by printToFile().

◆ printSolutionLegacyFormat()

static SCIP_RETCODE printSolutionLegacyFormat ( SCIP *  scip,
ParentSetData psd,
SCIP_Real **  Scores,
SCIP_Bool **  selected,
SCIP_Real  total_score,
FILE *  stream 
)
static

Prints the solution in the traditional GOBNILP format.

Parameters
scipThe SCIP instance to which the solution belongs.
psdThe problem data used by the solution.
ScoresThe score data to use for the solution.
selectedWhether each of the variables is selected in the solution.
total_scoreThe overall score of this solution.
streamWhere to print the solution.
Returns
SCIP_OKAY if the solution was printed correctly or an appropriate error message otherwise.

References ParentSetData::n, ParentSetData::nodeNames, ParentSetData::nParents, ParentSetData::nParentSets, and ParentSetData::ParentSets.

Referenced by IO_printcountsols(), and printToFile().

◆ printSolutionMECFormat()

static SCIP_RETCODE printSolutionMECFormat ( SCIP *  scip,
ParentSetData psd,
SCIP_Real **  Scores,
SCIP_Bool **  selected,
SCIP_Real  total_score,
FILE *  stream 
)
static

Prints the Markov equivalance class of the solution.

Parameters
scipThe SCIP instance to which the solution belongs.
psdThe problem data used by the solution.
ScoresThe score data to use for the solution.
selectedWhether each of the variables is selected in the solution.
total_scoreThe overall score of this solution.
streamWhere to print the solution.
Returns
SCIP_OKAY if the solution was printed correctly or an appropriate error message otherwise.

References ParentSetData::n, ParentSetData::nodeNames, ParentSetData::nParents, ParentSetData::nParentSets, and ParentSetData::ParentSets.

Referenced by printToFile().

◆ printSolutionScoreAndTimeFormat()

static SCIP_RETCODE printSolutionScoreAndTimeFormat ( SCIP *  scip,
ParentSetData psd,
SCIP_Real **  Scores,
SCIP_Bool **  selected,
SCIP_Real  total_score,
FILE *  stream,
SCIP_Real  soltime 
)
static

Prints just the objective value of the given solution and the time taken to find the solution.

Parameters
scipThe SCIP instance to which the solution belongs.
psdThe problem data used by the solution.
ScoresThe score data to use for the solution.
selectedWhether each of the variables is selected in the solution.
total_scoreThe overall score of this solution.
streamWhere to print the solution.
soltimeThe time taken to find the solution.
Returns
SCIP_OKAY if the solution was printed correctly or an appropriate error message otherwise.

Referenced by printToFile().

◆ printToFile()

static SCIP_RETCODE printToFile ( SCIP *  scip,
ParentSetData psd,
SCIP_Real **  Scores,
SCIP_Bool **  selected,
char *  filename,
char *  format,
SCIP_Real  soltime,
SCIP_Real  total_score,
SCIP_Bool *  pedVals 
)
static

Prints a solution to the problem.

Parameters
scipThe SCIP instance for which to print the solution.
psdThe problem data used by the solution.
ScoresThe score data to use for the solution.
selectedWhether each of the variables is selected in the solution.
total_scoreThe overall score of this solution.
filenameThe filename to output to, "stdout" for stdout or "" for nowhere.
formatThe format in which to print the solution. Recognised values are dot, pedigree, scoreandtime, legacy, adjacencymatrx and normal.
soltimeThe time taken to find the solution.
pedValsWhether each of the pedigree specific variables is selected in the solution.
Returns
SCIP_OKAY if the solution was printed correctly or an appropriate error message otherwise.

References PD_printSolutionPedigreeFormat(), printSolutionAdjacencyMatrixFormat(), printSolutionBNFormat(), printSolutionDotFormat(), printSolutionLegacyFormat(), printSolutionMECFormat(), and printSolutionScoreAndTimeFormat().

Referenced by printAverages(), and printSolution().

Here is the call graph for this function: