[gecode-users] Sum of IntVarArrays with changing array positions

Guido Tack tack at gecode.org
Thu Oct 13 10:33:58 CEST 2011


On 12 Oct 2011, at 16:27, Mathias Dalheimer wrote:
> Dear Guido, dear Christian, list,
> 
> wow, I'm impressed - usually not even paid support does answer so fast
> and so accurate. Thank you very much!
> 
> I've implemented Guidos idea, but I still have a problem. My code looks
> like this:
> 
> I have some member variables (all IntVarArrays), here's the
> initialization list:
> 
>  :_start_times(*this, devices.size(), 0, MINS_PER_DAY)
>  _movable_load(*this, MINS_PER_DAY, 0, 15000)
>  _dev0_load(*this, MINS_PER_DAY, 0, 15000)
>  _dev1_load(*this, MINS_PER_DAY, 0, 15000)
>  _dev0(*this, devices[0].size(), 0, 15000)
>  _dev1(*this, devices[1].size(), 0, 15000)
> 
> devices is of type std::vector< std::vector >, I copy the
> initial device data to _dev0 (and _dev1):
> 
>  for (size_t i=0; i < devices[0].size(); ++i) {
>    rel(*this, _dev0[i] == devices[0][i]);
>  }
> 
> Then, I use Guido's recommendation:
> 
> for (int j=0; j < _dev0.size(); ++j) {
>    rel(*this, _dev0_load[j] == element(_dev0, _start_times[0] + j));
> }

Shouldn't this be the other way around:

for (int j=0; j < _dev0.size(); ++j) {
   rel(*this, _dev0[j] == element(_dev0_load, _start_times[0] + j));
}


> Please note that I was not able to use the post function - the compiler
> complains that the function is not defined, although minimodel.hh is
> included.

Right, sorry, rel was called post in an earlier version of Gecode and I still get that mixed up sometimes.

Cheers,
Guido

-- 
Guido Tack, http://people.cs.kuleuven.be/~guido.tack/




More information about the users mailing list