[gecode-users] saving the way to one of the solution in a file

Mikael De Bie mikael.debie at student.uclouvain.be
Sun Dec 10 18:01:16 CET 2006


On Mon, 2006-12-04 at 14:41 +0100, Guido Tack wrote:
> > nevertheless I wonder why the webpage http://www.gecode.org/gecodej/
> > indicates that Gecode/J allows to implement search engines using  
> > copying
> > and recomputation.
> >
> > Don't you think I could program a new search engine totally in java as
> > it's done for Gist ?
> 
> Sorry, I maybe wasn't very clear on this. You can write the search  
> engine in Java, it's just that you can't take an existing one and  
> modify it, but you'll have to start from scratch. I wanted to suggest  
> that you look at the C++ code, and then more or less port that to  
> Java, adjusting it to your needs. The space interfaces are very  
> similar in C++ and Java, so porting stuff is relatively easy.
> 
> Cheers,
> 	Guido
> 

I've finally decided to use gecode instead of gecode/J so that I could
modify the existing classes dfs.icc, reco-stack.icc and search.hh rather
than implement the whole from nothing.

I've managed to get the way to the solution found, that is the list of
alternatives to follow. But I don't really understand how to rebuild the
stack.

In my opinion, I have to push a new ReCoNode in the stack for each
alternative.

I've tried to add a method in DFSEngine that rebuild the stack:

	// Reconstruct the stack from the way (ex: way = "0110111")
	forceinline void
	DfsEngine::setWay(string way){
		rcs.reset();
		const BranchingDesc* desc = rcs.push(cur, NULL);
		for(int i=0;i<way.length();i++){
			//Get the integer in ith pos in the way
			string stmp = way.substr(i,1);
			const char* tmp = stmp.c_str();
			int j = atoi(&tmp[0]);
			
			//push a new ReCoNode in the stack
			cur->commit(desc,j);
	     		desc = rcs.push(cur,NULL);
		}
	}

Once the stack is rebuild, I thought I could simply call the method
next().
But it doesn't seem to work...

I don't get any error, but the program simply stops when j = 1 but I
don't know why...

Has anybody any idea to help me ?

Thanks in advance

Mikael





More information about the gecode-users mailing list