[eclipse-clp-users] labeling question with ic and eplex

From: Kostas Oikonomou <ko_at_...308...>
Date: Tue, 02 Oct 2012 13:45:40 -0400
Hi,

I am experimenting with hybrid algorithms, using eplex and ic.
I am encountering a problem with labeling, exemplified by 
the following code:



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

hyb1(W,X,Y,F) :-
     eplex: (F :: 0.0..100.0),
     eplex_solver_setup(min(F),F,[],[new_constraint]),
     eplex: ([W,X,Y] :: 0..10),
     % constrain X to be integral for ic, so we can use 
ic:search() on it
     ic: (X #:: 0..10),
     eplex: (2*W + X + Y $= 13),
     eplex: (F $= W + 3*Y),
     ic:search([X],0,input_order,indomain,complete,[]),
     eplex_var_get(W,solution,W),
     eplex_var_get(Y,solution,Y),
     eplex_get(cost,F)
.


hyb2(W,X,Y,F) :-
     eplex: (F :: 0.0..100.0),
     eplex_solver_setup(min(F),F,[],[new_constraint]),
     eplex: ([W,Y] :: 0..10),
     dim(X,[2]),
     eplex: (X[1..2] :: 0..10),
     % constrain X to be integral for ic, so we can use 
ic:search() on it
     ic: (X[1..2] #:: 0..10),
     eplex: (2*W + X[1] + X[2] + Y $= 13),
     eplex: (F $= W + 3*Y),
     ic:search([X[1..2]],0,input_order,indomain,complete,[]),
     eplex_var_get(W,solution,W),
     eplex_var_get(Y,solution,Y),
     eplex_get(cost,F)
.

The query hyb1(W,X,Y,F) works as expected.  The query 
hyb2(W,X,Y,F) results in a type error:

[eclipse 3]: hyb2(W,X,Y,F).
Eplex warning: Imposing integer bounds on variable(s) [W, Y] 
for eplex instance eplex does not impose integer type.
Eplex warning: Imposing integer bounds on variable(s) 
[](_938, _939)[1 .. 2] for eplex instance eplex does not 
impose integer type.
type error in indomain([](_1059{}(','(:(ic, ..(0, 10)), 
:(eplex, _at_(..(0.0, 10.0), 10.0)))), _1041{}(','(:(ic, ..(0, 
10)), :(eplex, _at_(..(0.0, 10.0), 3.0)))))[1 .. 2])
Abort
[eclipse 4]:


The only difference between hyb1 and hyb2 is that X is a 
single variable in hyb1 but a 2-element array in hyb2.
I don't understand why or how the array is treated 
differently.  And is there a way around this issue?

I see that when I change X from an array to an explicit list 
[X1,X2], the problem goes away.
But in my application I need an array.

                                     Kostas
Received on Tue Oct 02 2012 - 17:45:50 CEST

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST