蚁群系统的数据库,以计算多个点之间的距离 [英] database for ant colony system to calculate distance between several points
本文介绍了蚁群系统的数据库,以计算多个点之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个问题,如何创建一个可以计算蚁群系统几个点之间(x坐标,y坐标)的距离的数据库.
示例:点A(3,5)和点B(4,8)
如何计算距离以及如何在数据库中应用此距离.
感谢您的帮助:D
i have a problem how to create a database that can calculate distance between several points(in (x,y) coordinate) for Ant Colony System..
example: point A(3,5) and point B(4,8)
how to calculate the distance and how to apply this in database..
thank''s for help :D
推荐答案
您的问题不清楚.您要寻找什么样的距离,例如,如果点a和b之间的简单距离说3和5之间的距离是2、4和8之间的距离是4,我会建议您使用一个表格来存储坐标x和y并在您的业务逻辑中计算距离.不要在数据库中存储任何多余/不需要的信息.
[更新]
获取两个坐标之间的距离的公式如下
sqrt((x1-x2)^ 2 +(y1-y2)^ 2)如果我替换x1,x2,y1,y2的值,它将看起来像
sqrt((3-4)^ 2 +(5-8)^ 2)
现在您可以将所有的点存储在具有四列的表中,然后从数据库中获取点并在运行时计算距离.
[/Update]
Your question is not clear. What kind of distance you are looking for.If a simple distance between point a and b for example say distance between 3 and 5 is 2 and 4 and 8 is 4 the i''ll suggest you to have a table where you can store coordinate x and y and the calculate the distance in your business logic. Do not store any extra/unneeded information in database.
[Update]
Formula to get distance between two coordinate is as follow
sqrt((x1 - x2)^2 + (y1 - y2)^2) if i replace the values of x1,x2,y1,y2 it will look like
sqrt((3-4)^2 + (5-8)^2)
Now you can store all then point in a table with four column.And fetch the points from database and calculate the distance during run-time.
[/Update]
这篇关于蚁群系统的数据库,以计算多个点之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文