=================== O R D E R D I F F =================== The Order Diff algorithm determines the "delta" between two order lists; that is, it identifies the placements, cancellations, and modifications required for converting an old list into a new list. If it finds an old order "similar" to some new order, it modifies the old order to obtain the new order. If an old order is not similar to any new orders, it cancels this order. If a new order is not similar to any old order, it places this order. Currently, we consider two orders "similar" if they are for the same event, same vendor, and same item type. We may later change the similarity definition based on the user feedback. -= Input and output =- Input: Old order list, new order list Output: List of order changes The output does not include utilities of placements, modifications, and cancellations. The system later calls the Utility Calc algorithm to compute these utilities. -= Main steps =- Create empty Placement-List and Modification-List Create Old-List, which initially includes all old orders For every New-Order in the list of new orders: Search for Old-Order in Old-List that is identical to New-Order If not found, search for Old-Order in Old-List that is similar to New-Order If an identical Old-Order is found, then remove it from Old-List Else, if a similar Old-Order is found: Remove Old-Order from Old-List Add modification of Old-Order into New-Order to Modification-List Else, add placement of New-Order to Placement-List Create Cancellation-List that includes all orders from Old-List Create the list of order changes, by combining Placement-List, Cancellation-List, and Modification-List Return the resulting list