[gecode-users] Problem with FlatzincSpace deep copy

Guido Tack tack at gecode.org
Fri Feb 22 10:11:11 CET 2013


Hi,

you're using several classes not in the way they were designed.

First of all, you have to call clone on fs instead of copy.

Secondly, you're not supposed to create the Engine* like that.  Try the following code:

BAB<FlatZincSpace> bab(s_copy, opt);
FlatZincSpace* solution = bab.next();

Please have a look at the tutorial documentation, these things are explained there.

Cheers,
Guido

On 22/02/2013, at 20:04 , Mohamed Rezgui <kyo.alone at gmail.com> wrote:

> Hi everybody, 
> 
> I have a bug to copy (deep copy) a FlatzincSpace without branhing (no Branchers) 
> when I would like to start a branch and bound in only two decision variables.
> 
> <code>
> Printer p;
> FlatZincSpace* fs = FlatZincSpace::parse(......); 
> 
> FlatZincSpace* s_copy = fs->copy(false);
> s_copy->shrinkArrays(p);
> 
> 
> SearchOptions opt = o;
> opt.threads = 1.0; //MonoThread
> opt.expand();
> 
> Gecode::IntVarArgs vars(2);
> vars[0] = s_copy->iv[0];
> vars[1] = s_copy->iv[1];
> 
>         	
> Gecode::branch(*s_copy, vars, Gecode::INT_VAR_NONE(), Gecode::INT_VAL_MIN());
> 		
> Gecode::Search::Engine* bab = Gecode::Search::bab(s_copy, 1.0, opt); 
>         
> FlatZincSpace* solution = NULL;
> solution = static_cast<FlatZincSpace*>(bab->next()) ;//<----------------------- Bug here
> </code>
> 
> the bug is declared in this instruction line 85 
> file search/sequential/bab.hh
> <code>
> forceinline 
>   BAB::BAB(Space* s, size_t sz, const Options& o)
>     : Worker(sz), opt(o), d(0), mark(0), best(NULL) {
>     current(s); //<----------------------- Bug here
> </code>
> 
> Precisely when there is an allocation of an actorlink in s->allocated() 
> file search/worker.hh  line 162
> <code>
> forceinline void
>   Worker::current(const Space* s) {
>     if (s == NULL) {
>       mem_total -= mem_cur;
>       mem_cur = 0;
>     } else {
>       mem_cur = mem_space + s->allocated(); //<----------------------- Bug here
>       mem_total += mem_cur;
>       if (mem_total > memory)
>         memory = mem_total;
>     }
>   }
> 
> With Gecode rev13367
> 
> Can you help me please ?
> 
> Best Regards,
> Mohammed REZGUI
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users

-- 
Guido Tack,
http://www.csse.monash.edu/~guidot/



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20130222/8b7e3f64/attachment.html>


More information about the users mailing list