⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recomputegains.cc

📁 贝叶斯优化算法是一种新的演化算法
💻 CC
字号:
// ################################################################################
//
// name:          recomputeGains.cc
//
// author:        Martin Pelikan
//
// purpose:       a function calling the metric repeatedly in order to recompute
//                the gains for all edge additions ending in a particular node
//
// last modified: February 1999
//
// ################################################################################

#include "recomputeGains.h"
#include "boa.h"
#include "graph.h"
#include "population.h"
#include "memalloc.h"
#include "K2.h"

// ================================================================================
//
// name:          recomputeGains
//
// function:      recomputes gains for all edge additions ending in a particular
//                node by calling the corresponding metric functions with the
//                required set of parameters
//
// parameters:    i............the ending node of all the edges for which the gain
//                             is to be updated
//                gain.........the matrix of gains for all edge additions where to
//                             update the newly computed gains
//                full.........the array with information on whether each node is
//                             already filled up (no more edges can be added ending
//                             in the node)
//                G............the network to which the edges are to be added
//                population...the population of promising solutions (the modeled
//                             data set)
//
// returns:       (int) 0
//
// ================================================================================

int recomputeGains(int i, float **gain, char *full, AcyclicOrientedGraph *G, Population *population)
{
  int parentCount;
  int *parentList;
  int numUpdated;
  int *updateIdx;
  int n,k;

  // initialize the variables

  n = population->n;

  // if the node i is full then no edges can be added

  if (full[i])
    {
      for (k=0; k<n; k++)
	gain[k][i]=-1;
    }
  else
    {

      // initialize the variables
      
      parentCount = G->getNumIn(i);
      
      // allocate memory for the index of nodes from which the edge is to be updated
      
      updateIdx = (int*) Calloc(n-parentCount,sizeof(int));
      
      // create the index of those nodes
      
      numUpdated = 0;
      
      for (k=0; k<n; k++)
	if ((!G->connected(k,i))&&
	    (G->canAddEdge(k,i)))
	  updateIdx[numUpdated++] = k;
	else
	  gain[k][i]=-1;
      
      // initialize the parent list

      parentList = G->getParentList(i);
  
      // compute the gains for edges from all updateIdx to i

      computeLogGains(i,gain,updateIdx,numUpdated,parentList,parentCount,population);
	
      // free memory used by list of beginning nodes of the edges to be updated

      Free(updateIdx);
    };

  // get back

  return 0;
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -