Minizinc - Task Assignment with distances - Sorting Arrays with decision variables

48 Views Asked by At

I have two decision variables to assign tickets to techs:

  1. x describes which tech is assigned to each ticket
  2. y descripes the priority of each ticket, i.e. defines the order of execution
int: nTechs;
int: nTickets;
set of int: TECHNIKER = 1..nTechs;
set of int: TICKETS = 1..nTickets;

array[TICKETS] of var 0..nTechs: x;
array[TICKETS] of var TICKETS: y;

I now want to optimize the distances the techs have to drive between the locations of the tickets. Therefore I have a distance matrix for ticket-to-ticket:

array[TICKETS, TICKETS] of int: distancesTicketsToTickets;

The issue I have is to iterate through the tickets for each tech in the correct order y.


Example:

  • Ticket1 assigned to Tech1
  • Ticket2 assigned to Tech1
  • Ticket3 assigned to Tech1
  • Priority of Ticket1 = y[1] = 1
  • Priority of Ticket2 = y[2] = 3
  • Priority of Ticket3 = y[3] = 2

In this case, using the given priorities, I have to calculate the total distance with:

distance := (Ticket1 to Ticket3) + (Ticket3 to Ticket2)

Can you help me how to write the distance function? I keep failing with the sorting-operations in Minizinc.

I tried using arg_sort, sort, sort_by but I kept failing with the issue of using decision variables and having optional return types.

0

There are 0 best solutions below