I'm implementing a simple model in Minizinc to schedule tasks with different priority and duration in a series of time slots, but not all the tasks can be scheduled so some will be left out and I'm trying to maximize the sum of priorities of the scheduled tasks.
I have a working version where the tasks is defined in a array of vars, and non-scheduled tasks have time 0. The constrains have several where clauses to take into account only the scheduled tasks (when[i]>0). The default search strategy is very slow so I changed it to another that worked much better, using Gecode as solver.
Now I'm implementing a different version using optional variables, to get rid off the where clauses, to check if there is any improvement. However, it seems I cannot define a search strategy int_search() when using opt var.
Is there any way to do it?
The working model is as follows (the solve clause with the search strategy I want to try is commented out):
int: numtasks=100;
int: numslots=100;
set of int: TASK=1..numtasks;
set of int: SLOT=1..numslots;
array[TASK] of var opt 1..numslots: when;
array[TASK] of int: duration = [(i mod 3)+1 | i in TASK];
array[TASK] of int: prio = [(i mod 10)+1 | i in TASK];
include "globals.mzn";
constraint disjunctive(when, duration);
var int: obj = sum(i in TASK where not absent(when[i]))(prio[i]);
%solve ::int_search(when, input_order, indomain_random, complete) maximize obj;
solve maximize obj;
output [show(obj)," ",show(when)];
I'm not sure if this is the best approach, but can test using "occurs()" inside "int_search", i.e.
solve ::int_search([occurs(when[t]) | t in TASK], input_order, indomain_random, complete) maximize obj;
Also, I recommend that you test with some other labelings than input_order/indomain_random, e.g. first_fail/indomain_split etc.
/Hakan