Dear Joachim, Thank you for your explanation. Our task is to have a fuller version of incremental query (than post_goal and EC_resume can do now). We may need to modify or re-design the algorithms for our purpose. It will be great if you or any one here can provide me some pointers and references (and more details if possible) on the Eclipse algorithm and implementaion of incremental answering of queries (i.e., related to post_goal and EC_resume). best, Yuanlin > -----Original Message----- > From: Joachim Schimpf [mailto:joachim.schimpf_at_infotech.monash.edu.au] > Sent: Monday, June 22, 2009 9:25 AM > To: 'eclipse-clp-users_at_lists.sourceforge.net' > Subject: Re: [eclipse-clp-users] On implementation of post_goal and > EC_resume > > Zhang, Y wrote: > > > > We are working on answering a sequence of goals incrementally. > > We noticed eclipse provides "post_goal" in its interface for C++. > > I'd like to know how eclipse process the continuously added goals > > (incrementally)? > > Yes, it's incremental. As long as your posted goals succeed, > additional posted goals get appended to the resolvent (so they form a > logical conjunction), you can imagine something like: > > ?- get_posted_goals(G1), call(G1), get_posted_goals(G2), call(G2), ... > > You can find some further discussion here > http://eclipse-clp.org/archive/eclipse-users/0704.html > http://eclipse-clp.org/doc/bips/kernel/externals/yield-2.html > > > > > > I also have a programming problem. I write this piece of code: > > > > --- > > ... > > ec_exec_string("compile('test.pl')",0); > > > > post_goal(term(EC_functor("q",1),X)); > > if (EC_resume(Start)==EC_succeed){ > > ((EC_word)X).is_atom(&r1); > > cout << "succeed" << " X=" << r1.Name() << endl; > > } > > else cout << "failed q(X)" << endl; > > > > post_goal(term(EC_functor("q", 2), X, Y)); > > if (EC_resume(Start)==EC_succeed) { > > cout << "succeed"; > > if (EC_succeed == ((EC_word)X).is_atom(&r1)) > > cout << " X=" << r1.Name() << " "; > > > > if (EC_succeed == ((EC_word)Y).is_atom(&r2)) { > > cout << " Y=" << r2.Name() << endl; > > } > > else cout << "bad Y " << endl; > > } > > else > > cout << "failed q(X,Y)" << endl; > > ... > > --- > > --- test.pl --- > > q(a). > > q(b). > > q(b,c). > > --- end of test.pl --- > > > > I got this output > > > > -- > > succeed X=a > > succeed X=b bad Y > > succeed X=b > > succeed X=basf Y=c > > --- > > > > In fact, I expect line 2 to be "succeed X=b Y=c". Any comments on > > what's wrong about the program? Thank you. > > In the following I have marked the "current execution point" with a ^. > You first post p(X): > > ?- p(X). > ^ > after resuming, you get the first solution X=a, so effectively the > resolvent now looks like: > > ?- p(a). > ^ > now you post q(a,Y): > > ?- p(a), q(a,Y). > ^ > but after resuming, p(a,Y) fails, which means we backtrack to p(X) > which succeeds with the second solution X=b: > > ?- p(b). > ^ > But you see that the posted q(a,Y) goal was lost during backtracking > because it was posted only conditionally for the first solution of > p(X). > > To achieve the result you expected, you have to post both goals > together at the beginning, and only resume once. > > > -- Joachim > > ---------------------------------------------------------------------- > - > ------- > Are you an open source citizen? Join us for the Open Source Bridge > conference! > Portland, OR, June 17-19. Two days of sessions, one day of > unconference: $250. > Need another reason to go? 24-hour hacker lounge. Register today! > http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebr > i > dge.org > _______________________________________________ > ECLiPSe-CLP-Users mailing list > ECLiPSe-CLP-Users_at_lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/eclipse-clp-usersReceived on Wed Jul 29 2009 - 15:41:29 CEST
This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET