Search code examples
eclipse-clp

How To write a query for testing the following code that written with eplex Lib in ECLiPSe-CLP


I am new in ECLiPSe and have a follwing problem. when I write and compile this simple program:

---------------------------------
:- lib(eplex).

main1(Cost, Vars) :-
Vars = [A1, A2, A3, B1, B2, B3, C1, C2, C3, D1, D2, D3],
Vars :: 0.0..inf,            % variables
A1 + A2 + A3 $= 200,            % demand constraints
B1 + B2 + B3 $= 400,
C1 + C2 + C3 $= 300,
D1 + D2 + D3 $= 100,

A1 + B1 + C1 + D1 $=< 500,        % capacity constraints
A2 + B2 + C2 + D2 $=< 300,
A3 + B3 + C3 + D3 $=< 400,

optimize(min(                % solve
10*A1 + 7*A2 + 11*A3 +
8*B1 + 5*B2 + 10*B3 +
5*C1 + 5*C2 +  8*C3 +
9*D1 + 3*D2 +  7*D3), Cost).
------------------------------

I dont know how to test it? or what is simple query for test it?

I will be very glad ,If you guide me . Thanks in Advance


Solution

  • The two arguments of main1 are both outputs, so you can just provide two variables (upper case names) in your query, for example main1(C,Vs). Type this into the query prompt (or the query entry box, if you are using tkeclipse), then the system will run the code and print the answer bindings:

    [eclipse 1]: main1(C, Vs).
    C = 6600.0
    Vs = [100.0, 0.0, 100.0, 100.0, 300.0, 0.0, 300.0, 0.0, 0.0, 0.0, 0.0, 100.0]
    Yes (0.00s cpu)