Optimize the cluster assignments for the k'th cluster.
387 for (
int l = 0; l <
K; l++) {
391 TFlt d = (
CHat[l].IsKey(Src) &&
CHat[l].IsKey(Dst)) ? 1 : -1;
399 CostNotInclude = -Other + InnerProduct + log(1 + exp(Other - InnerProduct));
400 CostInclude = -Other - InnerProduct + log(1 + exp(Other + InnerProduct));
402 CostNotInclude = log(1 + exp(Other - InnerProduct));
403 CostInclude = log(1 + exp(Other + InnerProduct));
406 CostNotIncludeHash.
AddDat(kv) = -CostNotInclude;
407 CostIncludeHash.
AddDat(kv) = -CostInclude;
411 TFlt InitialTemperature = 1.0;
412 for (
int r = 2; r < MCMCReps + 2; r++) {
413 TFlt Temperature = InitialTemperature / log((
double) r);
422 if (ed.Val1 > ed.Val2) {
423 ed =
TIntPr(ed.Val2, ed.Val1);
427 if (NewLabel[np] == 0) {
432 l1 += CostIncludeHash.
GetDat(kv);
435 TFlt LogLikelihoodDiff = exp(l1 - l0);
436 TFlt AcceptProb = pow(LogLikelihoodDiff, 1.0 / Temperature);
TPair< TInt, TInt > TIntPr
TSizeTy Len() const
Returns the number of elements in the vector.
const TDat & GetDat(const TKey &Key) const
THash< TIntPr, TIntIntH > EdgeFeatures
int AddKey(const TKey &Key)
TFlt Inner(TIntIntH &Feature, TFlt *Parameter)
Inner product for sparse features.
bool IsEdge(const int &SrcNId, const int &DstNId) const
Tests whether an edge between node IDs SrcNId and DstNId exists in the graph.
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
TDat & AddDat(const TKey &Key)
PGraphAttributes GraphAttributes