Re: [eclipse-clp-users] Storage of delayed goals

From: Kish Shen <kisshen_at_cisco.com>
Date: Tue, 24 Jul 2012 03:11:41 +0100
Hi Daniel,

I think what you want is to have interaction between your ECLiPSe goal 
and Java, i.e. what you want to do is:

goal :-
    setu-p constraints(....),
    wait_for_check.

wait_for_check :-
    <return control to Java and wait for check>,
    wait_for_check.

You of course need some way to terminate the wait_for_check when you 
want to finish.

You can hand control from ECLiPSe back to Java while executing a goal, 
e.g. via a queue, you can then return control back from Java to ECLiPSe
(again via a queue) when you want to run check (wait_for_check in the 
example above).

A simple example of this sort of interaction is shown in the 
EclipseMapColourer.java example (in doc/examples/JavaInterface in the 
ECLiPSe distribution), where a solution is returned to Java, and the 
ECLiPSe side wait for the user (interacting via Java) to ask for either 
the next solution, or stop running the program.

There is also a description of this interaction in the paper:

A High-Level Generic Interface to External Programming Languages for 
ECLiPSe, which you can download from:

http://eclipseclp.org/reports/eclipse_generic_interface.ps.gz

the example is described in terms of Tcl/Tk rather rather than Java, but 
the basic ideas are the same.

Cheers,

Kish

On 23/07/2012 13:41, Daniel Guimarans Serrano wrote:
> Hi all,
>
> We are using Java and ECLiPSe for solving a routing problem. Currently, we are using CP for checking feasibility. For efficiency reasons, we would like to store in memory the constraints model and not building it up every time we call the checking predicate.
>
> For instance, let's say we have two predicates, constraints/3 and check/3:
>
> constraints(A,B,C) :-
>    constraint_1(A,B),
>    constraint_2(B,C),
>    constraint_3(A,C).
>
> check(A,B,C).
>
> We would like to keep the delayed goals generated by constraints/3 when called with A,B, and C, uninstantiated, so in a later call to check/3 they are woken up. Instead of having:
>
> [eclipse1]: constraints(A,B,C), check(A,B,C).
> Yes(0.00s)            % or No(0.00s)
>
> we would like to get something like the following:
>
> [eclipse1]: constraints(A,B,C).
> There are XXX delayed goals.
> Yes(0.00s)
>
> [eclipse2]: check(A,B,C).    % where A,B, and C are instantiated
> Yes(0.00s)                            % or No(0.00s)
>
> Right now, we have the call to constraints/3 within the check/3 predicate, but we would like to take it out so we can make two separate calls from Java. The number of generated solutions is quite high, so it would be more computationally efficient to have one call to constraints/3 and several calls to check/3.
>
> We have been through the documentation and the mailing list archives, but couldn't find anything related. Is there any way to do it? And, if so, we are wondering if variables A, B, and C, will remain instantiated after the first call to check/3.
>
> Thanks in advance for your help!
>
> Best regards,
> Daniel Guimarans
>
> =====================================================================
> Daniel Guimarans Serrano
>
> Unitat de Gestiˇ AeronÓutica
> Departament de Telecomunicaciˇ i d'Enginyeria de Sistemes
> Escola d'Enginyeria - Universitat Aut˛noma de Barcelona
> Emprius, 2
> 08202 - Sabadell
>
> Despatx: S / 247
> Tel.: +34 93 728 77 55
> E-mail: daniel.guimarans_at_uab.cat
> =====================================================================
>
>
>
> This body part will be downloaded on demand.
>
>
>
> This body part will be downloaded on demand.
>


-- 
This e-mail may contain confidential and privileged material for the
sole use of the intended recipient. Any review, use, distribution or
disclosure by others is strictly prohibited. If you are not the intended
recipient (or authorized to receive for the recipient), please contact
the sender by reply e-mail and delete all copies of this message.
Cisco Systems Limited (Company Number: 02558939), is registered in
England and Wales with its registered office at 1 Callaghan Square,
Cardiff, South Glamorgan CF10 5BT.
Received on Tue Jul 24 2012 - 02:47:01 CEST

This archive was generated by hypermail 2.2.0 : Thu Jul 26 2012 - 06:15:15 CEST