def whether_get_opt_sln()

in Vehicle Routing Problem/src/baseline_model.py [0:0]


def whether_get_opt_sln(env, prev_o_status, prev_o_xy, current_action_plan):
    ''' Ask for a new solution if
        1 - A new order has arrived
        2 - An order has expired (not delivered)
        @annaluo 3 - All actions executed
    '''

    # get_new_solution = False
    # If any new orders has arrived
    new_orders = [o for o in range(env.n_orders) if prev_o_status[o] == 0 and env.o_status[o] == 1]
    if new_orders:
        print("New order has arrived!")
        return True

    if len(current_action_plan) == 0:
        return True

    for o in range(env.n_orders):
        # If we plan to accept but the order has changed
        # Add here if the restaurant has changed as well
        if o + 1 in current_action_plan and (((env.o_x[o], env.o_y[o]) != prev_o_xy[o])):
            print("Order", o + 1, "we were planning to accept has changed. Resolving the opt problem.")
            return True

    return False