GOBNILP  f164d83
Functions
model_averaging.c File Reference

Implements the functions needed to perform model averaging over the n best Bayesian networks. More...

#include "model_averaging.h"
#include "parent_set_data.h"
Include dependency graph for model_averaging.c:

Functions

static int indexOf (MA_info *ma_info, SCIP_VAR *var)
 Find the index of ma_info->vars and ma_info->average_scores relating to a variable. More...
 
SCIP_RETCODE MA_addAveragingParameters (SCIP *scip, MA_info *ma_info)
 Adds parameters for controlling the model averaging. More...
 
SCIP_RETCODE MA_createAverageDataStructure (SCIP *scip, MA_info *ma_info)
 Allocates memory for the data structures used for model averaging. More...
 
SCIP_RETCODE MA_destroyAverageDataStructure (SCIP *scip, MA_info *ma_info)
 Frees memory used for the data structures used for model averaging. More...
 
SCIP_Real MA_getAverageValue (MA_info *ma_info, SCIP_VAR *variable)
 Returns the model average value of a given variable. More...
 
SCIP_Real MA_getTotalAveragesScore (MA_info *ma_info)
 Returns the total likelihood of all the solutions included in the model average. More...
 
SCIP_Real MA_getTotalAveragesTime (MA_info *ma_info)
 Returns the total time spent solving for all the solutions included in the model average. More...
 
SCIP_RETCODE MA_updateAverageDataStructure (SCIP *scip, MA_info *ma_info, SCIP_SOL *sol)
 Updates the average scores based on a newly found solution. More...
 

Detailed Description

Implements the functions needed to perform model averaging over the n best Bayesian networks.

Function Documentation

◆ indexOf()

static int indexOf ( MA_info ma_info,
SCIP_VAR *  var 
)
static

Find the index of ma_info->vars and ma_info->average_scores relating to a variable.

Parameters
varThe variable of interest.
ma_infoModel averaging information.
Returns
The index of the var in ma_info->vars. If the variable is not included in the averaging, -1 is returned.

References MA_info::num_vars, and MA_info::vars.

Referenced by MA_getAverageValue().

◆ MA_addAveragingParameters()

SCIP_RETCODE MA_addAveragingParameters ( SCIP *  scip,
MA_info ma_info 
)

Adds parameters for controlling the model averaging.

Parameters
scipThe SCIP instance to which the parameter is to be added.
ma_infoModel averaging information.
Returns
SCIP_OKAY if the parameters were added successfully or an error code otherwise.

References MA_info::is_log_score.

Referenced by main().

◆ MA_createAverageDataStructure()

SCIP_RETCODE MA_createAverageDataStructure ( SCIP *  scip,
MA_info ma_info 
)

Allocates memory for the data structures used for model averaging.

Parameters
scipThe SCIP instance on which the model averaging will be performed.
ma_infoModel averaging information.
Returns
SCIP_OKAY if memory allocation was successful or an appropriate error message otherwise.

References MA_info::average_scores, MA_info::first_score, MA_info::is_first_score, MA_info::normalising_constant, MA_info::num_vars, MA_info::total_score, MA_info::total_time, and MA_info::vars.

Referenced by main().

◆ MA_destroyAverageDataStructure()

SCIP_RETCODE MA_destroyAverageDataStructure ( SCIP *  scip,
MA_info ma_info 
)

Frees memory used for the data structures used for model averaging.

Parameters
scipThe SCIP instance on which the model averaging was performed.
ma_infoModel averaging information.
Returns
SCIP_OKAY if memory deallocation was successful or an appropriate error message otherwise.

References MA_info::average_scores, and MA_info::vars.

Referenced by main().

◆ MA_getAverageValue()

SCIP_Real MA_getAverageValue ( MA_info ma_info,
SCIP_VAR *  variable 
)

Returns the model average value of a given variable.

If the variable is not part of this model averaging, the value -1 will be returned.

Parameters
ma_infoModel averaging information.
variableThe variable to get the model averaging score for.
Returns
The model average score of the variable.

References MA_info::average_scores, indexOf(), MA_info::is_log_score, MA_info::normalising_constant, and MA_info::total_score.

Referenced by printAverages().

Here is the call graph for this function:

◆ MA_getTotalAveragesScore()

SCIP_Real MA_getTotalAveragesScore ( MA_info ma_info)

Returns the total likelihood of all the solutions included in the model average.

Parameters
ma_infoModel averaging information.
Returns
The sum of the likelihoods of each of the solutions included.

References MA_info::total_score.

Referenced by printAverages().

◆ MA_getTotalAveragesTime()

SCIP_Real MA_getTotalAveragesTime ( MA_info ma_info)

Returns the total time spent solving for all the solutions included in the model average.

Parameters
ma_infoModel averaging information.
Returns
The number of seconds spend on solving all of the solutions that have been used to make up the average.

References MA_info::total_time.

Referenced by printAverages().

◆ MA_updateAverageDataStructure()

SCIP_RETCODE MA_updateAverageDataStructure ( SCIP *  scip,
MA_info ma_info,
SCIP_SOL *  sol 
)

Updates the average scores based on a newly found solution.

Parameters
scipThe SCIP instance to which the solution belongs.
ma_infoModel averaging information.
solThe new solution to incorporate in to the averages.
Returns
SCIP_OKAY if the operation succeeded or an appropriate error message otherwise.

References MA_info::average_scores, MA_info::first_score, MA_info::is_first_score, MA_info::is_log_score, MA_info::normalising_constant, MA_info::num_vars, MA_info::total_score, MA_info::total_time, and MA_info::vars.

Referenced by main().