Re: [eclipse-users] R: ec_cleanup() segmentation fault

From: Kish Shen <kisshen_at_cisco.com>
Date: Thu, 07 Feb 2008 14:44:38 +0000
Hi Guiseppe,


Giuseppe Di Guglielmo wrote:
> Hi Kish,
> thanks.
>
> Does exist a way to submit via a C/C++ API to ECLiPSe constraints
> dynamically created?
>
> Let us imagine a post_goal function which receives a string rather than a
> complex ECLiPSe data-structure, in this way I could write
> post_goal("x<2");
> or
> post_goal(my_constraint);
>
>   

The C++ interface does allow you to post a string as a goal which will 
be parsed by ECLiPSe,:

void post_goal(const char *)

which iw described on the same page in the Embedding and Interfacing 
manual that I mentioned in my last reply to you:

http://www.eclipse-clp.org/doc/embedding/embroot067.html

Note that

1) the string must be in correct ECLiPSe syntax (so your "x<2" is 
incorrect, because variables should begin with upper case letters, e.g. 
"X < 2"). This may be a little difficult to do correctly from your C++ 
program, if you have complicated expressions.

2) Each post_goal() is parsed individually when they are executed, so 
variables in one post_goal will not be linked to another post_goal().

post_goal("X > 3");
post_goal("X > 4");

the two Xs are different variables.

So this probably does not do what you want to do, unless you use a 
single post_goal to post all the constraints and collect the results you 
want back as well.

In short, you are better off writing most of the program on the ECLiPSe 
side. Is there any reason why you can't dynamically generate the 
constraints on the ECLiPSe side? I think the best way to approach your 
problem is to write an ECLiPSe program which has a top-level query that 
is called from your C++ code, which just passes the information needed 
by the ECLiPSe program to generate the constraints you want, and to 
return the result you want, *all in one goal* that you call with a 
single post_goal().

It is difficult to give a relevant example that suit your needs without 
knowing more about how your constraints are generated. However, examples 
of what can be passed in your post_goal includes:

1) the filename giving the file that contains the information to 
generate the constraints you need, if your constraint/problem is 
specified in a file.
 
2) some flat representation of your constraints (e.g. "op(<) var(X) 
int(2)" for X < 2) that can be easily parsed by your ECLiPSe program, if 
your constraints are generated by some C++ application.

Cheers,

Kish


> where my_constraint is built runtime as a string.
>
> Giuseppe
>
>
> ----------------------------------------------------------------------------
> Giuseppe Di Guglielmo       Dept. of Computer Science - University of
> Verona 
>                                Strada le Grazie, 15 - 37134 Verona - Italy
>
> Phone Office:   +39 045 8027049         Fax:    +39 045 8027068
> Phone Home:     +39 045 6152251         Mobile: +39 347 0493371
>
> WWW: http://profs.sci.univr.it/~diguglielmo
>
> email: giuseppe.diguglielmo_at_univr.it 
> email: diguglielmo_at_certess.com          Skype: giuseppe.diguglielmo  
>
> ----------------------------------------------------------------------------
>
>
> This e-mail message is intended for the addressee(s) only and may contain 
> confidential and or privileged information.  If you are not the intended 
> recipient of this e-mail message, you should not read, copy, forward or 
> otherwise distribute or further disclose the information in it. If you have 
> received this e-mail message in error, please contact the originator of this
> e-mail message via e-mail and delete all copies of this message from your 
> computer or network, thank you.
>
>
>
>
>
> _______________________________________________
> ECLiPSe-Users mailing list
> ECLiPSe-Users_at_crosscoreop.com
> http://www.crosscoreop.com/mailman/options/eclipse-users
>   
Received on Thu Feb 07 2008 - 14:44:53 CET

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET