本文整理汇总了Python中error.Error.resetLast方法的典型用法代码示例。如果您正苦于以下问题:Python Error.resetLast方法的具体用法?Python Error.resetLast怎么用?Python Error.resetLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类error.Error
的用法示例。
在下文中一共展示了Error.resetLast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Lgreedy
# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import resetLast [as 别名]
def Lgreedy(G, M, errorEnc, time, struc, totalCostOld, Eold, model_cost_struct):
toKeep = 'true';
old_numUnmodelledErrors = Eold.numUnmodelledErrors;
if time == 1:
E = Error(G); # initially, everything is error, nothing is covered
#E.saveOld();
# the cost for encoding each structure (to avoid recomputing it for the greedy updates)
model_cost2 = 0;
else :
E = Eold; #Error(G, Eold);
# clear the temp vars that keep the diff in the Error by adding the new structure
E.resetLast();
#E.deepish_copy(Eold);
#E = copy.deepcopy(Eold);
#E = Eold;
# the cost for encoding each structure separately
# Just update the up-to-now cost by adding the cost of the new structure
model_cost2 = model_cost_struct;
error_cost = 0;
repeatedEdges = 0;
repeatedErrors = 0;
model_cost = LN(M.numStructs+1); # encode number of structures we're encoding with
model_cost += LwC(M.numStructs, M.numStrucTypes); # encode the number per structure
# encode the structure-type identifier per type
if M.numFullCliques > 0 :
model_cost += M.numFullCliques * log(M.numFullCliques / float(M.numStructs), 2);
if M.numNearCliques > 0 :
model_cost += M.numNearCliques * log(M.numNearCliques / float(M.numStructs), 2);
if M.numChains > 0 :
model_cost += M.numChains * log(M.numChains / float(M.numStructs), 2);
if M.numStars > 0 :
model_cost += M.numStars * log(M.numStars / float(M.numStructs), 2);
# off-diagonals
if M.numFullOffDiagonals > 0 :
model_cost += M.numFullOffDiagonals * log(M.numFullOffDiagonals / float(M.numStructs), 2);
if M.numNearOffDiagonals > 0 :
model_cost += M.numNearOffDiagonals * log(M.numNearOffDiagonals / float(M.numStructs), 2);
# bipartite-cores
if M.numBiPartiteCores > 0 :
model_cost += M.numBiPartiteCores * log(M.numBiPartiteCores / float(M.numStructs), 2);
if M.numNearBiPartiteCores > 0 :
model_cost += M.numNearBiPartiteCores * log(M.numNearBiPartiteCores / float(M.numStructs), 2);
if M.numJellyFishes > 0 :
model_cost += M.numJellyFishes * log(M.numJellyFishes / float(M.numStructs), 2);
if M.numCorePeripheries > 0 :
model_cost += M.numCorePeripheries * log(M.numCorePeripheries / float(M.numStructs), 2);
# encode the structures
if struc.isFullClique() :
(cost,repeatedEdges,repeatedErrors) = LfullClique(struc,M,G,E);
model_cost2 += cost;
elif struc.isNearClique() :
(cost,repeatedEdges,repeatedErrors) = LnearClique(struc,M,G,E);
model_cost2 += cost;
elif struc.isChain() :
(cost,repeatedEdges,repeatedErrors) = Lchain(struc,M,G,E);
model_cost2 += cost;
elif struc.isStar() :
(cost,repeatedEdges,repeatedErrors) = Lstar(struc,M,G,E);
model_cost2 += cost;
elif struc.isCorePeriphery() :
(cost,repeatedEdges,repeatedErrors) = LcorePeriphery(struc,M,G,E);
model_cost2 += cost;
elif struc.isJellyFish() :
(cost,repeatedEdges,repeatedErrors) = LjellyFish(struc,M,G,E);
model_cost2 += cost;
elif struc.isBiPartiteCore() :
(cost,repeatedEdges,repeatedErrors) = LbiPartiteCore(struc,M,G,E);
model_cost2 += cost;
elif struc.isNearBiPartiteCore() :
(cost,repeatedEdges,repeatedErrors) = LnearBiPartiteCore(struc,M,G,E);
model_cost2 += cost;
elif struc.isFullOffDiagonal() :
(cost,repeatedEdges,repeatedErrors) = LfullOffDiagonal(struc,M,G,E);
model_cost2 += cost;
elif struc.isNearOffDiagonal() :
(cost,repeatedEdges,repeatedErrors) = LnearOffDiagonal(struc,M,G,E);
model_cost2 += cost;
#print ">>>> repeated_errors = %.0f,\trepeated_edges = %.0f\tcovered = %.0f\tnewly_covered = %.0f" % (repeatedErrors,repeatedEdges,G.numEdges - E.numUnmodelledErrors, old_numUnmodelledErrors - E.numUnmodelledErrors);
#print ">?>? previously_covered = %.0f,\tnow_covered = %.0f" %(G.numEdges - old_numUnmodelledErrors, G.numEdges - E.numUnmodelledErrors);
# encode the error
error_cost += 0 if E.numCellsCovered == 0 else log(E.numCellsCovered, 2); # encode number of additive Errors
if ((G.numNodes * G.numNodes - G.numNodes) / 2) - E.numCellsCovered > 0 :
error_cost += log(((G.numNodes * G.numNodes - G.numNodes) / 2) - E.numCellsCovered, 2); # encode number of Errors
if errorEnc == "NP" :
error_cost += LErrorNaivePrefix(G,M,E);
elif errorEnc == "NB" :
error_cost += LErrorNaiveBinom(G,M,E);
elif errorEnc == "TP" :
error_cost += LErrorTypedPrefix(G,M,E);
elif errorEnc == "TB" :
error_cost += LErrorTypedBinom(G,M,E);
#.........这里部分代码省略.........