Nilsson's sequence score算法解决八数码问题解释

解决了最近一个人工智能关于解决八数码难题的作业。

图可能看不清,除了黑块外其他位置是英文字母ABCDEFGH

A*:f(n)=g(n)+h(n)

其中f为总花费,g为已知花费(深度),h为估计花费

 

关于Nilsson sequence score这个估计花费算法(也就是计算h的,估计函数)

Nilsson's sequence score 

A tile in the center scores 1 (since it should be empty)

For each tile not in the center, if the tile clockwise to it is not the one that should be clockwise to it then score 2.

Multiply this sequence by three and finally add the total distance you need to move each tile back to its correct position.

 

公式:h(n)=P(n)+3S(n)

P(n)是每一个滑块距离正确位置的曼哈顿(Manhattan)距离之和,即P(n)所得分数;

曼哈顿距离P=水平位移+垂直位移

S(n):对于当前状态(块的分布)而言,如果中心的块非空,则得1分(对于八数码问题,目标状态的中心块是空的);然后轮流检查除了中心块之外的每一个块,如果该块的后继结点是错误的后继结点,得2分。其余块不得分;

把P(n)的分数与S(n)的分数的三倍相加即为Nilsson sequence score

 

举一个例子

初始状态I
*AC           

HBD           

GFE

目标状态T

ABC

H*D

GFE

开始计算

1.计算曼哈顿距离

从初始状态看,

对于A,从I(A)移到T(A)需要一步(向左移一步),得1分;

对于C,D,E,F,G,H位置一致,不得分;

对于B,需要向上移一步,得1分;

P(n)总共得分为1+1=2分。

2.计算S

①B位于中心块,得1分;

②将其他块按顺时针顺序排好:

I:*ACDEFGBH

T:ABCDEFGH

使[当前点,后继点]组成如下数对

目标状态的数对:[A,B], [B,C], [C,D], [D,E], [E,F], [F,G], [G,H], [H,A]

当前状态的数对:[A,C], [C,D], [D,E], [E,F], [F,G], [G,H], [H,*]

([*,A] 不考虑,因为不存在*这样的前继)

其中有2对是当前点相同,后继点不同的:[A,C], [H,*]    因此 2*2=4分;

再把S乘以3:3*(1+2*2)=15分;

总得分h=P+3S=2+15=17分

再通过求所有情况的每一步的总花费f=g+h就可以重新对open表排序来进行选择最优策略了。

 

附上自己对求单步h值的Python脚本

#h(n)=P(n)+3S(n)
Current=[0,1,3,
         8,2,4,
         7,6,5]
Target=[1,2,3,
        8,0,4,
        7,6,5]
#顺时针排序
closewise=[0,1,2,5,8,7,6,4,0]
#左下角代表坐标原点(0,0)
Coordinate=[13,23,33,
            12,22,32,
            11,21,31]
p=0
s=0
h=0
#ManhattanDistance
for i in range(9):
    for j in range(9):
        if Current[i]==Target[j] and Current[i]!=0:
            x1 = int(Coordinate[i] / 10) - 1
            y1 = int(Coordinate[i] % 10) - 1
            x2 = int(Coordinate[j] / 10) - 1
            y2 = int(Coordinate[j] % 10) - 1
            p+=abs(x1-x2)+abs(y1-y2)

#A tile in the center scores 1 (since it should be empty)
if Current[4]:
    s+=1

#For each tile not in the center,
# if the tile clockwise to it is not the one that
# should be clockwise to it then score 2.
for i in range(8):
    for j in range(8):
        if Current[closewise[i]]!=0:
            if Target[closewise[i]]==Current[closewise[j]] and Target[closewise[i+1]]!=Current[closewise[j+1]]:
                s+=2
h=p+3*s
print(h,p,3*s)

 

 

以上是我自己理解的,要是没讲清楚的话大家最好直接去看看这些解释(全英

http://www.cs.rpi.edu/academics/courses/fall00/ai/assignments/assign3heuristics.html

http://heyes-jones.com/astar.php

https://cs.stackexchange.com/questions/1904/nilssons-sequence-score-for-8-puzzle-problem-in-a-algorithm/1910#1910

 

 

 

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
室内定位算法,有助于研究者认清研究方向,给定位算法一个准确的描述,是很好的参考教材。the possibility for the user to be notified by visible and Waveformof Distance audible warnings using buzzer and led ar to Very close to al 1903 Tme「 samples Fig 4 Distance measurement using the RSSi signal The system is used to determine the distance between Fig. 2. Tag4M Data Acquisition System tags and 2, 3, 4 or more APs. The tag scans after the aps ⅣV. EXPERIMENTS and sends the rssi values for each ap to the ap which is associated The system presented above can be used for objects or In order to read the corresponding rSsi values of all people localization in an indoor enviro found access points, a""operation is implemented at Let's suppose a building where several objects are Tag4M level. The time to scan is smaller than few distributed all over milliseconds, because the tag doesnt associate with the all For a better understanding of the system, it is showed an APs. These values are sent to a pC where the localization experiment where the objects are placed only at one floor. algorithm is implemented in LabVIFW20 10 (see Fig. 5) Each of these objects has attached a tag. The devices are Table I presents a scan operation result. In this case used to determine the location of the objects in the four APs(which are placed in the floor building)named building and the distance between tags and APs. To Hawk, Helicopter, Tag4M and WitagServer are detected measure the distance, the RSSI is processed. This method The corresponding rSSi values(in dBm) measured by the is not very accurate and is strong depended to the Tag4M are reported for every AP environment, but is very easy to implement with the TABLE 1. A SEQUENCE OF RESULTS FOR THE SCANOPERATION The Fig 3 presents the experiment environment for one EXFCUTED ON THE TAG4M DEVICE oor where the colored circles represents the APs and the rectangles represents the objects intended to be located This floor is divided in six rooms separated by walls RSSI Scan results: 4 Time Ssid Ch ad-Iloc Sec wps mac Address erp WMM SSI Supported Rates(Mbits, Mandatory) Crypto Suites CW Max/min AP SCAN. llawk. -57 dBm AP SCAN, Helicopter, -50 dBm, AP SCAN, Tag4M.-68 dBm AP SCAN. WitagServer. -45 dBm The Rssi values are converted to distance values using formula(1) The value of the received signal strength is a function of the transmitted power and the distance between the Fig 3. The Experiment Environment sender and the receiver. The received signal strength will decrease when the distance increases as the following First step in finding the location is distance equation shows [23] measurement using the RSSI signal. The experiment for computing the distance is presented in Fig. 4. The RSSI(IOn- logo+A)(1) experimental precisions of measurements are less than 5 meters Where: lal propagation constant al d propagation exponent. d represents the distance from sender, A represents the received signal strength at a distance of one meter worn even by people. The system runs on batterie w sSID having a characteristic life time of a couple of years and 回H offers a platform for sensor measurements. Thus, the system can use any existent infrastructure, with significant decrease of implementation costs REFERENCES [1] H. Liu, H. Darabi, P. Banerjee and J. Liu, ""Survey of wireless Distance 2 Tn] aRch Indoor Positioning Techniques and SystemS", IEEE TRANSACTIONS ON SYSTEMS. MAN. AND CYBERNETICS-PART C: APPLICATIONS AND REVIEWS VOL 37, NO 6, NOVEMBER 2007, pp. 1067-10801 Distance 3[] [2 Want, A. Hopper, V. FalcaO, J. Gibbons, "The Active Budge 4MDastDct v Location System, ACM Transactions on Information Systems vol. 10, no l, January 1992, pp 91-102. Fig. 5. Block Diagram of the localization program [3] Firefly Motion Tracking System User's guide", vcrsion 2.2 December 1999 http://www.gesturecentral.com/firefly/fireflyuserguide.pdf The application compute the distances between the Wi- [4] Northen Digilal Inc. Website, Oplotrak PROseries, 2011 Fi Tags placed on targets and the APs placed in indoor http:/www.ndigital.com/industrial/optotrakproseries-family.php [5] E. Aitenbichler, M. Mhlhuser, An /R Local Positioning System for environment. For this case, three APs are enough but the Smart Items and Devices Proc. 23rd IEEE Internationa number of Aps can be increased for obtaining more Conference on Distributed Computing Systems Workshops accurate position estimation. The distances between the TWSAWC03), 2003 Wi-fiTagsandeachAparerepresentedascirclesasit[6]topaz,2004,http:/www.tadlys.co.il/pAges/productcontent.asp?igi bald=2 can be seen in Fig. 6, having the centre in the AP locations [7 A. Kotanen, M. Hannikainen, H. Leppakoski, and T. D which have previously known coordinates. The target's Hamalaincn, E.cperiments on local positioning with Bluetoothin position is given by the point at the intersection of the Proc. IEEE Int Conf. Inf. Technol. Comput. Commun., Apr 2003 three circles PP.297-303 [8 J. Hallberg, M. Nilsson, and k. Synnes, "Positioning with Bluetooth"in Proc. Ieee 10th Int Conf. Telecommun. Mar. 2003 ol.2,pp.954958 9 Active bat website. 2008 http:/www.cl.cam.ac.uk/research!dtg/attarchive/bat/ [10] Hazas, M, Hopper, A, "A Novel Brucdbund Ultrasonic Locution System for Improved Indoor Positioning IEEE Transactions on mobile Computing. Vol 5, No 5, May 2006 [11 N B Priyantha, The Cricket Indoor Location System", PhD thes MIT.2005 2]SonitorSystemWebsite2011,http://www.sonitor.com/ [13] Minami M, Fukuju Y, Hirasawa K, Yokoyama S, Mizumachi M Aoyama T ,"Dolphin. A practical approach for implementing a fully distributed indoor ultrasonic positioning system", Ubicomp, 2004, 347-365 Fig. 6. Front Panel of the localization program 14]J. Ilightower, R. Want, and G. borriello, SpotON: An indoor 3D cation sensing technology hased on RF signal strength"Univ The simplicity and cost efficiency of the rssi based Washington, Seattle, Tech Rep UW CSE 2000-02-02, Feb. 2000 localization make the proposed system a desired candidate 15]L. M. Ni, Y. Liu, Y. C. Lau, and A. P. Patil,"LANDMARC: Indoor location sensing using active RFID Wireless Netw., vol 10, no 6 for specific applications like tracking and positioning svstems hP.701-70.N0v.200 Zebra Technologies Corporation eb sit http://www.7ebra.com/id/zebra/na/en/index/products/location/isoie c 24730 2html V. CONCLUSION [17 P. Bahl and V. Padmanabhan, "RADAR: An in-building rf based user location and tracking system, Proc. IEEE INFOCOM, voL 2 In this paper, an indoor localization system based on March200,pp.775784 ultra-low power Wi-Fi technology and designed to 18Ekahau2011,http://www.ekahau.com: [19] T. King, S. Kopf, T. Haenselmann, C. Lubberger and w determine location of objects in a closed environment is Effelsberg, "COMPASS: A Probabilistic Indoor Positioning System proposed gILo rOC In the first part of this paper a survey of existing indoor Workshop on Wireless Network Testbeds, Experimental evaluation and Cllaracterization (WiNTECID), Los Angeles, CA, USA positioning systems was made In the second part was presented the way in which an [20] Convert sensor data to web pages using a Cloud Instrument, june object can be localized by using access points and Tag 4M 2011.http://www.tag4m.com devices which may read the rssi values [21Tag4mDatasheet2010,http://test.tag4m.com/wp- content/uploads/20/03/Tag4M Prod Datasheet Revised3. pdf The importance of the proposed system lies in ultra-low [22] Aamodt, K.(2006). CC2431 Location Engine, Application Note power and Wi-Fi transmission capabilities that are An042,fromhttp://focus.tii.co.ip/ip/lit/an/swra095/swra095.pdf embedded in a very small package, why they are suitable 320

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值