## Leading with double document.SUBSCRIPTION_OPTIONS = { "thing": "thread", "subscribed": false, "url": "subscribe", "icon": { "css": "fa fa-envelope-o" } };

Help
Sylvain
2012-01-04
2013-05-30
• Sylvain - 2012-01-04

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.

Regards,

Sylvain

• kris - 2012-01-04

Hi!

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 ;)

Best,
/Kris

• Sylvain - 2012-01-04

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!

Sylvain