! Assignment model.
We have a set of tasks to be performed, and
a set of operators, each of whom can do one task, and
a COST(i,j) of having task i done by operator j.
We want to find an assignment of tasks to operators that
minimizes total cost.
The Assignment problem is a special case of the Transportation problem;
! Keywords: Assignment, Task Assignment;
SETS:
TASK ;
OPERATOR;
LINK( TASK, OPERATOR): COST, X;
ENDSETS ! Here are the data;
DATA:
! The names of the tasks;
TASK = T1 T2 T3 T4 T5 T6;
! The traditional assignment problem has
number of operators = number of tasks,
but that is not crucial.
The names of the operators.;
OPERATOR= P1 P2 P3 P4 P5 P6 P7 P8;
! The cost of assigning operator j (column)
to task i (row);
COST = 6 2 6 7 4 2 5 9
4 9 5 3 8 5 8 2
5 2 1 9 7 4 3 3
7 6 7 3 9 2 7 1
2 3 9 5 7 2 6 5
5 5 2 2 8 1 4 3;
! Data can be retrieved from a spreadsheet with
statements like TASK = @OLE( );
! if a) the appropriate spreadsheet is open in Excel, and
b) there is an appropriate range named TASK in the spreadsheet;
ENDDATA
SUBMODEL ASSIGN:
! Minimize the cost of the assignment;
MIN = TCOST;
TCOST = @SUM( LINK( i, j):
COST( i, j) * X( i, j));
! Each operator can do at most one task;
@FOR( OPERATOR( j):
@SUM( TASK( i): X( i, j)) <= 1;
);
! Each task must be done;
@FOR( TASK( i):
@SUM( OPERATOR( j): X( i, j)) = 1;
);
ENDSUBMODEL
CALC:
@SET('TERSEO', 2); ! Ask for Terse output, (0 = default);
@SOLVE( ASSIGN);
@WRITE('A Task Assignment Problem.',@NEWLINE(1));
@WRITE(' The assignments are:',@NEWLINE(1), ' Task Operator Cost', @NEWLINE(1));
@FOR( LINK(i,j) | X(i,j) #GT# 0.5:
@WRITE(' ',TASK(i),' ', OPERATOR(j),' ',COST(i,j),@NEWLINE(1));
);
@WRITE(' Cost of the assignment= ', TCOST, @NEWLINE(1));
ENDCALC
|