Advertisement
Guest User

Untitled

a guest
Jul 21st, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.71 KB | None | 0 0
  1.  
  2. ;Declaration
  3.  
  4. Local $a_Block[rows][properties] ; an imported array of storage rows with each their own number of pallets and total space
  5. ;$a_block[row][0] = number of pallets stored in the storage row
  6. ;$a_block[row][1] = maximum storage spaces in this row
  7. Local $Total_space = 0
  8. Local $Number_of_pallets = 0
  9. Local $a_Rows_to_be_filled[UBound($a_Block, 1)]; declare an onedimensional array with same number of indices as the imported array
  10.  
  11. ;/declaration
  12.  
  13. For $i = 0 To UBound($a_Block, 1) - 1 ; for all rows in array $a_block
  14.     $Total_space += $a_Block[$i][1] ; add the current row's total space to the total space
  15.     $Number_of_pallets += $a_Block[$i][0] ; add current row's number of pallets to total number of pallets
  16. Next
  17.  
  18. _ArraySort($a_Block, Default, Default, Default, 1)
  19. ; sort the array on maximum storage spaces, smallest first
  20. ;secondary sort all the rows with same number of maximum storage space by number of pallets stored with the biggest number of pallets first
  21.  
  22. For $i = 0 To UBound($a_Block, 1) - 1 ; for all rows in array $a_block
  23.     If ($Total_space - $Number_of_pallets) > $a_Block[$i][1] And $Number_of_pallets > 0 Then
  24.         ;check if we can free up space by filling this row/check for end-of-loop
  25.  
  26.         $a_Rows_to_be_filled[$i] = 1; set the local array so we know the row can be completly filled
  27.         $Total_space -= $a_Block[$i][1] ; substract the filled row from maximum storage space
  28.         $Number_of_pallets -= $a_Block[$i][1] ; subtract the number of pallets we used to fill that row
  29.     Else
  30.         $a_Rows_to_be_filled[$i] = 0
  31.         ReDim $a_Rows_to_be_filled[$i] ; shrinks array to needed size
  32.         Return $a_Rows_to_be_filled ; end function and return the array with rows that can be optimised
  33.     EndIf
  34. Next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement