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

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第三方库


热门话题
JavaSpringbean已创建但未自动连接   java LibGDX游戏在三星Galaxy Grand Prime上结束   如何在Java中列出字符串句子中所有匹配条件的单词   java在Recyclerview中使用“putExtra”传递数据   java从一个特定的数组中提取特定的JSON对象,以便在Android中通过一个意图放入另一个活动   java需要使用IntelliJ和设置项目SDK的帮助   java springcontextindexer和Swagger 3   java使用indexOf和substring计算数字   java使用xml解析在word文档中查找隐式分页符   在添加<context:componentscan basepackage=“com.young.user”/   java无条件更改JTable单元格的背景色   选择列表中的java调用oracle函数:节点无数据类型   java如何添加缓冲图像作为JFrame的背景,然后在此图像上添加面板?   java Javadoc找不到用scala编写的类   java连接到文件共享程序的IP地址   java将数组元素加载到集合中   Tomcat中的java servlet、过滤器和线程   非Bean对象中的java EJB CDI注入?   java与println和printf的不同舍入