Frequently asked questions. Add your question here. If it happens to be infrequent or fits better in other wiki we will move it.
--
RadoslawSzymanek - 28 Jul 2008
* I (
HakanK) am learning
JaCoP and has some questions. Links below are to models at my
JaCoP page
http://www.hakank.org/JaCoP . (Explanation and links related to the problems are in the source files.)
-
LeastDiff.javaThe objective here is to minimize the difference ABCDE-FGHIJ, where A..J is 0..9 (all different).
I looked for the constraint
XminusYeqZ? , but found none. Instead I had to use the following construct:
// diff = abcde - fghij
// ->
// diff + fghij = abcde
store.impose(new XplusYeqZ? (diff, value_fghij, value_abcde)); This works of course, but it would be nice with a constraint
XminusYeqZ? (value_abcde, value_fghij, diff), though.
Is there are reason (other than that noone asked for it) why
XminusYeqZ? is missing?
ANSWER : Implementing a constraint takes some time and coding (all functions from the interface must be implemented). In addition, if we find an improvement for a given constraint, we would have to change it in many places (
XplusYeqZ? and
XminusYeqZ? ) making it likely to introduce (efficiency) bugs. Here, for ease of maintenance, and small code footprint we force a user to transform his constraint like
XminusYeqZ? into the
XplusYeqZ? .
-This is not a question, just a note about modelling in
JaCoP.
The more advanced models,
DeBruijn? and
Minesweeper , were surprisingly easy to model. Both are quite straightforward translations of
my MiniZinc models, so there are probably better ways of modelling them in
JaCoP. Please feel free to point out any suggestions.
- Are there any plans of supporting sets? There are some problem where modelling using sets helps much.
ANSWER : No immediate plans. Although, aware of that interest, we redesigned the domain abstract class to make it possible to write your own
SetDomain? class and by providing functions specified by Domain you will be able to plugin
SetDomain? into
JaCoP withouth problems.
SetDomain? by itself is of little use, the constraints must also be implemented. We concentrate mostly on CP(FD).
--
HakanK - 12 Aug 2008