Re: [eclipse-clp-users] Data Passing from C++ to Eclipse

From: Joachim Schimpf (Independent Contractor) <jschimpf_at_...5...>
Date: Mon, 09 Jun 2008 14:50:58 +0100
Ok, I suggest you forget for the moment everything about yield, resume
or queues, and start fresh:

The basic method of calling Eclipse form C++ is by using post_goal + resume.
The posted goal can have input and output arguments.  I don't see why you
should need anything more complicated for your purpose.

So your Eclipse code should have a main predicate, e.g.

solve(Parameters, Results) :-
	... compute Results from Parameters ...

and you simply call this from C++ by doing:

	EC_word parameters = ... construct the Parameters argument ...
	EC_Ref result;

	post_goal(term(EC_functor("solve",2), parameters, result));
	if (EC_resume() == EC_succeed)
		... now you can decompose the Result argument ...

Both the Parameters and Results arguments could be Eclipse lists or
structures containing numbers.  Parameters would be constructed in
C++ and accessed in Eclipse, while Results would be constructed in
Eclipse and accessed in C++.  Please try this simple scheme first,
it is in Chapter 2.3.1 of the Embedding manual, and you need the
functions from the C++ appendix.

Once you have that working, you may want to try to use the technique
in chapter 3.4 of the Embedding manual.  In that case, both Parameters
and Results could be C++ arrays, which are accessed by Eclipse though
an "external data handle".  This is created in C++ using the handle()
function, and then Eclipse can read/write this C++ array using its
xset/xget/3 built-ins.  Control-flow-wise this is the same as above
(a simple post_goal + resume), only the types of the passed arguments
is different.

SadikAli.Sayyad@...123... wrote:
> Hi,
> We have a financial model which have around 150 parameters, some of 
> which have constant values, or which are range bound. We need to pass 
> this to Eclipse to find out potential solutions which meet this 
> financial scenario. The output will consist of multiple scenarios where 
> each scenario has a set of parameters with range values.

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?

-- Joachim
Received on Mon Jun 09 2008 - 06:51:48 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST