Hi all and happy new year!
I have been using JaCoP for some days now and I am really satisfied with the tool but I am facing a problem for which I didn't manage to get a simple solution yet. In my model, I have to use both double coefficients and variable division (through the XdivYeqZ method). I noticed that:
* it is not possible to multiply a variable by a double, but only an integer,
* the XdivYeqZ method returns in fact Z = Math.floor(X/Y).
I'd like to know if there is some way I can multiply a variable by a double and round (or floor, or ceil) the result, and if I can simply have a variable Z = Math.ceil(X/Y) without having to use the mod function.
Happy New Year!
JaCoP is finite domain solver and it uses **finite domains** for their variables, represented as integer domains. Thus double is not possible but … you can play with XdivYeqZ and XmodYeqZ. Since they are constraints you can use also XdivYeqZ for multiplication.
For example, you can do 5 div 2 = 2 and 5 mod 2 = 1 thus you have 2 1/2 = 2.5.
I do not know if this helps and certainly it is not the way JaCoP has been planned to be used ;)
I noticed indeed that JaCoP is a finite domain solver. The only thing in my case is that although my decision variables are all integer, their calculations involve doubles (such as divisions, or double coefficients before rounding the result).
For example, the simple problem of "finding the number of perimeters of a circle (with a given diameter) that are necessary to get the total distance over a given threshold" would be using integer variables but double-oriented calculations.
But ok, I will then use the mod function for my matters. Thanks Kris!
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.