Description
I have a problem with a FloatVar objective. I'm not sure the details are relevant, but here it goes:
FloatVar totalCost = expr(*this,
overstaffing/FloatVal(c1)+
unhappiness*FloatVal(c2)+FloatVal(c3))/FloatVal(c4)+
understaffing/FloatVal(c5)
);
where c1,..,c5 are constants (doubles), and overstaffing, understaffing, and unhappiness are also FloatVar.
I'm doing branch and bound (using BAB), but I'm getting a
Gecode::Float::ValOfUnassignedVar
when trying to read totalCost of one of the solutions found along the way, even when all the other involved variables are assigned. When printing the value of totalCost, it shows something like:
totalCost: [[1.69614..1.69614]]
but totalCost.max()-totalCost.min() is 4.4409e-16.
My model subclasses FloatMinimizeSpace without any parameters. I'm not linking with GMP, but there are no transcendental functions involved.
I understand that the fact that all variables in a float expression are assigned does not guarantee that the result of the expression can be represented by a single float value. The problem here is that gecode will throw an exception on the constrain() method since it is trying to access the val() method as well there (why not just max()?).
Likely solution (?)
I believe the calls to objective.val() should be replaced by objective.max() (in case of minimization), for example here:
|
rel(*this, cost(), FRT_LE, best->cost().val()-step); |
This will mean that for a very very small step the BAB may get stucked, but at least is safe.
To Reproduce
This might not be easy to reproduce it as this happens with some particular combination of floating point numbers.
Gecode and Platform Configuration
Gecode/gecode@release-6.2.0
Linux 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u1 (2019-09-20) x86_64 GNU/Linux
Description
I have a problem with a FloatVar objective. I'm not sure the details are relevant, but here it goes:
where c1,..,c5 are constants (doubles), and overstaffing, understaffing, and unhappiness are also FloatVar.
I'm doing branch and bound (using BAB), but I'm getting a
when trying to read totalCost of one of the solutions found along the way, even when all the other involved variables are assigned. When printing the value of totalCost, it shows something like:
totalCost: [[1.69614..1.69614]]but
totalCost.max()-totalCost.min()is4.4409e-16.My model subclasses
FloatMinimizeSpacewithout any parameters. I'm not linking with GMP, but there are no transcendental functions involved.I understand that the fact that all variables in a float expression are assigned does not guarantee that the result of the expression can be represented by a single float value. The problem here is that gecode will throw an exception on the
constrain()method since it is trying to access the val() method as well there (why not just max()?).Likely solution (?)
I believe the calls to objective.val() should be replaced by objective.max() (in case of minimization), for example here:
gecode/gecode/minimodel/optimize.cpp
Line 92 in 7749cde
This will mean that for a very very small
stepthe BAB may get stucked, but at least is safe.To Reproduce
This might not be easy to reproduce it as this happens with some particular combination of floating point numbers.
Gecode and Platform Configuration
Gecode/gecode@release-6.2.0
Linux 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u1 (2019-09-20) x86_64 GNU/Linux