• API
• FAQ
• Tools
• Archive
daily pastebin goal
72%
SHARE
TWEET

# Untitled

a guest Jan 19th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. def search(problem, heuristic, usegN, astar):
2.     """Multifunctional Algorithm"""
3.     fringe = util.PriorityQueue()
4.     generated = {}
5.     n = node.Node(problem.getStartState())
6.     fringe.push(n, 0)#el cost=0 ja que es el node inicial
7.     generated[n.state] = ['F', n]
8.
9.     while True:
10.         #TEST OBJETIVO
11.         if fringe.isEmpty():
12.             print "No Solution"
13.             sys.exit(-1)
14.         n = fringe.pop()
15.         if problem.isGoalState(n.state):
16.             return n.path()
17.             print "Solution"
18.         if not generated[n.state][0] == 'E':
19.             generated[n.state] = ['E', n]
20.             #GENERAR SUCESORES
21.             for s, a, c in problem.getSuccessors(n.state):
22.                 #FUNCION DE COSTE ADAPTABLE AL ALGORITMO
23.                 fdeNsuc = max(n.fdeN * astar, heuristic(s, problem) + (n.gdeN + c) * usegN)
24.                 ns = node.Node(s, n, a, fdeNsuc, n.gdeN + c)
25.                 #CONTROLAR NODOS YA EXPANDIDOS O EN EL FRINGE
26.                 if not generated.get(ns.state) == None:
27.                     if generated.get(ns.state)[0] == 'E':
28.                         continue
29.                     if generated.get(ns.state)[0] == 'F' and generated[ns.state][1].fdeN <= ns.fdeN:
30.                         continue
31.                 fringe.push(ns, fdeNsuc)
32.                 generated[ns.state] = ['F', ns]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top