GOBNILP  f164d83
Functions
pedigrees.c File Reference

Contains all the functions related to the use of pedigrees in the program. More...

#include "probdata_bn.h"
#include "pedigrees.h"
#include "pedigree_data.h"
#include "parent_set_data.h"
#include "metadata.h"
#include "utils.h"
#include "versiongit.h"
#include <string.h>
Include dependency graph for pedigrees.c:

Functions

static SCIP_RETCODE addFullSiblingAgeGapConstraint (SCIP *scip, ParentSetData *psd, int max_age_gap, PedigreeData *peddata)
 Creates constraints which prevent the age gap better a pair of full siblings being too great. More...
 
static SCIP_RETCODE addHalfSiblingAgeGapConstraint (SCIP *scip, ParentSetData *psd, int max_age_gap, PedigreeData *peddata)
 Creates constraints which prevent the age gap better a pair of half siblings with a common mother being too great. More...
 
static SCIP_RETCODE addMaximumNumberOfOffspringConstraint (SCIP *scip, ParentSetData *psd, int max_size, SCIP_Bool mother, SCIP_Bool father, PedigreeData *peddata)
 Creates constraints stating that individuals cannot have more than a given number of children. More...
 
static SCIP_RETCODE addMaximumSibsetSizeConstraint (SCIP *scip, ParentSetData *psd, int max_size, PedigreeData *peddata)
 Creates constraints stating that a pair of individuals cannot have more than a given number of children together. More...
 
static SCIP_RETCODE addSexConsistencyConstraint (SCIP *scip, ParentSetData *psd, PedigreeData *peddata)
 Creates constraints enforcing sexual consistency on a pedigree. More...
 
static SCIP_RETCODE assignSexVariables (SCIP *scip, SCIP_SOL *sol, ParentSetData *psd, SCIP_Bool *possible)
 Determines a possible assignment of the sex variables for a given primal solution. More...
 
static SCIP_Bool checkSuitableForPedigree (SCIP *scip, ParentSetData *psd)
 Checks whether a SCIP problem is suitable for use as a pedigree. More...
 
static SCIP_RETCODE PD_addPedigreeConstraints (SCIP *scip, ParentSetData *psd, PedigreeData *peddata)
 Adds all appropriate pedigree based constraints to the problem. More...
 
SCIP_RETCODE PD_addPedigreeParameters (SCIP *scip)
 Makes SCIP recognise parameters related to pedigree reconstruction. More...
 
SCIP_RETCODE PD_addPedigreeSpecificConstraints (SCIP *scip, ParentSetData *psd)
 Adds any constraints and variables needed for pedigree based constraints. More...
 
static SCIP_RETCODE PD_addPedigreeVariables (SCIP *scip, ParentSetData *psd, PedigreeData *peddata)
 Creates any needed variables needed specifically for learning pedigrees. More...
 
SCIP_RETCODE PD_assignPedigreeVariables (SCIP *scip, SCIP_SOL *sol, ParentSetData *psd, SCIP_Bool *possible)
 Tries to find values for any pedigree specific variables in a given primal solution. More...
 
SCIP_Bool * PD_getCurrentPedigreeVarValues (SCIP *scip)
 Gets the values of the pedigree specific variables in the current solution. More...
 
SCIP_Bool PD_inPedigreeMode (SCIP *scip)
 Determines whether the program is being run for learning pedigrees. More...
 
SCIP_RETCODE PD_printSolutionPedigreeFormat (SCIP *scip, ParentSetData *psd, SCIP_Real **Scores, SCIP_Bool **selected, SCIP_Real total_score, FILE *stream, SCIP_Bool *pedvars)
 Prints the solution as a pedigree. More...
 
static SCIP_Bool usingSexConsistency (SCIP *scip)
 Checks whether the program is enforcing sex consistency. More...
 

Detailed Description

Contains all the functions related to the use of pedigrees in the program.

Function Documentation

◆ addFullSiblingAgeGapConstraint()

static SCIP_RETCODE addFullSiblingAgeGapConstraint ( SCIP *  scip,
ParentSetData psd,
int  max_age_gap,
PedigreeData peddata 
)
static

Creates constraints which prevent the age gap better a pair of full siblings being too great.

Parameters
scipThe SCIP instance in which to apply the constraint.
psdThe parent set data associated with this problem.
max_age_gapThe maximum permissible age gap.
peddataThe pedigree data to use to construct the constraint.
Returns
SCIP_OKAY if all needed constraints were created successfully. An appropriate error code otherwise.

References PedigreeData::ages, PedigreeData::n, ParentSetData::nodeNames, ParentSetData::nParents, ParentSetData::nParentSets, ParentSetData::ParentSets, ParentSetData::PaVars, and UT_createEmptyLTEConstraint().

Referenced by PD_addPedigreeConstraints().

Here is the call graph for this function:

◆ addHalfSiblingAgeGapConstraint()

static SCIP_RETCODE addHalfSiblingAgeGapConstraint ( SCIP *  scip,
ParentSetData psd,
int  max_age_gap,
PedigreeData peddata 
)
static

Creates constraints which prevent the age gap better a pair of half siblings with a common mother being too great.

Parameters
scipThe SCIP instance in which to apply the constraint.
psdThe parent set data associated with this problem.
max_age_gapThe maximum permissible age gap.
peddataThe pedigree data to use to construct the constraint.
Returns
SCIP_OKAY if all needed constraints were created successfully. An appropriate error code otherwise.

References PedigreeData::ages, PedigreeData::n, ParentSetData::nodeNames, ParentSetData::nParents, ParentSetData::nParentSets, ParentSetData::ParentSets, ParentSetData::PaVars, PedigreeData::SexVars, and UT_createEmptyLTEConstraint().

Referenced by PD_addPedigreeConstraints().

Here is the call graph for this function:

◆ addMaximumNumberOfOffspringConstraint()

static SCIP_RETCODE addMaximumNumberOfOffspringConstraint ( SCIP *  scip,
ParentSetData psd,
int  max_size,
SCIP_Bool  mother,
SCIP_Bool  father,
PedigreeData peddata 
)
static

Creates constraints stating that individuals cannot have more than a given number of children.

Parameters
scipThe SCIP instance this applies in.
psdThe parent set data associated with this problem.
max_sizeThe maximum number of children an indiivdual may have.
motherWhether the constraint should apply to mothers.
fatherWhether the constraint should apply to fathers.
peddataThe pedigree data to use to construct the constraint.
Returns
SCIP_OKAY if adding the constraints worked. An appropriate error code otherwise.

References PedigreeData::n, ParentSetData::nodeNames, ParentSetData::nParents, ParentSetData::nParentSets, ParentSetData::ParentSets, ParentSetData::PaVars, PedigreeData::SexVars, and UT_createEmptyLTEConstraint().

Referenced by PD_addPedigreeConstraints().

Here is the call graph for this function:

◆ addMaximumSibsetSizeConstraint()

static SCIP_RETCODE addMaximumSibsetSizeConstraint ( SCIP *  scip,
ParentSetData psd,
int  max_size,
PedigreeData peddata 
)
static

Creates constraints stating that a pair of individuals cannot have more than a given number of children together.

Parameters
scipThe SCIP instance this applies in.
psdThe parent set data associated with this problem.
max_sizeThe maximum number of children an indiivdual may have.
peddataThe pedigree data to use to construct the constraint.
Returns
SCIP_OKAY if adding the constraints worked. An appropriate error code otherwise.

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

Referenced by PD_addPedigreeConstraints().

Here is the call graph for this function:

◆ addSexConsistencyConstraint()

static SCIP_RETCODE addSexConsistencyConstraint ( SCIP *  scip,
ParentSetData psd,
PedigreeData peddata 
)
static

Creates constraints enforcing sexual consistency on a pedigree.

Parameters
scipThe SCIP instance in which the constraints should be added.
psdThe parent set data associated with this problem.
peddataThe pedigree data to use to construct the constraint.
Returns
SCIP_OKAY if the constraints were added successfully, or an appropriate error code otherwsie.

References PedigreeData::n, ParentSetData::nParents, ParentSetData::nParentSets, ParentSetData::ParentSets, ParentSetData::PaVars, PedigreeData::SexVars, and UT_createEmptyLTEConstraint().

Referenced by PD_addPedigreeConstraints().

Here is the call graph for this function:

◆ assignSexVariables()

static SCIP_RETCODE assignSexVariables ( SCIP *  scip,
SCIP_SOL *  sol,
ParentSetData psd,
SCIP_Bool *  possible 
)
static

Determines a possible assignment of the sex variables for a given primal solution.

If there is no possible assignment of sex variables (i.e. the primal is sexually inconsistent) then the function returns an appropriate error message.

Parameters
scipThe SCIP instance on which the heuristic is running.
solThe heuristic solution being worked on.
psdThe heursitic data related to this primal heursitic.
possibleWill be set to TRUE if an assignment was possible.
Returns
SCIP_OKAY if a consistent labelling could be found and was made to sol. An appropriate error code otherwise.

References MD_getPedigreeData(), PedigreeData::n, ParentSetData::nParents, ParentSetData::nParentSets, ParentSetData::ParentSets, ParentSetData::PaVars, and PedigreeData::SexVars.

Referenced by PD_assignPedigreeVariables().

Here is the call graph for this function:

◆ checkSuitableForPedigree()

static SCIP_Bool checkSuitableForPedigree ( SCIP *  scip,
ParentSetData psd 
)
static

Checks whether a SCIP problem is suitable for use as a pedigree.

A problem is acceptable as a pedigree if it has no parent sets of more than size 2.

Parameters
scipThe SCIP instance for which to check the data.
psdThe parent set data associated with this problem.
Returns
TRUE if this problem represents a valid pedigree problem, FALSE otherwise.

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

Referenced by PD_addPedigreeConstraints(), PD_addPedigreeVariables(), PD_assignPedigreeVariables(), and PD_printSolutionPedigreeFormat().

◆ PD_addPedigreeConstraints()

static SCIP_RETCODE PD_addPedigreeConstraints ( SCIP *  scip,
ParentSetData psd,
PedigreeData peddata 
)
static

Adds all appropriate pedigree based constraints to the problem.

Parameters
scipThe SCIP instance in which to add the constraints.
psdThe parent set data associated with this problem.
peddataThe pedigree data to use to construct the constraints.
Returns
SIP_OKAY if the constraints were added successfully, or an appropriate error code otherwise.

References addFullSiblingAgeGapConstraint(), addHalfSiblingAgeGapConstraint(), addMaximumNumberOfOffspringConstraint(), addMaximumSibsetSizeConstraint(), addSexConsistencyConstraint(), checkSuitableForPedigree(), PedigreeData::sexes, and usingSexConsistency().

Referenced by PD_addPedigreeSpecificConstraints().

Here is the call graph for this function:

◆ PD_addPedigreeParameters()

SCIP_RETCODE PD_addPedigreeParameters ( SCIP *  scip)

Makes SCIP recognise parameters related to pedigree reconstruction.

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

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

Referenced by BN_addParameters().

Here is the call graph for this function:

◆ PD_addPedigreeSpecificConstraints()

SCIP_RETCODE PD_addPedigreeSpecificConstraints ( SCIP *  scip,
ParentSetData psd 
)

Adds any constraints and variables needed for pedigree based constraints.

Parameters
scipThe SCIP instance in which to add the constraints.
psdThe parent set data associated with this problem.
Returns
SIP_OKAY if the constraints were added successfully, or an appropriate error code otherwise.

References PedigreeData::ages, MD_getPedigreeData(), MD_setPedigreeData(), PedigreeData::n, ParentSetData::n, PD_addPedigreeConstraints(), PD_addPedigreeVariables(), PE_deallocatePedigreeData(), PedigreeData::sexes, and PedigreeData::SexVars.

Referenced by addAdditionalConstraints().

Here is the call graph for this function:

◆ PD_addPedigreeVariables()

static SCIP_RETCODE PD_addPedigreeVariables ( SCIP *  scip,
ParentSetData psd,
PedigreeData peddata 
)
static

Creates any needed variables needed specifically for learning pedigrees.

Parameters
scipThe SCIP instance in which to create the variables.
psdThe parent set data associated with this problem.
peddataThe pedigree data to store the variables in.
Returns
SCIP_OKAY if the variable was successful, or an approriate error code otherwise.

References checkSuitableForPedigree(), PedigreeData::n, ParentSetData::nodeNames, PedigreeData::sexes, PedigreeData::SexVars, and usingSexConsistency().

Referenced by PD_addPedigreeSpecificConstraints().

Here is the call graph for this function:

◆ PD_assignPedigreeVariables()

SCIP_RETCODE PD_assignPedigreeVariables ( SCIP *  scip,
SCIP_SOL *  sol,
ParentSetData psd,
SCIP_Bool *  possible 
)

Tries to find values for any pedigree specific variables in a given primal solution.

If there is no possible assignment of pedigree variables then the function returns an appropriate error message.

Parameters
scipThe SCIP instance on which the heuristic is running.
solThe heuristic solution being worked on.
psdThe heursitic data related to this primal heursitic.
possibleReturns whether a valid assignment was possible.
Returns
SCIP_OKAY if a consistent labelling could be found and was made to sol. An appropriate error code otherwise.

References assignSexVariables(), checkSuitableForPedigree(), and usingSexConsistency().

Here is the call graph for this function:

◆ PD_getCurrentPedigreeVarValues()

SCIP_Bool* PD_getCurrentPedigreeVarValues ( SCIP *  scip)

Gets the values of the pedigree specific variables in the current solution.

If no pedigree specific variables are being used, NULL is returned.

Parameters
scipThe SCIP instance for which to find the variable values.
Returns
A list of SCIP_Bools which are TRUE for all variables included in the solution and FALSE otherwise.

References MD_getPedigreeData(), PedigreeData::n, PedigreeData::SexVars, and usingSexConsistency().

Referenced by printSolution().

Here is the call graph for this function:

◆ PD_inPedigreeMode()

SCIP_Bool PD_inPedigreeMode ( SCIP *  scip)

Determines whether the program is being run for learning pedigrees.

Parameters
scipThe SCIP instance that is running.
Returns
TRUE if the program is being used to learn pedigrees. FALSE otherwsie.

Referenced by addAdditionalConstraints(), printSolution(), and usingSexConsistency().

◆ PD_printSolutionPedigreeFormat()

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

Prints the solution as a pedigree.

The pedigree consists of four columns. The first is the individual, thes second is the sex of the individual, the third is its father and the fourth is its mother. If either the father or the mother is not present in the sample, a '-' is printed instead. If sex consistency is enforced, then individuals will not appear as father of one individual and mother of another. The pedigree is sorted such that all individuals are declared on a earlier line than those in which they appear as parents.

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.
pedvarsWhether 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 checkSuitableForPedigree(), MD_getPedigreeData(), PedigreeData::n, ParentSetData::nodeNames, ParentSetData::nParents, ParentSetData::nParentSets, ParentSetData::ParentSets, and usingSexConsistency().

Referenced by printToFile().

Here is the call graph for this function:

◆ usingSexConsistency()

static SCIP_Bool usingSexConsistency ( SCIP *  scip)
static

Checks whether the program is enforcing sex consistency.

If the deprecated version of rhe sex consistency parameter is being used then a message will warn the user of this.

Parameters
scipThe SCIP instance of which to check the status.
Returns
TRUE if the program should enforcing sex consistency. FALSE otherwise.

References PD_inPedigreeMode().

Referenced by PD_addPedigreeConstraints(), PD_addPedigreeVariables(), PD_assignPedigreeVariables(), PD_getCurrentPedigreeVarValues(), and PD_printSolutionPedigreeFormat().

Here is the call graph for this function: