Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I have solved Bridge and Torch puzzle in Prolog by simple depth first search. Now I am trying to solve it via a heuristic search. But I have no idea how should a heuristic be defined in Prolog.
As I have not found useful examples in SWI-Prolog manual and Google, would you please help me find some examples in Prolog which use heuristics for searching? Or give me a hint to start thinking heuristically about this problem.
Take a look to the state-space searching example distributed with Logtalk (which you can run using several backend Prolog compilers, including SWI-Prolog):
https://github.com/LogtalkDotOrg/logtalk3/tree/master/examples/searching
This example defines a state-space searching framework, supporting both blind and heuristic search, and comes with several examples, including a "bridge" one that might be useful to compare with your own solution. You will find examples of heuristics in some of the provided examples. This "searching" example also provides profiling support, which is useful to compare the effectiveness of different heuristics and search strategies.
You may look at my answer that uses Warnsdorff's heuristic to solve large Knight's tour puzzle: https://stackoverflow.com/a/21069014/220700 But the Warnsdorff's heuristic (Warnsdorff's rule) is very strong - it always works, which is not typical for heuristics in general.
The main idea of using heuristics in general is that if you have a predicate that lists all possible moves, order them according to some rule: shortest first, largest first, etc.
A* (A star) is one of the most used heuristics-based algorithms. Just google "a-star in prolog" for a lot of info.
Also constraint logic programming uses heuristics all the time: first_fail, most_constrained, largest, etc.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I would like to formalize some knowledge and execute queries in what may referred to as fully-declarative Horn logic (or, fully-declarative Prolog). Could anyone provide some guidelines on how to implement it? I briefly recap the fine description from the link above:
The formal language is that of (the core of) Prolog: a "program" is a set of rules and facts as in Prolog (including functions and variables and basically, containing only user defined predicates).
In contrast to Prolog, however, I am looking for an implementation that is sound and complete with respect to the standard declarative semantics of logic programs --- the least Herbrand model (i.e., the inductively defined set of ground terms). In theoretical work on logic programming this is usually the object of study, and it is well known that a sound and complete answer to queries can be attained (in the "recursively-enumerable" sense), for example, using SLD-resolution subject to the following conditions:
fair search for matching rules (e.g., Prolog's depth-first search is not fair);
unification with "occurs-check" (checking that a variable doesn't occur in a term with which it is unified).
I am looking for a concise implementation that would build on existing capabilities, rather than inventing the wheel. Two of the more promising directions that I see are implementing it as a meta-interpreter of Prolog, or as part of some theorem prover. Could anyone with practical knowledge in these domains provide some guideline on how to implement it? Can it be easily implemented in miniKanren?
My intentions are to formalize some knowledge in a fully-declarative manner. The crucial characteristics of such a formalization is that it precisely corresponds to the mathematical notion of (monotone) induction, so that the knowledge and it's properties can be easily reasoned about with inductive arguments.
It is an easy exercise to implement a prover for Horn logic in a few lines of Prolog. Start with the Vanilla Meta-interpreter, then modify it to use the standard unify_with_occurs_check/2 predicate for all unifications, and to use a complete search procedure - iterative deepening depth first search is the simplest to implement.
See #mat's page A Couple of Meta-interpreters in Prolog for some inspiration.
More pointers:
Datalog has declarative semantics, but as a "Prolog without function symbols" it is not Prolog. See the excellent intro "What You Always Wanted to Know About Datalog (And Never Dared to Ask)" by Ceri, Gottlob and Tanca, 1989. Available via CiteSeerX
Implementations of Prolog that use tabling instead of depth-first search for added declarativeness (plus other nice features as I understand), like XSB.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I was reading about restricted boltzman machines which is an algorithm used on deep learning. I dont finish to understand how do a RBM can be used to classification. Could anybody provide me a example of clssifying with this algorithm?.
From wikipedia:
RBMs have found applications in dimensionality reduction,
classification, collaborative filtering, feature learning and topic
modelling. They can be trained in either supervised or unsupervised
ways, depending on the task.[1]
[1] Larochelle, H.; Bengio, Y. (2008). "Classification using discriminative restricted Boltzmann machines". Proceedings of the 25th international conference on Machine learning - ICML '08. p. 536. doi:10.1145/1390156.1390224. ISBN 9781605582054. edit
RBM is not a classification model, it is a model for unsupervised learning. There are at least two possible classification-related applications:
In deep learning, RBMs are used as preprocessing units, while on the top of them you still built some "simple" linear model (like logistic regression, perceptron or svm)
In some side works (by Hinton in particular) you can create two RBMs stacks, and connect them with one layer of RBM on top, where one stack is feeded with inputs, and the second one with labels. This way RBM during autoaussociation learning actually models the input->labels mapping (as well as the other way around)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
We have a user, with a music library of 100 songs. Out of those he loves 20, he hates 10 and there are 5 he neither hates nor loves. He never listened to the remaining 65.
Question: What kind of algorithm(s) is/are used to scan the remaining 65 songs and find out music the user will like?
Do some research on a product called MusicIP, it had some very clever algorithm fingerprinting technology. It converted the track to WAV and then created a fingerprint, then some clever magic to match songs that were similar.
To suggest new unfamiliar content to a user, the general approach is to use machine learning, specifically collaborative filtering, which is often used for recommender systems. The idea is to use the knowledge of the crowd, and finds people (or groups) that have similar taste to yours, and recommend new items that they tend to like.
An alternative is creating a classification algorithm for like/dislike, but that might require extracting features from each song that will describe the essense of the problem, and that's usually not trivial at all.
Some classification algorithms you might want to try are SVM, Naive Bayes, neural networks, Decision trees and more. The real challenge, as I mentioned would be to find the right features for the problem.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I saw a talk by Keith Adams of Facebook comparing machine learning techniques to tuning code for improved performance in the real world. Are there examples of such automation techniques being applied in real projects? I
I know of profile guided optimizations in certain compilers and also some techniques JIT compilers use to improve performance, but I am thinking of more fundamental ways to improve code performance that could require changing the code itself and not code generation. Things like:
Choosing the optimal buffer size in a particular network application or choosing the right stack size for particular application.
Selecting the struct layout in a multi-threaded application that improves local cache performance while reducing false sharing.
Selecting different data structures all together for a certain algorithm.
I read a paper on Halide, an image processing framework that uses genetic algorithms to auto-tune image processing pipelines to improve performance. Examples like this one or any pointers to research would be useful.
Have a look at Remy http://web.mit.edu/remy/
It uses kind of genetic optimization approach to generate algorithm for congestion control in networks, significantly increasing network's performance. One specifies assumptions about network being used, and Remy generates control algorithm to be run on data nodes of this network. The results are amazing, Remy outperforms all human-developed so far optimization techniques.
FFTW is a widely used software package which uses OCaml to generate optimized C code. This paper has more details on the process: http://vuduc.org/pubs/vuduc2000-fftw-dct.pdf
You might also look into Acovea, a genetic algorithm to optimize compiler flags: http://stderr.org/doc/acovea/html/index.html
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I know C and C++ and I have some experience with Java, but I don't know too much about Algorithms and Data Structures.
I did a search on Amazon, but I don't know what book should I choose. I don't want a book which put its basis only on the theoretic part; I want the practical part too (probably more than the theoretical one :) ).
I don't want the code to be implemented in a certain language, but if is in Java, probably I would happier. :)
Don't buy any book use
MIT OCW
.
Introduction to Algorithms by Cormen et. al. is a standard introductory algorithms book, and is used by many universities, including my own. It has pretty good coverage and is very approachable.
And anything by Robert Sedgewick is good too.
I think introduction to Algorithms is the reference books, and a must have for any serious programmer.
http://en.wikipedia.org/wiki/Introduction_to_Algorithms
Other fun book is The algorithm design manual http://www.algorist.com/. It covers more sophisticated algorithms.
I can't not mention The art of computer programming of Knuth
http://www-cs-faculty.stanford.edu/~knuth/taocp.html
If you want the algorithms to be implemented specifically in Java then there is Mitchell Waite's Series book "Data Structures & Algorithms in Java". It starts from basic data structures like linked lists, stacks and queues, and the basic algorithms for sorting and searching. Working your way through it you will eventually get to Tree data structures, Red-Black trees, 2-3 trees and Graphs.
All-in-all its not an extremely theoretical book, but if you just want an introduction in a language you are familiar with then its a good book. At the end of the day, if you want a deeper understanding of algorithms you're going to have to learn some of the more theoretical concepts, and read one of the classics, like Cormen/Leiserson/Rivest/Stein's Introduction to Algorithms.
If you don't need in a complete reference to the most part of algorithms and data structures that are in use and just want to get acquainted with common techniques I would recommend something more lightweight than Cormen, Sedgewick or Knuth. I think, Algorithms and Data Structures by N. Wirth is not as bad choice even in spite of it was printed far ago.