高斯舍入的割模逼近及正交约束优化

cutnorm的Python项目详细描述


用高斯四舍五入逼近和正交约束优化

此包利用Alon和Noar [ALON2004]和Win和Yu^ {A2}的快速优化算法中的一些技术来计算矩阵的CuthFoad逼近。

阅读documentation

安装

使用pip安装包。 从终端安装,如下所示:

$ pip install cutnorm

示例用法

给定两个简单图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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java Square类   java Android RecyclerView内部视图寻呼机   java类变量:公共访问只读,但私有访问r/w   java不兼容ClassChangeError java8   安卓java on on参数,如参数iNIT.C++C++   java如何在下面的代码中根据我的喜好设置JTextArea和JTextField的大小?   java使用CustomAdapter更改ListView的显示方式   jakarta ee什么是Java Servlet?   传递给Javasocket程序的参数   java为什么我的计划任务在这两者之间有很长的延迟   Java“迭代器”关键字   java获取数据库SQLite Android中插入行的行ID   网络如何在Java应用程序中设置H2嵌入式数据库,以便在小型网络中使用?   数组Java:写出所有包含K1的Nbit序列   java返回随机字符串键的整数值   在java中解析到日期的字符串时保留时区   java如何修复“运行配置错误:[在SDK中找不到Rails]”?   Java包装器OutofMemory