eyeprolog 1.3.73 → 1.3.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/lib/clpz.pl +33 -10
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.3.73",
6
+ "version": "1.3.74",
7
7
  "description": "EyeProlog turns facts and rules into answers and proofs.",
8
8
  "type": "module",
9
9
  "main": "./index.js",
package/src/lib/clpz.pl CHANGED
@@ -2248,10 +2248,15 @@ all_different([X|Right], Left, Orig) -->
2248
2248
  all_distinct(Ls) :-
2249
2249
  fd_must_be_list(Ls, all_distinct(Ls)-1),
2250
2250
  maplist(fd_variable, Ls),
2251
- make_propagator(pdistinct(Ls), Prop),
2252
- new_queue(Q0),
2253
- phrase((distinct_attach(Ls, Prop, []),trigger_prop(Prop),do_queue), [Q0], _),
2254
- variables_same_queue(Ls).
2251
+ % A ground list needs validation, but no attributed propagator.
2252
+ ( ground(Ls) ->
2253
+ sort(Ls, Distinct),
2254
+ same_length(Ls, Distinct)
2255
+ ; make_propagator(pdistinct(Ls), Prop),
2256
+ new_queue(Q0),
2257
+ phrase((distinct_attach(Ls, Prop, []),trigger_prop(Prop),do_queue), [Q0], _),
2258
+ variables_same_queue(Ls)
2259
+ ).
2255
2260
 
2256
2261
  %% nvalue(?N, +Vars).
2257
2262
  %
@@ -6707,10 +6712,21 @@ serialize_upper_bound(I, D_I, J, D_J, MState) -->
6707
6712
 
6708
6713
  element(N, Is, V) :-
6709
6714
  must_be(list, Is),
6710
- length(Is, L),
6711
- N in 1..L,
6712
- element_(Is, 1, N, V),
6713
- propagator_init_trigger([N|Is], pelement(N,Is,V)).
6715
+ % A constant table is one extensional relation; expanding it into
6716
+ % reified implications and a second propagator is needlessly costly.
6717
+ ( maplist(integer, Is) ->
6718
+ element_relation(Is, 1, Relation),
6719
+ tuples_in([[N,V]], Relation)
6720
+ ; length(Is, L),
6721
+ N in 1..L,
6722
+ element_(Is, 1, N, V),
6723
+ propagator_init_trigger([N|Is], pelement(N,Is,V))
6724
+ ).
6725
+
6726
+ element_relation([], _, []).
6727
+ element_relation([V|Vs], N, [[N,V]|Relation]) :-
6728
+ N1 is N + 1,
6729
+ element_relation(Vs, N1, Relation).
6714
6730
 
6715
6731
  element_domain(V, VD) :-
6716
6732
  ( fd_get(V, VD, _) -> true
@@ -6799,8 +6815,15 @@ global_cardinality(Xs, Pairs, Options) :-
6799
6815
  ).
6800
6816
 
6801
6817
  keys_costs(Keys, X, Row, C) :-
6802
- element(N, Keys, X),
6803
- element(N, Row, C).
6818
+ % Keys and matrix rows are integers here. Zip them once instead of
6819
+ % connecting two element/3 constraints through an auxiliary index.
6820
+ keys_cost_relation(Keys, Row, Relation),
6821
+ tuples_in([[X,C]], Relation).
6822
+
6823
+ keys_cost_relation([Key|Keys], [Cost|Costs], [[Key,Cost]|Relation]) :-
6824
+ keys_cost_relation(Keys, Costs, Relation).
6825
+ keys_cost_relation([], _, []).
6826
+ keys_cost_relation([_|_], [], []).
6804
6827
 
6805
6828
  gcc_pair(Pair) :-
6806
6829
  ( Pair = Key-Val ->