Vivek Balaraman wrote: > Joachim, > Thanks for the information. > > My response to the last part of your mail > > > On 6/9/08, *Joachim Schimpf (Independent Contractor)* > <jschimpf_at_...5... <mailto:jschimpf@...5...>> wrote: > > > How are you going to compute several solutions? Are they computed one > by one from scratch, or all in one go, or are alternative solutions > produced on backtracking, etc? > > > > Our current code in eclipse calculates a solution, stores it in a store > and then calls fail causing it to backtrack and find other > solutions. Then either when all solutions or number of solutions > 50 > used to send the solutions to the calling program one by one using the > write_exdr operations. > > something like > > calc_all_scenarios:- > > ( > > calc_one_scenario ([Index, Solution]), > > store_put(Store, Index,Solution), > > Additionally also increment the count of solutions in a counter > > fail > > ; > > Lookup counter to get number of solutions > > For all solutions, store_get(Store,I, Solution), write solution to queue > > ). Using the C/C++ interface, there is no need to use queues, you can read the store contents directly by posting store_get/3 goals, i.e. EC_Ref solution; int index = ...; post_goal(term(EC_functor("store_get",3), "my_store_name", index, solution)); EC_resume(); Another solution, which is possible with the C/C++ interface, is to have the fail-loop in C++. In that scenario, you would initially post calc_one_scenario/1 and resume. When this succeeds and returns to C++, you have one solution and can process it in C++. You then post a fail/0 and resume, and this will succeed with the next solution and return to C++, and so on. No need to use stores. An example is in doc/examples/eg_cc_fail_loop.cc -- JoachimReceived on Tue Jun 10 2008 - 02:55:47 CEST
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST