"Stop After this Many Optimal Solutions" --> ALWAYS greyed out

25 views
Skip to first unread message

David Lloyd

unread,
Oct 30, 2025, 8:57:12 AMOct 30
to MiniZinc
% Define the variables var int: x; var int: y;
% Define the domain for the variables constraint 1 <= x; constraint x <= 5; constraint 1 <= y; constraint y <= 5;
% Constraint that links the variables constraint x + y >= 5;
% Objective function: minimize the sum of x and y. % The minimum possible sum is 1 + 1 = 2. % However, the constraint x+y >= 5 forces the minimum sum to be 5. % Multiple pairs (x, y) satisfy x+y = 5 (e.g., (1, 4), (2, 3), (3, 2), (4, 1)).
% Output the solution output ["x = ", show(x), "; y = ", show(y), "; Sum = ", show(x + y), "\n"];
solve satisfy;

There are several ways this can be 5 which is the minimum:

1+4, 3+2, 2+3 etc.

If I change it to:

solve minimize x+y;

No matter the solver I try to use, it just refuses to ungrey that toggle.

MiniZinc IDE 2.9.4 on Windows
20730142


David Lloyd

unread,
Oct 30, 2025, 8:58:58 AMOct 30
to MiniZinc
% Apparently copy/paste is STUPID - this is the formatted file.

% Define the variables
 
var int: x; 
var int: y;

% Define the domain for the variables 
constraint 1 <= x; 
constraint x <= 5; 
constraint 1 <= y; 
constraint y <= 5;

% Constraint that links the variables 
constraint x + y >= 5;
% Objective function: minimize the sum of x and y. % The minimum possible sum is 1 + 1 = 2. % However, the constraint x+y >= 5 forces the minimum sum to be 5. % Multiple pairs (x, y) satisfy x+y = 5 (e.g., (1, 4), (2, 3), (3, 2), (4, 1)). 

solve minimize x + y;
% Output the solution
output ["x = ", show(x), "; y = ", show(y), "; Sum = ", show(x + y), "\n"];

guido.tack

unread,
Nov 5, 2025, 8:29:26 PMNov 5
to MiniZinc
This option is only available if the backend solver supports it (i.e., it understands the "-a-o" command line option). I don't think any of the standard solvers that comes bundled with MiniZinc supports this at the moment.

Cheers,
Guido

Reply all
Reply to author
Forward
0 new messages