! The Department to Location Facility Assignment Problem(Dept2Locn);
 ! Given: 1) A set of Departments and a matrix of traffic between departments,						
          2) A set of Locations and a matrix of distances betweeen locations,						
  Assign Departments to Locations, at most one department per location,						
  so as to minimize total traffic*distance cost of the assignment.
  The "Departments" might be flights at at airport,
  The "Traffic" might be transfers between flights,
  The "Locations" might be gates at the terminal.
 Click on the Red Bullseye button to solve;			
!Keywords: Layout planning, Facility layout, Assignment, Quadratic assignment;
  LXL( LOCN, LOCN): DIST; ! Distance between departments;
  DXD( DEPT, DEPT): TRAF; ! Traffic between departments;
  DXL( DEPT, LOCN): D2L;  ! Dept to Locn assignment variable;
DATA: ! Read department names from open spreadsheet; DEPT = @OLE(); ! Read location names from open spreadsheet; LOCN = @OLE(); ! Get distance matrix between locations; DIST = @OLE(); ! Get traffic matrix between departments; TRAF = @OLE(); ENDDATA !--------------------------------------------------------; SETS: ! Warning: this set gets big fast; TGTG( DEPT, LOCN, DEPT, LOCN)| &1 #LT# &3 #AND# (( TRAF( &1, &3) #NE# 0) #AND# ( DIST( &2, &4) #NE# 0) #OR# ( TRAF( &3, &1) #NE# 0) #AND# ( DIST( &4, &2) #NE# 0)): Y; ENDSETS
! Variables: D2L(d, p) = 1 if department d is assigned to location or place p, Y(d,p,d2,p2) = 1 if d assigned to p, and d2 assigned to p2; ! Min the cost of transfers * distance; MIN = TRAFCOST; TRAFCOST = @SUM( TGTG( d, p, d2, p2): Y( d, p, d2, p2) * ( TRAF( d, d2) * DIST( p, p2) + TRAF( d2, d) * DIST( p2, p)) ;); ! Each department, or flight, d, must be assigned to a location or gate; @FOR( DEPT( d): @SUM( LOCN( p): D2L( d, p)) = 1; ); ! Each location, p, can receive at most one department; @FOR( LOCN( p): @SUM( DEPT( d): D2L( d, p)) <= 1; ); ! Force Y( d, p, d2, p2) = 1 if d assigned to p and d2 assigned to p2; ! Assumes the DIST() and TRAF() matrices are nonnegative; @FOR( TGTG( d, p, d2, p2): Y( d, p, d2, p2) > D2L( d, p) + D2L( d2, p2) - 1; ); ! Make the D2L's integer; @FOR( DXL: @BIN( D2L);); DATA: ! Send the solution back to the spreadsheet; @OLE() = D2L; ! Send the objective value back to the spreadsheet; @OLE() = TRAFCOST; ENDDATA END