Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Solving takes ages when a var opt int is used to output #132
When running this simple solver on MiniZinc 2.1.2 (in the IDE), with the default Geocode solver, it gets me a very quick optimal solution as long as I don't try to output the obj variable (a var opt int). When I add it either through the output statement or by annotating it with ::add_to_output, the solver runs forever without finding a single solution. The code below runs without problem if I remove var from the obj declaration, and adds a "deopt" to the expression to make it a non-var.
This is from Workshop 2 "Surrender" of the Coursera "Basic Modeling for Discrete Optimization" course.
`% workshop 2
int: l; % minimum party size
array[NEGOTIATOR] of int: honor;
var set of NEGOTIATOR: party::add_to_output;
% cardinality of the party is between l and u
% sum of pairs joint must be greather than m
% maximize the honor of the party (the min of all members)
solve maximize obj;
output ["party = (party)\nobj = (obj)"];`
This is not a bug. As long as you don't specify a search strategy, the solver needs to guess which variables to search over, and it uses the fact whether variables are output or not to guess. Sometimes that guess can be quite bad. Just adding ::set_search([party],input_order,indomain_min,complete) will fix it.