[eclipse-clp-users] Instantiation fault in bb_min with non-default strategy

From: Sergii Dymchenko <kit1980_at_...6...>
Date: Fri, 13 Mar 2015 12:39:08 -0700
Hi,
I wrote a blog post about solving PuzzlOR "Electrifying" puzzle with
ECLiPSe: http://sdymchenko.com/blog/2015/03/13/electrifying-eclipse/

While solving the puzzle I encountered and issue with bb_min and strategies
other than the default one.

Consider this program (basically the same program as in the blog post
linked):

:- lib(ic).
:- lib(branch_and_bound).
solve(HouseXs, HouseYs, K, GenXs, GenYs, Cost) :-
    dim(HouseXs, [N]),
    MaxX #= max(HouseXs), MaxY #= max(HouseYs),
    dim(GenXs, [K]), dim(GenYs, [K]),
    GenXs :: 1..MaxX, GenYs :: 1..MaxY,
    ( for(I, 1, N), foreach(Di, Distances), param(HouseXs, HouseYs, GenXs,
GenYs, K) do
        ( for(J, 1, K), fromto(1.0Inf, Dprev, Dcurr, Di), param(I, HouseXs,
HouseYs, GenXs, GenYs) do
            Dcurr $= min(Dprev, sqrt(sqr(HouseXs[I] - GenXs[J]) +
sqr(HouseYs[I] - GenYs[J])))
        )
    ),
    Cost $= sum(Distances),
    bb_min(search([](GenXs, GenYs), 0, most_constrained, indomain_middle,
complete, []), Cost, bb_options{delta:0.1, strategy:dichotomic}).

main :-
    HouseXs = [](2, 2, 3, 3, 4, 4,  5, 5, 5, 5, 6, 6, 7, 7, 8, 8, 8, 9, 9,
10),
    HouseYs = [](2, 5, 6, 8, 2, 10, 2, 3, 6, 8, 1, 5, 2, 8, 5, 7, 8, 4, 7,
3),
    solve(HouseXs, HouseYs, 3, GenXs, GenYs, _Cost),
    ( foreacharg(X, GenXs), foreacharg(Y, GenYs) do
        LetterCode is 0'A + Y - 1,
        char_code(Letter, LetterCode),
        write(X), write(Letter), nl
    ).

With strategy:dichotomic I get:

Found a solution with cost 67.5083636407248__67.50836364072498
Found no solution with cost 0.0 .. 33.75418182036249
instantiation fault in 33.75418182036249 =< _325826{49.307233137943534 ..
49.30723313794369}
abort

There is a similar issue with strategy:restart, but the program works OK
with the default continue strategy.
Is this an ECLiPSe bug?

-Sergii.
Received on Fri Mar 13 2015 - 19:39:14 CET

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:30 CEST