[gecode-users] Problem with FlatzincSpace deep copy
Christian Schulte
cschulte at kth.se
Fri Feb 22 10:52:16 CET 2013
But, first and foremost, read the documentation!
Then you would have known many things in advance: that you should not
contact me but the users list, that it is clone not copy, that status
matters.
Honestly, why do you think there is some 450 pages plus docs if it does not
serve any purpose?
Christian
--
Christian Schulte, www.ict.kth.se/~cschulte/
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Guido Tack
Sent: Friday, February 22, 2013 10:29 AM
To: Mohamed Rezgui
Cc: users at gecode.org
Subject: Re: [gecode-users] Problem with FlatzincSpace deep copy
As I said, using copy won't work, in fact it's likely that this causes the
problem. Simply call status() on the space before calling clone(), that
will get rid of the exception (SpaceNotStable has nothing to do with whether
there are any branchers).
Cheers,
Guido
On 22/02/2013, at 20:26 , Mohamed Rezgui <kyo.alone at gmail.com> wrote:
and the clone() method throw en exeption Gecode::SpaceNotStable because
there are no branchers
and this is why I used copy()
Best regards,
Mohamed REZGUI
2013/2/22 Mohamed Rezgui <kyo.alone at gmail.com>
OK thank you I change it but the bug is still here :S
Best Regards
Moahmed REZGUI
2013/2/22 Guido Tack <tack at gecode.org>
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/
--
Cordialement,
Mohamed REZGUI
--
Cordialement,
Mohamed 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/3d4ae4bb/attachment.html>
More information about the users
mailing list