First of all, I meant the copy constructor in your custom branching. Secondly, I re-read your originally posted code, and saw that you use the status/description/commit interface erroneously. From the documentation of description [1]: "This member function can only be called after the member function Space::status on the same space has been called and in between no non-const member function has been called on this space."
Cheers, Mikael [1] http://www.gecode.org/gecode-doc-latest/group__TaskSearch.html On Wed, Jan 21, 2009 at 8:12 AM, Malcolm Ryan <malco...@cse.unsw.edu.au> wrote: > On 21/01/2009, at 5:36 PM, Mikael Zayenz Lagerkvist wrote: > >> Hi, >> >> While I'm not sure about the exact reason for your failure (especially >> without seeing your code), it could be that you call the wrong >> Branching-constructor in your copy constructor. See the example custom >> branchings in examples/black-hole.cc and examples/queen-armies.cc for >> guidance. > > Yes, I was following those examples. My code for the space is: > > > ConcretePlanSpace::ConcretePlanSpace(Graph *graph, int nRobots, int > maxLength) : > Space(), myPlan(this, graph, nRobots, maxLength, true) { > > } > > ConcretePlanSpace::ConcretePlanSpace(bool share, ConcretePlanSpace > &space) : > Space(share, space) { > myPlan.update(this, share, space.myPlan); > } > > ConcretePlanSpace::~ConcretePlanSpace() { > // TODO Auto-generated destructor stub > } > > Space* ConcretePlanSpace::copy (bool share) { > return new ConcretePlanSpace(share, *this); > } > > CompletePlanVar& ConcretePlanSpace::getPlan() { > return myPlan; > } > > > >> >> >> Cheers, >> Mikael >> >> On Wed, Jan 21, 2009 at 7:21 AM, Malcolm Ryan <malco...@cse.unsw.edu.au >> > wrote: >>> I've written a custom branching and I am trying to write some unit >>> tests to make sure it is working properly. As such, I am doing the >>> branching and propagation process step-by-step, but there is >>> something >>> wrong with my code. I have: >>> >>> ConcretePlanSpace *space = new ConcretePlanSpace(graph, 1, 10); >>> ConcretePlanBranching *branching = new (space) >>> ConcretePlanBranching(space); >>> >>> assert(space->status() == SS_BRANCH); >>> >>> const BranchingDesc* desc = space->description(); >>> space->commit(desc, 0); >>> >>> assert(space->status() == SS_BRANCH); >>> >>> That much of the code works fine, but I want to create a clone of the >>> space to test out different alternatives: >>> >>> Space* copy = space->clone(false); >>> desc = copy->description(); >>> copy->commit(desc, 0); >>> >>> When it gets to commit() the code fails. GDB shows: >>> >>> Program received signal EXC_BAD_ACCESS, Could not access memory. >>> Reason: KERN_PROTECTION_FAILURE at address: 0x0000000b >>> 0x001d1e0b in Gecode::Space::commit (this=0xf17460, d=0x7, a=0) at >>> gecode/kernel/core.cc:330 >>> 330 while ((b_commit != Branching::cast(&a_actors)) && >>> >>> Any ideas what I am doing wrong? >>> >>> Thanks, >>> >>> Malcolm >>> >>> _______________________________________________ >>> Gecode users mailing list >>> us...@gecode.org >>> https://www.gecode.org/mailman/listinfo/gecode-users >>> >> >> >> >> -- >> Mikael Zayenz Lagerkvist, http://www.ict.kth.se/~zayenz/ > > > _______________________________________________ > Gecode users mailing list > us...@gecode.org > https://www.gecode.org/mailman/listinfo/gecode-users > -- Mikael Zayenz Lagerkvist, http://www.ict.kth.se/~zayenz/ _______________________________________________ Gecode users mailing list us...@gecode.org https://www.gecode.org/mailman/listinfo/gecode-users