Comments (3)
the Queue.PriorityQueue class is appropriate when you have to handle parallel
access to the queue (in multi-threads programs). For our purpose, I think the
heapq module is preferable.
Original comment by [email protected]
on 20 Jul 2012 at 3:40
from aima-python.
I've written a fix to make the function PriorityQueue.__contains__() run in
constant time, rather than being linear in the number of items on the queue.
It simply adds a hash table for membership testing. I've pushed it to a
branch on github:
https://github.com/nealmcb/aima-python/tree/fasterPriorityQueue
It sped up my solution for the second problem in ai-class.org unit 22 "Optional
NLP Programming" by a huge factor.
Note that __getitem__() and __delitem__() are still linear time, but could
easily be improved also if necessary. But in my current usage they aren't
hotspots.
I didn't switch to use the standard hashq or Queue.PriorityQueue modules since
they don't provide a constant-time membership test, but it still would seem
better to use one of them.
My fix also includes another commit which improves the doctests a bit. They
now test membership after pops.
A patch is attached.
Original comment by [email protected]
on 30 Jul 2012 at 4:25
Attachments:
from aima-python.
Looking up the hash of a key is incorrect because different keys may have the
same hash, right? I think this could be fixed to store the actual keys, though.
Original comment by [email protected]
on 20 May 2013 at 11:07
from aima-python.
Related Issues (20)
- 6 Tests failing in latest svn download of data and code HOT 1
- nlp.py: E0 grammar missing Name in NP HOT 1
- Errors in NearestNeighborLearner HOT 3
- Error in utility function for Tic Tac Toe makes 'X' always win HOT 1
- Misleading comment in MDP class HOT 1
- TicTacToe games utility method is incorrect HOT 3
- Unit Tests Fail 'out-of-the-box' HOT 4
- IOError: [Errno 2] No such file or directory: '/home/maxim/aima-python-read-only/../data/orings.csv' HOT 2
- abstract instead of NotImplementedError
- R133 runtime error HOT 3
- MDP: mdp.py infinite loop for gamma = 1
- Patch for /trunk/games.py
- search algorithms outside classes ?
- File missing
- alpha beta pruning is incomplete
- fiind_unit_clause function used by dpll_satisfiable in logic.py has a missing case HOT 1
- [deleted issue]
- ConnectFour- Game: inside actions method - listcomprehension issue causes traceback
- The function dpll_satisfiable in logic.py requires arguments to be expr-s.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aima-python.