MiniZinc / libminizinc

The MiniZinc compiler
http://www.minizinc.org
Other
508 stars 79 forks source link

2.8.2: inconsistent behavior of many globals on empty arrays #770

Open matsc-at-sics-se opened 10 months ago

matsc-at-sics-se commented 10 months ago

IMHO, the following models should silently succeed:

include "globals.mzn";
constraint sliding_sum(0, 0, 0, []);
include "globals.mzn";
constraint symmetric_all_different([]);
include "globals.mzn";
constraint subcircuit([]);
include "globals.mzn";
constraint bin_packing_capa([], [], []);
include "globals.mzn";
constraint bin_packing_load([], [], []);
include "globals.mzn";
constraint bin_packing(0, [], []);
include "globals.mzn";
constraint circuit([]);
include "globals.mzn";
constraint decreasing([]);
include "globals.mzn";
constraint increasing([]);
include "globals.mzn";
constraint disjunctive([], []);
include "globals.mzn";
constraint inverse([], []);

and the following should silently fail:

include "globals.mzn";
constraint let {var int: W} in member([], W);

but:

For circuit and subcircuit, the semantics is not obvious. Is a circuit with no nodes still a circuit?

zayenz commented 10 months ago

I agree that it should be defined clearly what semantics are given to empty arrays for all the cases that you mention.

For circuit in particular, Gecode elects to not define the semantics for empty arrays and that is why it fails noisily. I think that that is a reasonable choice to make for Gecode when used from C++. However, that should really not be exposed from MiniZinc, the case of an empty array should be handled in a manner that is consistent with what MiniZinc thinks the semantics should be. I will defer any changes on the Gecode side until we have some guidance.

Cheers, Mikael

On Mon, Dec 18, 2023 at 11:12 AM Mats Carlsson @.***> wrote:

IMHO, the following models should silently succeed:

include "globals.mzn"; constraint sliding_sum(0, 0, 0, []);

include "globals.mzn"; constraint symmetric_all_different([]);

include "globals.mzn"; constraint subcircuit([]);

include "globals.mzn"; constraint bin_packing_capa([], [], []);

include "globals.mzn"; constraint bin_packing_load([], [], []);

include "globals.mzn"; constraint bin_packing(0, [], []);

include "globals.mzn"; constraint circuit([]);

include "globals.mzn"; constraint decreasing([]);

include "globals.mzn"; constraint increasing([]);

include "globals.mzn"; constraint disjunctive([], []);

include "globals.mzn"; constraint inverse([], []);

and the following should silently fail:

include "globals.mzn"; constraint let {var int: W} in member([], W);

but:

  • sliding_sum, symmetric_all_different, increasing, decreasing, inverse fail noisily
  • symmetric_all_different fails noisily
  • subcircuit succeeds silently with Gecode but fails noisily with Chuffed and OR-Tools
  • bin_packing and friends, disjunctive, knapsack give evaluation errors during flattening
  • circuit crashes Gecode and fails noisily with Chuffed and OR-Tools
  • member fails silently with Gecode but noisily with Chuffed and OR-Tools

For circuit and subcircuit, the semantics is not obvious. Is a circuit with no nodes still a circuit?

— Reply to this email directly, view it on GitHub https://github.com/MiniZinc/libminizinc/issues/770, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB34ZX6UHEYTIFOIDEMVNDYKAJHFAVCNFSM6AAAAABAZIL7XSVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA2DMMRWGA3TINA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Mikael Zayenz Lagerkvist