% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0 %-----------------------------------------------------------------------------% % The following program aborts with the following when compiled in a (declarative) % debugging grades using rotd-2007-08-25. % % Software Error: map.lookup: key not found % Key Type: term.var(parse_tree.prog_data.prog_var_type) % Key Value: var(37) % Value Type: ll_backend.var_locn.var_state % % This test case is derived from the module % g12/zinc/src/runtime/zinc_fdic_solver.m on % G12's ZINC_MODULAR_BACKEND change branch % (path: $G12ROOT/branches/changes/ZINC_MODULAR_BACKEND) % The revision was r6690. % %-----------------------------------------------------------------------------% :- module zinc_fdic_solver. :- interface. :- type ss ---> ss. :- type ic_var ---> ic_var. :- type fd_var ---> fd_var. :- type solve0 == pred(ss, ss). :- inst solve0_nondet == (pred(mdi, muo) is nondet). :- type solve(T) == pred(T, ss, ss). :- inst solve_nondet == (pred(out, mdi, muo) is nondet). :- type sense ---> minimise ; maximise. %-----------------------------------------------------------------------------% :- typeclass zinc_solver(Solver, I) <= ((Solver -> I), int_var(I)) where [ pred solve(Solver::in, zb_solve_kind::in, pred(ss, ss)::pred(mdi, muo) is nondet) : solve0 `with_inst` solve0_nondet ]. :- typeclass int_var(I) where []. :- type zb_solve_kind ---> zb_satisfy ; zb_minimize_int(zt_int) ; zb_maximize_int(zt_int) . :- type zt_int ---> some [I] iv(I) => int_var(I). %-----------------------------------------------------------------------------% :- type fdic_solver. :- instance zinc_solver(fdic_solver, fd_var). :- instance int_var(fd_var). :- pred get_fdic_solver(fdic_solver::out) is det. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% :- implementation. :- import_module int. :- import_module list. :- import_module pair. :- import_module univ. %-----------------------------------------------------------------------------% :- type fd_solver_instance ---> fd_solver_instance. :- type fdic_solver ---> fdic_solver. get_fdic_solver(fdic_solver). :- instance zinc_solver(fdic_solver, fd_var) where [ (pred(solve/5) is my_fdic_solve) ]. :- pred my_fdic_solve(fdic_solver::in, zb_solve_kind::in, pred(ss, ss)::pred(mdi, muo) is nondet) : solve0 `with_inst` solve0_nondet. my_fdic_solve(_, SolveKind, CustomSearch, !SS) :- ( SolveKind = zb_satisfy, CustomSearch(!SS) ; ( SolveKind = zb_minimize_int(OptE), Sense = minimise ; SolveKind = zb_maximize_int(OptE), Sense = maximise ), OptE = iv(I), type_to_univ(I, Univ), det_univ_to_type(Univ, FDV:fd_var), Solver = fd_solver_instance, Search = (pred(DSVarsValues::out, !.SS::mdi, !:SS::muo) is nondet :- CustomSearch(!SS), DSVarsValues = dsvars_values([], []) ), my_branch_and_bound(Search, Sense, Solver, FDV, _Value, !SS) ). %-----------------------------------------------------------------------------% :- pred my_branch_and_bound(solve(T)::in(solve_nondet), sense::in, S::in, V::in, int::out, ss::mdi, ss::muo) is semidet. my_branch_and_bound(_, _, _, _, 10, !SS) :- semidet_true. :- instance int_var(fd_var) where []. %-----------------------------------------------------------------------------% :- type dsvars_values ---> dsvars_values( fdvs :: list(pair(fd_var, int)), icvs :: list(pair(ic_var, float)) ).