高斯舍入的割模逼近及正交约束优化
cutnorm的Python项目详细描述
用高斯四舍五入逼近和正交约束优化
此包利用Alon和Noar [ALON2004]和Win和Yu^ {A2}的快速优化算法中的一些技术来计算矩阵的CuthFoad逼近。
示例用法
给定两个简单图A和B的邻接矩阵,我们希望计算两个图之间的差分矩阵(A-B)的范数。与l1范数相比,使用割范数的一个明显优点是考虑Erdos-Renyi random graphs上范数的值。
给定两个常数n和p=0.5的erdos-renyi随机图,其差(归一化后)的编辑距离(l1范数)为0.5,概率较大。l1范数为1表示两个矩阵完全不同,0表示恒等式,0.5介于两者之间。然而,这两个图具有相同的全局结构。当n接近无穷大时,a和b收敛到同一个graphon对象,该对象在任何地方都是0.5。从lovasz[LOVASZ2009]所讨论的全局结构相似性的角度来看,编辑距离不能作为两个图之间的“距离”的概念。割范数是反映全局结构相似性的距离度量。事实上,这个例子中的差分割范数随着n的增长接近于0。
下面是使用cutnorm包和工具的示例。
importnumpyasnpfromcutnormimportcompute_cutnorm,tools# Generate Erdos Renyi Random Graph (Simple/Undirected)n=100p=0.5erdos_renyi_a=tools.sbm.erdos_renyi(n,p,symmetric=True)erdos_renyi_b=tools.sbm.erdos_renyi(n,p,symmetric=True)# Compute l1 normnormalized_diff=(erdos_renyi_a-erdos_renyi_b)/n**2l1=np.linalg.norm(normalized_diff.flatten(),ord=1)# Compute cutnormcutn_round,cutn_sdp,info=compute_cutnorm(erdos_renyi_a,erdos_renyi_b)print("l1 norm: ",l1)# prints l1 norm value near ~0.5print("cutnorm rounded: ",cutn_round)# prints cutnorm rounded solution near ~0print("cutnorm sdp: ",cutn_sdp)# prints cutnorm sdp solution near ~0
[ALON2004] | Noga Alon and Assaf Naor. 2004. Approximating the cut-norm via Grothendieck’s inequality. In Proceedings of the thirty-sixth annual ACM symposium on Theory of computing (STOC ‘04). ACM, New York, NY, USA, 72-80. DOI: http://dx.doi.org/10.1145/1007352.1007371 |
[WEN2013] | Zaiwen Wen and Wotao Yin. 2013. A feasible method for optimization with orthogonality constraints. Math. Program. 142, 1-2 (December 2013), 397-434. DOI: https://doi.org/10.1007/s10107-012-0584-1 |
[LOVASZ2009] | Lovasz, L. 2009. Very large graphs. ArXiv:0902.0132 [Math]. Retrieved from http://arxiv.org/abs/0902.0132 |