[eclipse-clp-users] Getting started with ic_hybrid_sets

From: Matthew Skala <mskala_at_cs.toronto.edu>
Date: Sat, 9 Jan 2010 13:13:48 -0500 (EST)
I'm having trouble getting the ic_hybrid_sets library to work in even the
most basic ways.  I can't create union or intersection constraints; it
gives an error about add2_foreachevent being undefined.

Since I'm a beginner to ECLiPSe as well (though not to logic programming
or constraint programming) it's quite possibly some kind of trivial
installation problem, but everything else looks okay.  The problem is also
specific to ic_hybrid_sets; I can use ic_sets and have it work.  However,
I'd really like to be able to use the hybrid solver.  Any suggestions
appreciated.  Commented sessions demonstrating the problem below.

%
% This is a locally compiled copy of version 6.0_116.
%

mskala_at_opal:~/multilex$
/usr/local/src/Eclipse_6.0_116/bin/i386_linux/eclipse
ECLiPSe Constraint Logic Programming System [kernel]
Kernel and basic libraries copyright Cisco Systems, Inc.
and subject to the Cisco-style Mozilla Public Licence 1.1
(see legal/cmpl.txt or www.eclipse-clp.org/licence)
Source available at www.sourceforge.org/projects/eclipse-clp
GMP library copyright Free Software Foundation, see legal/lgpl.txt
For other libraries see their individual copyright notices
Version 6.0 #116 (i386_linux), Fri Jan  8 23:33 2010

%
% Load the hybrid sets library; it seems to load okay.
%

[eclipse 1]: lib(ic_hybrid_sets).
source_processor.eco loaded in 0.02 seconds
hash.eco   loaded in 0.01 seconds
compiler_common.eco loaded in 0.03 seconds
compiler_normalise.eco loaded in 0.01 seconds
compiler_map.eco loaded in 0.01 seconds
compiler_analysis.eco loaded in 0.02 seconds
compiler_peephole.eco loaded in 0.02 seconds
compiler_codegen.eco loaded in 0.03 seconds
compiler_varclass.eco loaded in 0.01 seconds
compiler_indexing.eco loaded in 0.01 seconds
compiler_regassign.eco loaded in 0.02 seconds
asm.eco    loaded in 0.03 seconds
module_options.eco loaded in 0.00 seconds
ecl_compiler.eco loaded in 0.20 seconds
ic_kernel.eco loaded in 0.23 seconds
linearize.eco loaded in 0.02 seconds
ic_constraints.eco loaded in 0.04 seconds
ic.eco     loaded in 0.01 seconds
ic_generic_interface.eco loaded in 0.01 seconds
ic_search.eco loaded in 0.04 seconds
ic.eco     loaded in 0.34 seconds
lex_set.eco loaded in 0.01 seconds
lists.eco  loaded in 0.01 seconds
ic_hybrid_sets.eco loaded in 0.43 seconds

Yes (0.45s cpu)

%
% Simply creating three set variables works.  Note it correctly displays
% the lex bounds for the variables.
%

[eclipse 2]: intsets([A,B,C],3,1,3).

A = A{([] .. [3, 2, 1]) : _253{0 .. 3} : ([] < [3, 2, 1])}
B = B{([] .. [3, 2, 1]) : _352{0 .. 3} : ([] < [3, 2, 1])}
C = C{([] .. [3, 2, 1]) : _451{0 .. 3} : ([] < [3, 2, 1])}
Yes (0.00s cpu)

%
% We can create lexical constraints; note that the bounds change
% appropriately.
%

[eclipse 3]: intsets([A,B,C],3,1,3),less(A,B),less(B,C).

A = A{([] .. [3, 2, 1]) : _483{0 .. 2} : ([] < [3, 1])}
B = B{([] .. [3, 2, 1]) : _582{[1, 2]} : ([1] < [3, 2])}
C = C{([] .. [3, 2, 1]) : _681{1 .. 3} : ([2] < [3, 2, 1])}

There are 18 delayed goals. Do you want to see them? (y/n)
Yes (0.00s cpu)

%
% The most obvious way of creating an intersection constraint fails.
% The name conflict suggests maybe I'm importing the library in the wrong
% way, since I'd expect there to be no conflicts in normal operation, but
% note that this conflict also occurs with ic_sets, which does work for me.
%

[eclipse 4]: intsets([A,B,C],3,1,3),intersection(A,B,C).
Ambiguous import of intersection / 3 from [eclipse_language,
ic_hybrid_sets] in module eclipse
calling an undefined procedure intersection(A, B, C) in module eclipse
Abort

%
% Okay, let's try explicitly specifying the module name.  This error seems
% to be the real problem:  something internal to the solver is broken when
% the constraint gets added.
%

[eclipse 5]: intsets([A,B,C],3,1,3),ic_hybrid_sets:intersection(A,B,C).
calling an undefined procedure add2_foreachevent(_691, e(_691,
'SUSP-_763-susp'), int_sets([](_425, _426, _427), [], [3, 2, 1], _407,
_408, _409, 0, 0, 3, _493, _494, ['SUSP-_717-sched'], ['SUSP-_728-sched'],
[], [], _467, _420, A), int_sets([](_524, _525, _526), [], [3, 2, 1],
_506, _507, _508, 0, 0, 3, _592, _593, ['SUSP-_740-sched'],
['SUSP-_751-sched'], [], [], _566, _519, B)) in module ic_hybrid_sets
Abort

%
% Digging into the source reveals that internally, the code uses
% intersect_lex/3 where the documentation would lead me to believe that
% intersection/3 would be right, so let's try that.  It produces the
% add2_foreachevent undefined error again.
%

[eclipse 6]: intsets([A,B,C],3,1,3),intersect_lex(A,B,C).
calling an undefined procedure add2_foreachevent(_658, e(_658,
'SUSP-_730-susp'), int_sets([](_392, _393, _394), [], [3, 2, 1], _374,
_375, _376, 0, 0, 3, _460, _461, ['SUSP-_684-sched'], ['SUSP-_695-sched'],
[], [], _434, _387, A), int_sets([](_491, _492, _493), [], [3, 2, 1],
_473, _474, _475, 0, 0, 3, _559, _560, ['SUSP-_707-sched'],
['SUSP-_718-sched'], [], [], _533, _486, B)) in module ic_hybrid_sets
Abort

%
% Another attempt: don't create a variable explicitly for the
% intersection, but use an intersection expression implicitly when setting
% the intersection's cardinality.  The documentation suggests this should
% also work, but it produces the error again.  This error really seems to
% be associated with creating an intersection constraint at all, not just
% with the specific way I attempt to do it.  Not shown here, but I get the
% same results attempting to create a union constraint.
%

[eclipse 7]: intsets([A,B,C],3,1,3),#(A/\B,1).
calling an undefined procedure add2_foreachevent(_796, e(_796,
'SUSP-_855-susp'), int_sets([](_407, _408, _409), [], [3, 2, 1], _389,
_390, _391, 0, 0, 3, _475, _476, ['SUSP-_809-sched'], ['SUSP-_820-sched'],
[], [], _449, _402, A), int_sets([](_506, _507, _508), [], [3, 2, 1],
_488, _489, _490, 0, 0, 3, _574, _575, ['SUSP-_832-sched'],
['SUSP-_843-sched'], [], [], _548, _501, B)) in module ic_hybrid_sets
Abort
[eclipse 8]:
bye


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% FOR COMPARISON
% Here's another session, using ic_sets to attempt the same things
% instead.  To the extent ic_sets has the same features, it works where
% ic_hybrid_sets doesn't.
%

%
% Solver loads okay
%

mskala_at_opal:~/multilex$
/usr/local/src/Eclipse_6.0_116/bin/i386_linux/eclipse
ECLiPSe Constraint Logic Programming System [kernel]
Kernel and basic libraries copyright Cisco Systems, Inc.
and subject to the Cisco-style Mozilla Public Licence 1.1
(see legal/cmpl.txt or www.eclipse-clp.org/licence)
Source available at www.sourceforge.org/projects/eclipse-clp
GMP library copyright Free Software Foundation, see legal/lgpl.txt
For other libraries see their individual copyright notices
Version 6.0 #116 (i386_linux), Fri Jan  8 23:33 2010
[eclipse 1]: lib(ic_sets).
source_processor.eco loaded in 0.02 seconds
hash.eco   loaded in 0.01 seconds
compiler_common.eco loaded in 0.03 seconds
compiler_normalise.eco loaded in 0.01 seconds
compiler_map.eco loaded in 0.01 seconds
compiler_analysis.eco loaded in 0.02 seconds
compiler_peephole.eco loaded in 0.02 seconds
compiler_codegen.eco loaded in 0.02 seconds
compiler_varclass.eco loaded in 0.02 seconds
compiler_indexing.eco loaded in 0.01 seconds
compiler_regassign.eco loaded in 0.02 seconds
asm.eco    loaded in 0.03 seconds
module_options.eco loaded in 0.01 seconds
ecl_compiler.eco loaded in 0.21 seconds
ic_kernel.eco loaded in 0.23 seconds
linearize.eco loaded in 0.01 seconds
ic_constraints.eco loaded in 0.05 seconds
ic.eco     loaded in 0.00 seconds
ic_generic_interface.eco loaded in 0.01 seconds
ic_search.eco loaded in 0.04 seconds
ic.eco     loaded in 0.35 seconds
ordset.eco loaded in 0.01 seconds
lists.eco  loaded in 0.01 seconds
notify_ports.eco loaded in 0.01 seconds
ic_sets.eco loaded in 0.44 seconds

Yes (0.45s cpu)

%
% I can create set variables, but this solver doesn't put lex bounds on
% them.
%

[eclipse 2]: intsets([A,B,C],3,1,3).

A = A{([] .. [1, 2, 3]) : _244{0 .. 3}}
B = B{([] .. [1, 2, 3]) : _326{0 .. 3}}
C = C{([] .. [1, 2, 3]) : _408{0 .. 3}}
Yes (0.00s cpu)

%
% Can't use the less/2 constraint, this solver doesn't support it.
%

[eclipse 3]: intsets([A,B,C],3,1,3),less(A,B),less(B,C).
calling an undefined procedure less(A, B) in module eclipse
Abort

%
% Just like with the other one, there is a name collision.
%

[eclipse 4]: intsets([A,B,C],3,1,3),intersection(A,B,C).
Ambiguous import of intersection / 3 from [eclipse_language, ic_sets] in
module eclipse
calling an undefined procedure intersection(A, B, C) in module eclipse
Abort

%
% But resolving the name collision with an explicit module name makes it
% work.  With ic_hybrid_sets it fails here.
%

[eclipse 5]: intsets([A,B,C],3,1,3),ic_sets:intersection(A,B,C).

A = A{([] .. [1, 2, 3]) : _458{0 .. 3}}
B = B{([] .. [1, 2, 3]) : _540{0 .. 3}}
C = C{([] .. [1, 2, 3]) : _622{0 .. 3}}

There are 6 delayed goals. Do you want to see them? (y/n)
Yes (0.00s cpu)

%
% The internal name intersect_lex isn't defined, understandably.
%

[eclipse 6]: intsets([A,B,C],3,1,3),intersect_lex(A,B,C).
calling an undefined procedure intersect_lex(A, B, C) in module eclipse
Abort

%
% The implicit intersection variable also works correctly.
%

[eclipse 7]: intsets([A,B,C],3,1,3),#(A/\B,1).

A = A{([] .. [1, 2, 3]) : _440{0 .. 3}}
B = B{([] .. [1, 2, 3]) : _522{0 .. 3}}
C = C{([] .. [1, 2, 3]) : _604{0 .. 3}}

There are 6 delayed goals. Do you want to see them? (y/n)
Yes (0.00s cpu)
[eclipse 8]:
bye

% BOTTOM LINE: ic_sets works.  ic_hybrid_sets doesn't work, but should.

-- 
Matthew Skala, postdoctoral researcher, Universities of Toronto and Waterloo
mskala_at_cs.toronto.edu    mskala_at_cs.uwaterloo.ca    mskala_at_ansuz.sooke.bc.ca
Received on Sat Jan 09 2010 - 18:12:28 CET

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