[zz]tagged structure initialization

Posted on Nov 25, 2010 10:42:56 PM


直接贴网址:http://stackoverflow.com/questions/3016107/what-is-tagged-structure-initialization-syntax/3017026#3017026

Read more

一些命令

Posted on Nov 13, 2010 06:37:20 AM

真正使用Linux的时间不错,一些命令总是会忘记还想不起来去哪找,做个笔记好了,持续更新…

Read more

Linux硬连接

Posted on Nov 12, 2010 04:29:08 AM

连接分为两种形式:一种是类似于Windows中的快捷方式,一个文件名指向另外一个文件名;一种就是硬连接(也叫实际连接),是两个文件名同时连接到一个实际文件。

一般情况下使用硬连接创建连接文件时,磁盘空间与inode数量都不会变。因为硬连接只是在某个目录的block下添加一个关联数据而已,而一般情况下硬连接占用的数据量很小,所以不会消耗block数量。

Read more

Testing

Posted on Nov 11, 2010 10:02:54 AM

Tesing

 

def aStarSearch(problem, heuristic=nullHeuristic):
  "Search the node that has the lowest combined cost and heuristic first."
  "*** YOUR CODE HERE ***"
  
  closedset = []
  start = problem.getStartState()
  openset = util.PriorityQueue()
  g_score = {}
  h_score = {}
  f_score = {}
  g_score[start] = 0
  h_score[start] = heuristic(start, problem)
  f_score[start] = h_score[start]
  openset.push( start, f_score[start])
  action = []
  came_from = {}
  came_from_action = {}
  while not openset.isEmpty():
	x = openset.pop()
	print x
	if problem.isGoalState(x):
		break
	closedset.append(x)
	for y in problem.getSuccessors(x):
		if y[0] in closedset:
			continue
		tentative_g_score = g_score[x] + 1
		g_score[y[0]] = g_score[x] + 1
		h_score[y[0]] = heuristic(y[0], problem)
		f_score[y[0]] = g_score[y[0]] + h_score[y[0]]
		
		if not openset.isHas(y[0]):
			openset.push(y[0], f_score[y[0]])
			tentative_is_better = True
		elif (tentative_g_score < g_score[y[0]]):
			tentative_is_better = True
		else:
			tentative_is_better = False
		
		if tentative_is_better == True:
			came_from[y[0]] = x
			came_from_action[y[0]] = y[1]
			g_score[y[0]] = tentative_g_score
			h_score[y[0]] = heuristic(y[0],problem)
			f_score[y[0]] = g_score[y[0]] + h_score[y[0]]
	
  v = x
  while v != start:
	action.append(came_from_action[v])
	v = came_from[v]
  
  action.reverse()
  return action
  
  util.raiseNotDefined()