GOBNILP  f164d83
Macros | Functions
probdata_bn.c File Reference

Provides the core functionality for the Bayesian network learning problem. More...

#include <string.h>
#include <ctype.h>
#include <float.h>
#include "probdata_bn.h"
#include "pedigrees.h"
#include "pedigree_scorer.h"
#include "cons_dagcluster.h"
#include "cons_ci.h"
#include "cons_chordal.h"
#include "cons_distinguishedrep.h"
#include "heur_sinks.h"
#include "utils.h"
#include "output.h"
#include "metadata.h"
#include "scoring.h"
#include "scip/misc.h"
#include "disp_clearcols.h"
#include "event_splitdag.h"
#include "cons_lop.h"
#include "cons_partialordering.h"
#include "cons_vanilla.h"
Include dependency graph for probdata_bn.c:

Macros

#define DEFAULT_GOBNILP_INPUT_FORMAT   "jkl"
 

Functions

static SCIP_RETCODE addAcyclicityConstraints (SCIP *scip, ParentSetData *psd)
 Adds the acyclity constraints to the problem. More...
 
static SCIP_RETCODE addAdditionalConstraints (SCIP *scip, ParentSetData *psd)
 Adds constraints ruling out immoralities in the DAG. More...
 
static SCIP_RETCODE addAncestorVariables (SCIP *scip, ParentSetData *psd)
 If gobnilp/ancestorvars == TRUE, creates binary variables encoding the ancestor relation Creates binary variables anc[i][j] where anc[i][j]==1 iff j is an ancestor of i If gobnilp/useconspartialordering == TRUE, the partial order constraint is used on these variables. More...
 
static SCIP_RETCODE addArrowVariables (SCIP *scip, ParentSetData *psd)
 Adds variables representing directed and undirected edges The branching priority for these variables is set at 10, so typically SCIP will branch on these variables rather than parent set variables. More...
 
static SCIP_RETCODE addEdgeNumberConstraints (SCIP *scip, ParentSetData *psd)
 Adds constraints on the number of edges in the DAG. More...
 
static SCIP_RETCODE addFounderConstraints (SCIP *scip, ParentSetData *psd)
 Adds constraints on the number of possible founders. More...
 
static SCIP_RETCODE addGeneralDAGConstraints (SCIP *scip, ParentSetData *psd)
 Adds general structural constraints to the DAG. More...
 
static SCIP_RETCODE addImsetVariables (SCIP *scip, ParentSetData *psd)
 The imsetvar for a subset of nodes = 1 iff one of the elements in the subset has all the others as parents. More...
 
static SCIP_RETCODE addKBestMECVariables (SCIP *scip, ParentSetData *psd)
 
static SCIP_RETCODE addNChildrenVars (SCIP *scip, const ParentSetData *psd)
 Adds variables which count how many children a node has.
 
static SCIP_RETCODE addOneParentSetConstraints (SCIP *scip, ParentSetData *psd)
 Adds the constraints that there must be one parent set to the problem. More...
 
static SCIP_RETCODE addOrderedCoveredArcConstraints (SCIP *scip, ParentSetData *psd)
 Adds constraints ruling out covered arcs from lower to higher vertices. More...
 
static SCIP_RETCODE addParentNumberConstraints (SCIP *scip, const ParentSetData *psd)
 Adds constraints on the number of nodes that can be parents. More...
 
static SCIP_RETCODE addParentVariables (SCIP *scip, ParentSetData *psd, SCIP_Real **scores)
 Creates and adds the parent variables to the problem. More...
 
static SCIP_RETCODE addPaSizeVariables (SCIP *scip, ParentSetData *psd)
 If gobnilp/pasizevars == TRUE adds and sets the branching priorities of variables representing parent set size. More...
 
static SCIP_RETCODE addPosindVariables (SCIP *scip, ParentSetData *psd)
 If gobnilp/posindvars == TRUE, adds binary variables indicating the position of nodes in a total order consistent with a DAG solution. More...
 
static SCIP_RETCODE addPosVariables (SCIP *scip, ParentSetData *psd)
 If gobnilp/posvars == TRUE, creates integer variables giving a generation number for each node If a node is a founder its generation number is 0 If j is a parent of i its generation number is strictly less than i's An upper bound on any such variable can be set using gobnilp/maxpos Uses an Indicator constraint. More...
 
static SCIP_RETCODE addTotalorderVariables (SCIP *scip, ParentSetData *psd)
 If gobnilp/totalordervars == TRUE, creates, and sets the branching priority for, binary variables encoding a total order consistent with a DAG solution Creates binary variables order[i][j] where order[i][j]==1 if i comes after j in the total ordering. More...
 
static SCIP_RETCODE ancestor_constraint (SCIP *scip, ParentSetData *psd, int i, int j, SCIP_Bool truthvalue)
 Adds a constraint stating that an ancestor relation must be present or absent. More...
 
static SCIP_RETCODE BN_addMECNonRepetitionConstraint (SCIP *scip, int run)
 Adds a constraint that prevents networks in the same MEC as the current best network being found again. More...
 
SCIP_RETCODE BN_addNonRepetitionConstraint (SCIP *scip, int run)
 Adds a constraint that prevents the current best network being found again. More...
 
SCIP_RETCODE BN_addParameters (SCIP *scip)
 Adds GOBNILP specific parameters to those recognised by SCIP. More...
 
SCIP_RETCODE BN_doIterativePrint (SCIP *scip, MA_info *ma_info, int run)
 Prints appropriate information about each optimal solution obtained. More...
 
int BN_getNumberOfRepeats (SCIP *scip)
 Gets the number of most likely Bayesian networks that should be found. More...
 
SCIP_RETCODE BN_includePlugins (SCIP *scip)
 Includes all plugins needed by the problem. More...
 
SCIP_RETCODE BN_printcountsols (SCIP *scip, char *filename)
 Prints solutions found using countsols. More...
 
SCIP_RETCODE BN_printHeader (SCIP *scip)
 Prints a header which describes the GOBNILP and SCIP systems being used. More...
 
SCIP_RETCODE BN_printParameters (SCIP *scip)
 Prints any of the current SCIP or GOBNILP parameters not at their default value. More...
 
SCIP_RETCODE BN_printProblem (SCIP *scip, int run)
 Prints the current problem. More...
 
SCIP_RETCODE BN_printScores (SCIP *scip)
 Prints the scores for the family variables in Jaakkola format. More...
 
SCIP_RETCODE BN_readProblem (SCIP *scip, char *inputformat, char *frequencyfile, const char *filename)
 Reads in a problem from a file. More...
 
SCIP_RETCODE BN_setParamaterDefaults (SCIP *scip)
 Sets various built-in SCIP parameters to suitable GOBNILP values. More...
 
SCIP_RETCODE BN_suppresscols (SCIP *scip)
 Suppresses output columns according to the value of parameter gobnilp/verblevelsetcols. More...
 
static SCIP_RETCODE ci_constraint (SCIP *scip, ParentSetData *psd, const char *a_str, const char *b_str, const char *s_str)
 Adds a conditional independence (ci) constraint. More...
 
static int countParentSets (FILE *file)
 
static int countVars (FILE *file)
 
static SCIP_RETCODE createBasicModel (SCIP *scip, ParentSetData *psd, SCIP_Real **scores)
 Adds the variables and constraints needed for the basic DAG learning problem. More...
 
static SCIP_Bool differ (SCIP *scip, ParentSetData *psd, int i, int ki1, int ki2, int j)
 Determines if two parent sets differ by just a single given item. More...
 
static SCIP_RETCODE edge_constraint (SCIP *scip, ParentSetData *psd, int i, int j, SCIP_Bool undirected, SCIP_Bool truthvalue)
 Adds a constraint stating that an edge must be present or absent. More...
 
static void extractMetaNameAndValue (const char *string, char *name, char *value)
 
static SCIP_RETCODE getDelimiters (SCIP *scip, int *num_delims, char **delims, SCIP_Bool *merge_delims)
 Gets the delimiter information needed to read in information from files. More...
 
static char * getInputFormat (SCIP *scip, char *inputformat, const char *filename)
 Gets the format in which the input file has been given. More...
 
static SCIP_RETCODE getProblemName (const char *filename, char *probname, int maxSize)
 Gets a problem name based on the file from which it was read. More...
 
static SCIP_RETCODE immorality_constraint (SCIP *scip, ParentSetData *psd, int i, int j, int child, SCIP_Bool truthvalue)
 Adds a constraint enforcing or preventing an immorality constraint. More...
 
static SCIP_RETCODE order_constraint (SCIP *scip, ParentSetData *psd, int i, int j)
 Adds a constraint stating that variable i must come before variable j in any variable ordering consistent with the learned network This works by simply fixing the relevant total order variable An error is generated if the user has not asked for the total order constraint handler to be used. More...
 
static SCIP_RETCODE parseSet (SCIP *scip, ParentSetData *psd, const char *str, int *set, int *n_set, SCIP_Bool *success)
 Parses a string to extract a set from it. More...
 
static SCIP_RETCODE process_constraint (SCIP *scip, ParentSetData *psd, const char *line)
 Adds a constraint on the DAG structure. More...
 
static SCIP_RETCODE readProblemInCIPFormat (SCIP *scip, const char *filename)
 Reads a problem from a file in cip format. More...
 
static SCIP_RETCODE readProblemInJaakkolaFormat (SCIP *scip, const char *filename, ParentSetData *psd, SCIP_Real ***scores, PropertyData *prop)
 Reads local score BN file (in Jaakkola format) More...
 
static SCIP_RETCODE readProblemInNonCIPFormat (SCIP *scip, char *frequencyfile, const char *filename, char *format)
 Reads a problem from a file in a format other than CIP. More...
 
static SCIP_RETCODE readProblemInPSSFormat (SCIP *scip, const char *filename, ParentSetData *psd, SCIP_Real ***scores, PropertyData *prop)
 Reads local score BN file (in PSS format) More...
 
static SCIP_DECL_PROBDELORIG (probdelorigBN)
 delete problem data
 
static SCIP_RETCODE setBranchingPriorities (SCIP *scip, ParentSetData *psd)
 Sets the branching priority of variables. More...
 
static SCIP_RETCODE setSpecialProperties (SCIP *scip, ParentSetData *psd)
 Sets properties to non-standard values. More...
 
static SCIP_RETCODE sink_constraint (SCIP *scip, ParentSetData *psd, int sink)
 Adds a constraint stating that a given node must be a sink This is effected by fixing all parent set indicator variables to zero if the sink is one of the parents. More...
 
static int splitAtWhitespace (const char *string, char ***parts)
 

Detailed Description

Provides the core functionality for the Bayesian network learning problem.

Function Documentation

◆ addAcyclicityConstraints()

static SCIP_RETCODE addAcyclicityConstraints ( SCIP *  scip,
ParentSetData psd 
)
static

Adds the acyclity constraints to the problem.

Parameters
scipThe SCIP instance to add the constraints to.
psdThe parent set data to use for generating the acyclity constraints.
Returns
SCIP_OKAY if the consraints were all added successfully.

References DC_createCons(), PS_deallocateParentSetData(), and PS_splitToComponents().

Referenced by createBasicModel().

Here is the call graph for this function:

◆ addAdditionalConstraints()

static SCIP_RETCODE addAdditionalConstraints ( SCIP *  scip,
ParentSetData psd 
)
static

Adds constraints ruling out immoralities in the DAG.

Parameters
scipThe SCIP instance to add the constraint to.
psdThe parent set data associated with this problem.
Returns
SCIP_OKAY if the constraints could be successfully added.Adds optional constraints to the problem based on the parameters in the settings file.
Parameters
scipThe SCIP instance to add the constraint to.
psdThe parent set data associated with this problem.
Returns
SCIP_OKAY if the constraints could be successfully added.

References addEdgeNumberConstraints(), addFounderConstraints(), addGeneralDAGConstraints(), addOrderedCoveredArcConstraints(), addParentNumberConstraints(), PD_addPedigreeSpecificConstraints(), PD_inPedigreeMode(), SCIPcreateConsBasicChordal(), SCIPcreateConsBasicDistinguishedrep(), SCIPcreateConsVanilla(), SCIPincludeConshdlrDistinguishedrep(), and SCIPincludeConshdlrVanilla().

Referenced by BN_readProblem().

Here is the call graph for this function:

◆ addAncestorVariables()

static SCIP_RETCODE addAncestorVariables ( SCIP *  scip,
ParentSetData psd 
)
static

If gobnilp/ancestorvars == TRUE, creates binary variables encoding the ancestor relation Creates binary variables anc[i][j] where anc[i][j]==1 iff j is an ancestor of i If gobnilp/useconspartialordering == TRUE, the partial order constraint is used on these variables.

Returns
SCIP_OKAY as long as all is well
Parameters
scipSCIP data structure
psdparent sets data structure

References ParentSetData::n, and SCIPcreateConsPartialOrdering().

Referenced by createBasicModel().

Here is the call graph for this function:

◆ addArrowVariables()

static SCIP_RETCODE addArrowVariables ( SCIP *  scip,
ParentSetData psd 
)
static

Adds variables representing directed and undirected edges The branching priority for these variables is set at 10, so typically SCIP will branch on these variables rather than parent set variables.

Returns
SCIP_OKAY if all is well
Parameters
scipSCIP data structure
psdparent sets data structure

References get_arrow(), hashtableCreateArrow(), ParentSetData::n, ParentSetData::nodeNames, ParentSetData::nParents, ParentSetData::nParentSets, ParentSetData::ParentSets, ParentSetData::PaVars, put_arrow(), and put_edge().

Referenced by createBasicModel().

Here is the call graph for this function:

◆ addEdgeNumberConstraints()

static SCIP_RETCODE addEdgeNumberConstraints ( SCIP *  scip,
ParentSetData psd 
)
static

Adds constraints on the number of edges in the DAG.

Parameters
scipThe SCIP instance to add the constraint to.
psdThe parent set data associated with this problem.
Returns
SCIP_OKAY if the constraints could be successfully added.

References get_edge(), and ParentSetData::n.

Referenced by addAdditionalConstraints().

Here is the call graph for this function:

◆ addFounderConstraints()

static SCIP_RETCODE addFounderConstraints ( SCIP *  scip,
ParentSetData psd 
)
static

Adds constraints on the number of possible founders.

Parameters
scipThe SCIP instance to add the constraint to.
psdThe parent set data associated with this problem.
Returns
SCIP_OKAY if the constraints could be successfully added.

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

Referenced by addAdditionalConstraints().

◆ addGeneralDAGConstraints()

static SCIP_RETCODE addGeneralDAGConstraints ( SCIP *  scip,
ParentSetData psd 
)
static

Adds general structural constraints to the DAG.

Parameters
scipThe SCIP instance to add the constraint to.
psdThe parent set data associated with this problem.
Returns
SCIP_OKAY if the constraints could be successfully added.

References get_edge(), ParentSetData::n, ParentSetData::nParents, ParentSetData::nParentSets, ParentSetData::ParentSets, ParentSetData::PaVars, and process_constraint().

Referenced by addAdditionalConstraints().

Here is the call graph for this function:

◆ addImsetVariables()

static SCIP_RETCODE addImsetVariables ( SCIP *  scip,
ParentSetData psd 
)
static

The imsetvar for a subset of nodes = 1 iff one of the elements in the subset has all the others as parents.

It is binary due to acyclicity. If gobnilp/imsetvars == TRUE, creates and sets the branching priority for, variables representing imsets for subsets of nodes of size 3 Note that the imsetvar for a subset of size 2 is an 'edge' variable - these are always created.

Returns
SCIP_OKAY, if all is well
Parameters
scipSCIP data structure
psdparent sets data structure

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

Referenced by createBasicModel().

Here is the call graph for this function:

◆ addKBestMECVariables()

static SCIP_RETCODE addKBestMECVariables ( SCIP *  scip,
ParentSetData psd 
)
static
Parameters
scipSCIP data structure
psdparent sets data structure

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

Referenced by createBasicModel().

Here is the call graph for this function:

◆ addOneParentSetConstraints()

static SCIP_RETCODE addOneParentSetConstraints ( SCIP *  scip,
ParentSetData psd 
)
static

Adds the constraints that there must be one parent set to the problem.

Parameters
scipThe SCIP instance to add the constraints to.
psdThe parent set data to use for generating the constraints.
Returns
SCIP_OKAY if the consraints were all added successfully.

References ParentSetData::n, ParentSetData::nParentSets, and ParentSetData::PaVars.

Referenced by createBasicModel().

◆ addOrderedCoveredArcConstraints()

static SCIP_RETCODE addOrderedCoveredArcConstraints ( SCIP *  scip,
ParentSetData psd 
)
static

Adds constraints ruling out covered arcs from lower to higher vertices.

Parameters
scipThe SCIP instance to add the constraint to.
psdThe parent set data associated with this problem.
Returns
SCIP_OKAY if the constraints could be successfully added.

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

Referenced by addAdditionalConstraints().

Here is the call graph for this function:

◆ addParentNumberConstraints()

static SCIP_RETCODE addParentNumberConstraints ( SCIP *  scip,
const ParentSetData psd 
)
static

Adds constraints on the number of nodes that can be parents.

This also requires the creation of a number of binary variables.

Parameters
scipThe SCIP instance to add the constraint to.
psdThe parent set data associated with this problem.
Returns
SCIP_OKAY if the constraints could be successfully added.

References get_arrow(), ParentSetData::n, and ParentSetData::nodeNames.

Referenced by addAdditionalConstraints().

Here is the call graph for this function:

◆ addParentVariables()

static SCIP_RETCODE addParentVariables ( SCIP *  scip,
ParentSetData psd,
SCIP_Real **  scores 
)
static

Creates and adds the parent variables to the problem.

Parameters
scipThe SCIP instance to create the variables for.
psdThe parent set data to base the variables on.
scoresThe objective function coefficients for each variable.
Returns
SCIP_OKAY if all variables were successfully created.

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

Referenced by createBasicModel().

◆ addPaSizeVariables()

static SCIP_RETCODE addPaSizeVariables ( SCIP *  scip,
ParentSetData psd 
)
static

If gobnilp/pasizevars == TRUE adds and sets the branching priorities of variables representing parent set size.

Creates pasize[i] for each node i which is constrained to be equal to the parent set size of node i

Returns
SCIP_OKAY as long as all is well
Parameters
scipThe SCIP instance
psdParent set data

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

Referenced by createBasicModel().

◆ addPosindVariables()

static SCIP_RETCODE addPosindVariables ( SCIP *  scip,
ParentSetData psd 
)
static

If gobnilp/posindvars == TRUE, adds binary variables indicating the position of nodes in a total order consistent with a DAG solution.

Creates n^2 variables posind[i][j], where posind[i][j]==1 iff variable i is in position j in some total order consistent with a DAG solution This is done by the following constraints: pos(j) - pos(i) + n*I(j is a parent of i) =< n-1 pos(i) and pos(j) are integers denoted the index of i and j in a total order. They are defined as a linear combination of posind variables in the obvious way.

Returns
SCIP_OKAY as long as all is well
Parameters
scipSCIP data structure
psdparent sets data structure

References get_arrow(), and ParentSetData::n.

Referenced by createBasicModel().

Here is the call graph for this function:

◆ addPosVariables()

static SCIP_RETCODE addPosVariables ( SCIP *  scip,
ParentSetData psd 
)
static

If gobnilp/posvars == TRUE, creates integer variables giving a generation number for each node If a node is a founder its generation number is 0 If j is a parent of i its generation number is strictly less than i's An upper bound on any such variable can be set using gobnilp/maxpos Uses an Indicator constraint.

Returns
SCIP_OKAY as long as all is well
Parameters
scipSCIP data structure
psdparent sets data structure

References get_arrow(), ParentSetData::n, ParentSetData::nParents, ParentSetData::nParentSets, and ParentSetData::PaVars.

Referenced by createBasicModel().

Here is the call graph for this function:

◆ addTotalorderVariables()

static SCIP_RETCODE addTotalorderVariables ( SCIP *  scip,
ParentSetData psd 
)
static

If gobnilp/totalordervars == TRUE, creates, and sets the branching priority for, binary variables encoding a total order consistent with a DAG solution Creates binary variables order[i][j] where order[i][j]==1 if i comes after j in the total ordering.

If gobnilp/useconslinearordering == TRUE, the linear ordering constraint handler that comes as an example with SCIP is used If gobnilp/inittransitivity == TRUE then all n^3 transitivity constraints are added to the problem If gobnilp/bestparentsfororder == TRUE then, for each node, a constraint is added so that the highest scoring parent set consistent with the total order must be selected

Returns
SCIP_OKAY as long as all is well
Parameters
scipSCIP data structure
psdparent sets data structure

References get_arrow(), ParentSetData::n, ParentSetData::nParents, ParentSetData::nParentSets, ParentSetData::ParentSets, ParentSetData::PaVars, and SCIPcreateConsLOP().

Referenced by createBasicModel().

Here is the call graph for this function:

◆ ancestor_constraint()

static SCIP_RETCODE ancestor_constraint ( SCIP *  scip,
ParentSetData psd,
int  i,
int  j,
SCIP_Bool  truthvalue 
)
static

Adds a constraint stating that an ancestor relation must be present or absent.

This works by simply fixing the relevant ancestor variable

Parameters
scipThe SCIP instance in which to add the constraint.
psdThe parent set data for the problem.
iThe descendant node
jThe ancestor node
truthvalueWhether the relation must or must not appear
Returns
SCIP_OKAY if the constraint on the edge was added successfully or an error code otherwise.

Referenced by process_constraint().

◆ BN_addMECNonRepetitionConstraint()

static SCIP_RETCODE BN_addMECNonRepetitionConstraint ( SCIP *  scip,
int  run 
)
static

Adds a constraint that prevents networks in the same MEC as the current best network being found again.

Parameters
scipThe SCIP instance being used for the optimisation.
runThe iteration of the loop that this soilution was found on.
Returns
SCIP_OKAY if a constraint could be added, or an error otherwise.

References get_edge(), MD_getParentSetData(), and ParentSetData::n.

Referenced by BN_addNonRepetitionConstraint().

Here is the call graph for this function:

◆ BN_addNonRepetitionConstraint()

SCIP_RETCODE BN_addNonRepetitionConstraint ( SCIP *  scip,
int  run 
)

Adds a constraint that prevents the current best network being found again.

Parameters
scipThe SCIP instance being used for the optimisation.
runThe iteration of the loop that this soilution was found on.
Returns
SCIP_OKAY if a constraint could be added, or an error otherwise.

References BN_addMECNonRepetitionConstraint(), MD_getParentSetData(), ParentSetData::n, ParentSetData::nParentSets, and ParentSetData::PaVars.

Here is the call graph for this function:

◆ BN_addParameters()

SCIP_RETCODE BN_addParameters ( SCIP *  scip)

Adds GOBNILP specific parameters to those recognised by SCIP.

Parameters
scipThe SCIP instance to add to the parameters to.
Returns
SCIP_OKAY if the operation succeeded or an appropriate error coede otherwise.

References IO_addOutputParameters(), PD_addPedigreeParameters(), SC_addScoringParameters(), UT_addBoolParam(), UT_addIntParam(), UT_addLongintParam(), UT_addRealParam(), and UT_addStringParam().

Referenced by main().

Here is the call graph for this function:

◆ BN_doIterativePrint()

SCIP_RETCODE BN_doIterativePrint ( SCIP *  scip,
MA_info ma_info,
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.
Returns
SCIP_OKAY if printing succeeded or an appropriate error code otherwise.

References IO_doIterativePrint(), and MD_getParentSetData().

Referenced by main().

Here is the call graph for this function:

◆ BN_getNumberOfRepeats()

int BN_getNumberOfRepeats ( SCIP *  scip)

Gets the number of most likely Bayesian networks that should be found.

Parameters
scipThe SCIP inatance used for finding the networks.
Returns
The number of Bayesian networks that should be found.

Referenced by main().

◆ BN_includePlugins()

SCIP_RETCODE BN_includePlugins ( SCIP *  scip)

Includes all plugins needed by the problem.

Parameters
scipThe SCIP instance to add the plugins to.
Returns
SCIP_OKAY if all plugins were added successfully, or an error otherwise.

References DC_includeConshdlr(), HS_includePrimal(), MD_initialiseMetadata(), SCIPincludeConshdlrChordal(), SCIPincludeConshdlrCi(), SCIPincludeConshdlrLOP(), and SCIPincludeConshdlrPartialOrdering().

Referenced by main().

Here is the call graph for this function:

◆ BN_printcountsols()

SCIP_RETCODE BN_printcountsols ( SCIP *  scip,
char *  filename 
)

Prints solutions found using countsols.

Parameters
scipThe SCIP instance to print scores for.
Returns
SCIP_OKAY if printing succeeded or an error otherwise.

References IO_printcountsols(), and MD_getParentSetData().

Referenced by main().

Here is the call graph for this function:

◆ BN_printHeader()

SCIP_RETCODE BN_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.

References IO_printHeader().

Referenced by main().

Here is the call graph for this function:

◆ BN_printParameters()

SCIP_RETCODE BN_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.

References IO_printParameters().

Referenced by main().

Here is the call graph for this function:

◆ BN_printProblem()

SCIP_RETCODE BN_printProblem ( SCIP *  scip,
int  run 
)

Prints the current problem.

Parameters
scipThe SCIP instance for which the problem should be printed.
runThe iteration of the main loop that the problem is to be solved on.
Returns
SCIP_OKAY if printing succeeded or an appropriate error code otherwise.

References IO_printProblem().

Referenced by main().

Here is the call graph for this function:

◆ BN_printScores()

SCIP_RETCODE BN_printScores ( SCIP *  scip)

Prints the scores for the family variables in Jaakkola format.

Parameters
scipThe SCIP instance to print scores for.
Returns
SCIP_OKAY if printing succeeded or an error otherwise.

References IO_printScoresInJKLFormat(), and MD_getParentSetData().

Referenced by main().

Here is the call graph for this function:

◆ BN_readProblem()

SCIP_RETCODE BN_readProblem ( SCIP *  scip,
char *  inputformat,
char *  frequencyfile,
const char *  filename 
)

Reads in a problem from a file.

Currently supported file formats are "jak", "cip" and "dat". The one to use is determined using the -f cmmand line argument and the filename extension. See getInputFormat() for details.

Parameters
scipThe SCIP instance to read the problem in to.
filenameThe filename from which to read the problem.
Returns
SCIP_OKAY if the problem was successfully created, or an error code otherwise.

References addAdditionalConstraints(), getInputFormat(), MD_getParentSetData(), ParentSetData::n, ParentSetData::nParents, ParentSetData::nParentSets, ParentSetData::ParentSets, readProblemInCIPFormat(), readProblemInNonCIPFormat(), setBranchingPriorities(), and setSpecialProperties().

Referenced by main().

Here is the call graph for this function:

◆ BN_setParamaterDefaults()

SCIP_RETCODE BN_setParamaterDefaults ( SCIP *  scip)

Sets various built-in SCIP parameters to suitable GOBNILP values.

These values can still be overriden using the settings file.

Parameters
scipThe SCIP instance the parameters relate to.
Returns
SCIP_OKAY if the setting worked or an appropriate error otherwise.

Referenced by main().

◆ BN_suppresscols()

SCIP_RETCODE BN_suppresscols ( SCIP *  scip)

Suppresses output columns according to the value of parameter gobnilp/verblevelsetcols.

Returns
SCIP_OKAY assuming all is well

Referenced by main().

◆ ci_constraint()

static SCIP_RETCODE ci_constraint ( SCIP *  scip,
ParentSetData psd,
const char *  a_str,
const char *  b_str,
const char *  s_str 
)
static

Adds a conditional independence (ci) constraint.

Parameters
scipThe SCIP instance in which to add the constraint.
psdThe parent set data for the problem.
a_strA set
b_strB set
s_strS (separator) set
Returns
SCIP_OKAY if the constraint was added successfully or an error code otherwise.

References ParentSetData::n, ParentSetData::nParents, ParentSetData::nParentSets, ParentSetData::ParentSets, parseSet(), ParentSetData::PaVars, and SCIPcreateConsCi().

Referenced by process_constraint().

Here is the call graph for this function:

◆ createBasicModel()

static SCIP_RETCODE createBasicModel ( SCIP *  scip,
ParentSetData psd,
SCIP_Real **  scores 
)
static

Adds the variables and constraints needed for the basic DAG learning problem.

Parameters
scipThe SCIP instance to create the problem in.
psdThe parent set data to base the problem on.
scoresThe scores of each of the parent sets in the problem.
Returns
SCIP_OKAY if the problem was created successfully.

References addAcyclicityConstraints(), addAncestorVariables(), addArrowVariables(), addImsetVariables(), addKBestMECVariables(), addNChildrenVars(), addOneParentSetConstraints(), addParentVariables(), addPaSizeVariables(), addPosindVariables(), addPosVariables(), and addTotalorderVariables().

Referenced by readProblemInNonCIPFormat().

Here is the call graph for this function:

◆ differ()

static SCIP_Bool differ ( SCIP *  scip,
ParentSetData psd,
int  i,
int  ki1,
int  ki2,
int  j 
)
static

Determines if two parent sets differ by just a single given item.

Parameters
scipThe SCIP instance the variable sets belong to.
psdThe parent set data for the problem.
iThe child variable.
ki1The index of one parent set of i.
ki2The index of another parent set of i.
jA variable.
Returns
True if the parent sets ki1 and ki2 of i are the same except for the presence of variable j in one of them but not the other.

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

Referenced by addOrderedCoveredArcConstraints().

◆ edge_constraint()

static SCIP_RETCODE edge_constraint ( SCIP *  scip,
ParentSetData psd,
int  i,
int  j,
SCIP_Bool  undirected,
SCIP_Bool  truthvalue 
)
static

Adds a constraint stating that an edge must be present or absent.

This works by simply fixing the relevant edge or arrow variable

Parameters
scipThe SCIP instance in which to add the constraint.
psdThe parent set data for the problem.
iThe node from which the edge starts.
jThe node at which the edge finishes.
undirectedWhether the edge is undirected or not.
truthvalueWhether the edge must or must not appear
Returns
SCIP_OKAY if the constraint on the edge was added successfully or an error code otherwise.

References get_arrow(), and get_edge().

Referenced by process_constraint().

Here is the call graph for this function:

◆ getDelimiters()

static SCIP_RETCODE getDelimiters ( SCIP *  scip,
int *  num_delims,
char **  delims,
SCIP_Bool *  merge_delims 
)
static

Gets the delimiter information needed to read in information from files.

Parameters
scipThe SCIP instance being used.
num_delimsThe number of delimiters.
delimsThe delimiters to use.
merge_delimsWhether consecutive delimiters should be merged into one.
Returns
SCIP_OKAY if the parameters were successfully read, or an error otherwise.

Referenced by readProblemInNonCIPFormat().

◆ getInputFormat()

static char* getInputFormat ( SCIP *  scip,
char *  inputformat,
const char *  filename 
)
static

Gets the format in which the input file has been given.

If the format has been set on the command line, this will be given. If this is not set, then the suffix of the filename will be examined. If this does not work, then DEFAULT_GOBNILP_PARAMS_FILE is used.

Parameters
scipThe SCIP instance this applies to.
filenameThe name of the file to read.
Returns
The format of the input file.

Referenced by BN_readProblem().

◆ getProblemName()

static SCIP_RETCODE getProblemName ( const char *  filename,
char *  probname,
int  maxSize 
)
static

Gets a problem name based on the file from which it was read.

This function copied from LOP example written by March Pfetsch.

Returns
SCIP_OKAY if the name could be found. An error otherwise.
Parameters
filenameinput filename
probnameoutput problemname
maxSizemaximum size of probname

Referenced by readProblemInNonCIPFormat().

◆ immorality_constraint()

static SCIP_RETCODE immorality_constraint ( SCIP *  scip,
ParentSetData psd,
int  i,
int  j,
int  child,
SCIP_Bool  truthvalue 
)
static

Adds a constraint enforcing or preventing an immorality constraint.

Parameters
scipThe SCIP instance in which to add the constraint.
psdThe parent set data for the problem.
iA parent involved in the immorality constraint.
jThe other parent involved.
childThe child involved in the constraint.
truthvalueTRUE if the immorality must exist, FALSE if it must not exist.
Returns
SCIP_OK if the constraint was added, or an error code otherwise.

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

Referenced by process_constraint().

Here is the call graph for this function:

◆ order_constraint()

static SCIP_RETCODE order_constraint ( SCIP *  scip,
ParentSetData psd,
int  i,
int  j 
)
static

Adds a constraint stating that variable i must come before variable j in any variable ordering consistent with the learned network This works by simply fixing the relevant total order variable An error is generated if the user has not asked for the total order constraint handler to be used.

Parameters
scipThe SCIP instance in which to add the constraint.
psdThe parent set data for the problem.
iThe node which must be earlier in the order.
jThe node which must be later in the order.
Returns
SCIP_OKAY if the constraint on the edge was added successfully or an error code otherwise.

Referenced by process_constraint().

◆ parseSet()

static SCIP_RETCODE parseSet ( SCIP *  scip,
ParentSetData psd,
const char *  str,
int *  set,
int *  n_set,
SCIP_Bool *  success 
)
static

Parses a string to extract a set from it.

Parameters
scipThe SCIP instance that this belongs to.
psdThe data set that the set refers to.
strstring to parse
setresult set
n_setlength of set
successsuccess flag

References get_index().

Referenced by ci_constraint().

Here is the call graph for this function:

◆ process_constraint()

static SCIP_RETCODE process_constraint ( SCIP *  scip,
ParentSetData psd,
const char *  line 
)
static

Adds a constraint on the DAG structure.

Parameters
scipThe SCIP instance in which to add the constraint.
psdThe parent set data relating to this problem.
lineThe description of the constraint to add.
Returns
SCIP_OKAY if the constraint was added or an error otherwise.

References ancestor_constraint(), ci_constraint(), edge_constraint(), get_index(), immorality_constraint(), order_constraint(), and sink_constraint().

Referenced by addGeneralDAGConstraints().

Here is the call graph for this function:

◆ readProblemInCIPFormat()

static SCIP_RETCODE readProblemInCIPFormat ( SCIP *  scip,
const char *  filename 
)
static

Reads a problem from a file in cip format.

Parameters
scipThe SCIP instance in to which the problem should be read.
filenameThe file to read the problem from.
Returns
SCIP_OKAY if the problem was successfully created, or an error code otherwise.

Referenced by BN_readProblem().

◆ readProblemInJaakkolaFormat()

static SCIP_RETCODE readProblemInJaakkolaFormat ( SCIP *  scip,
const char *  filename,
ParentSetData psd,
SCIP_Real ***  scores,
PropertyData prop 
)
static

Reads local score BN file (in Jaakkola format)

Format:

  • first line is: number of variables then local scores for each variable
  • first line of section of local scores is "variable number_of_parent_sets"
  • other lines are like "score 3 parent1 parent2 parent3" (e.g. when there are 3 parents)
Parameters
scipThe SCIP instance being used.
filenameThe file to read from.
psdThe parentage data that is read from the file.
scoresThe score of each of the parent set combinations.
propThe properties of the data read from the file.
Returns
SCIP_OKAY if reading was successful, or an appropriate error code otherwise.

References ParentSetData::n, PropertyData::n, ParentSetData::nodeNames, ParentSetData::nParents, ParentSetData::nParentSets, PropertyData::num_properties, ParentSetData::ParentSets, PropertyData::property_names, and PropertyData::property_values.

Referenced by readProblemInNonCIPFormat().

◆ readProblemInNonCIPFormat()

static SCIP_RETCODE readProblemInNonCIPFormat ( SCIP *  scip,
char *  frequencyfile,
const char *  filename,
char *  format 
)
static

Reads a problem from a file in a format other than CIP.

Parameters
scipThe SCIP instance in to which the problem should be read.
filenameThe file to read the problem from.
formatThe format the problem is given in.
Returns
SCIP_OKAY if the problem was successfully created, or an error code otherwise.

References createBasicModel(), getDelimiters(), getProblemName(), IO_printScoresInJKLFormat(), MD_setParentSetData(), MD_setPropertyData(), ParentSetData::n, ParentSetData::nodeNames, ParentSetData::nParents, ParentSetData::nParentSets, ParentSetData::ParentSets, ParentSetData::PaVars, PR_deallocatePropertyData(), PR_initialise(), PS_readProblemInGenomeFormat(), readProblemInJaakkolaFormat(), readProblemInPSSFormat(), and SC_readProblemInDataFormat().

Referenced by BN_readProblem().

Here is the call graph for this function:

◆ readProblemInPSSFormat()

static SCIP_RETCODE readProblemInPSSFormat ( SCIP *  scip,
const char *  filename,
ParentSetData psd,
SCIP_Real ***  scores,
PropertyData prop 
)
static

Reads local score BN file (in PSS format)

Parameters
scipThe SCIP instance being used.
filenameThe file to read from.
psdThe parentage data that is read from the file.
scoresThe score of each of the parent set combinations.
propThe properties of the data read from the file.
Returns
SCIP_OKAY if reading was successful, or an appropriate error code otherwise.

Referenced by readProblemInNonCIPFormat().

◆ setBranchingPriorities()

static SCIP_RETCODE setBranchingPriorities ( SCIP *  scip,
ParentSetData psd 
)
static

Sets the branching priority of variables.

Parameters
scipThe SCIP instance being used.
psdThe data for the problem.

References get_arrow(), get_edge(), ParentSetData::n, ParentSetData::nParentSets, and ParentSetData::PaVars.

Referenced by BN_readProblem().

Here is the call graph for this function:

◆ setSpecialProperties()

static SCIP_RETCODE setSpecialProperties ( SCIP *  scip,
ParentSetData psd 
)
static

Sets properties to non-standard values.

Parameters
scipThe SCIP instance being used.
psdThe data for the problem.

References get_arrow(), get_edge(), ParentSetData::n, ParentSetData::nParentSets, and ParentSetData::PaVars.

Referenced by BN_readProblem().

Here is the call graph for this function:

◆ sink_constraint()

static SCIP_RETCODE sink_constraint ( SCIP *  scip,
ParentSetData psd,
int  sink 
)
static

Adds a constraint stating that a given node must be a sink This is effected by fixing all parent set indicator variables to zero if the sink is one of the parents.

Parameters
scipThe SCIP instance in which to add the constraint.
psdThe parent set data for the problem.
sinkThe node which must be a sink.
Returns
SCIP_OKAY if the constraint on the edge was added successfully or an error code otherwise.

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

Referenced by process_constraint().