Re: Eclipse and C++

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Fri 11 Feb 2005 02:32:59 PM GMT
Message-ID: <420CC21B.8080201@icparc.ic.ac.uk>
Cristina Marconcini wrote:
> Dear All,
> I have some problems in calling some Eclipse functions from  C++.

You are having this problem because you are trying to "program Eclipse
through the C++ interface". This is not what it is designed for!
(if you want to do all your programming in C++, get a C++ solver
library, but you will hopefully see that programming in Eclipse has
considerable advantages when it comes to constraint programming).

If you are using Eclipse, you should do all the solving-related
programming in Eclipse, and only the I/O in C++.  If you do that,
the structure of your program looks something like

1. Input problem data in C++
2. Pass problem data (numbers) to Eclipse
3. Solve problem in Eclipse
4. Pass solution (numbers) back to C++
5. Output the result

The important point is that the data you pass between the Eclipse and
the C++ code is only numbers (or other constants), but never awkward
things like domain variables or delayed goals!


> 
> For example, given a simple example like this
> s1  :-   X1 :: 0..10, X2 :: 0..10,  (neg(X1 #= 5)) and (X1 #< X2),   
> writeln(X1),  writeln(X2).
> I get the following solution with Eclipse:
> X1{[0 .. 4, 6 .. 9]} X2{1 .. 10} Delayed goals:  X2{1 .. 10} - X1{[0 .. 
> 4, 6 .. 9]} #> 0

You need to understand a bit more about constraint programming, about the
properties of constraint propagation, and its interaction with search.

What you have here is NOT a solution! It is an intermediate state of
computation. A solution has
- no remaining variables (they all have been instantiated to values)
- no delayed goals (they are all satisfied and have disappeared)

You need to add search (e.g. labeling) to get to a solution state.


> 
> Is there a method to extract from a list of solutions a random element 
> for every variable?
> For example the function indomain(Var) allow me to get a single 
> solution, but it is the minumun.
> 
> I have to call eclipse from a C++ program. So, I can express the 
> solution domains
> with the get_domain_as_list(X, LIST) function.
> Is there a method to pass the solutions list form eclipse to a C++ list?
> 
> Then, I there a structure in eclipse to express the delayed goals in C++?

You don't need any of this. Because, as explained above, when you have a
solution, all variables are instantiated and there are no delayed goals.


> 
> Thanks
> 

My advice is, first solve your problem in pure Eclipse, then worry about
emebdding it into a C++ application.


-- 
  Joachim Schimpf              /             phone: +44 20 7594 8187
  IC-Parc                     /      mailto:J.Schimpf@imperial.ac.uk
  Imperial College London    /    http://www.icparc.ic.ac.uk/eclipse
Received on Fri Feb 11 14:37:24 2005

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:33 PM GMT GMT