Skip to main content

Proper way to use big-M method

Awaiting user input

Comments

7 comments

  • Riley Clement
    Gurobi Staff Gurobi Staff

    Hi Dong Hyun Kim,

    I’m encountering issues, and it seems like this constraint is not functioning as expected.

    Can you give details of what you expect vs what you are observing?

    - Riley

    0
  • Dong Hyun Kim
    Conversationalist
    First Question
    for d in range(drone):
        for i in range(1, num_orders + 1):
            model.addConstrs(battery_level[i+num_orders, d] >= battery_level[i, d] - e*time_drone[i, f] + charging_rate*time_vehicle[f, l]
            - e*time_drone[l, i+num_orders] - M*(5 - battery_need[i, d] - D[i, f, d] - D[f, l, d] - D[l, i+num_orders, d] - X[f, l, v])
                             for f in range(1, 2*num_orders+1) for l in range(1, 2*num_orders+2) for v in range(vehicle))

    In my optimization model, when a drone reaches a pickup node (let’s denote it as a node i) but does not have enough battery to proceed directly to the corresponding delivery node (i + num_orders), it needs to locate an active vehicle to follow. The idea is that the drone can travel with the vehicle, using its route temporarily to recharge along the way. Once the drone’s battery is sufficiently recharged, it can leave the vehicle and continue on to the delivery node (i + num_orders).

    The above constraint aims to update the drone's battery level as it moves along this coordinated route with the vehicle. In particular, the Big-M method is used here to capture different scenarios:

    • If the drone has enough battery to go from the pickup node to the delivery node, it does so directly.
    • If the drone lacks sufficient battery, then battery_need[i, d] = 1 becomes active, causing the drone to divert temporarily to follow the active vehicle’s path (X[f, l, v]), recharge, and then return to complete the original delivery.

    However, the current model isn’t producing the intended results. In some cases, the drone flies directly to the final depot after visiting the pickup node i, or the model returns as infeasible. My goal is for the drone to follow an optimized path, such as:

    • if battery_need[2, 0] = 1 & D[j, 2, 0] = 1 then D[2, 5, 0] -> D[5, 10, 0] (where it recharges on the route segment X[5, 10, 1] with the vehicle) -> D[10, 7, 0].
    0
  • Riley Clement
    Gurobi Staff Gurobi Staff

    Ok, so if I understand correctly, it's not that the "constraint isn't functioning as expected", it's that your model just isn't correct yet?

    0
  • Dong Hyun Kim
    Conversationalist
    First Question

    I think that’s likely the case. I’ve been working on refining the model continuously, but it hasn’t been going well, which is why I wanted to ask for some guidance. I’ll give it some more try and reach out again if I have further questions.

    0
  • Riley Clement
    Gurobi Staff Gurobi Staff

    I'd suggest starting with a tiny version of your problem, so that you can write the LP file out and inspect it - is it what you would expect?  Then try fixing variables to the solution you'd expect and see if it's valid.  If not there is a constraint which is wrong.  If it is valid then you're missing a constraint (or a constraint is not strong enough).

    You may find some useful tips here:
    How do I diagnose a wrong result?

    1
  • L Yan
    First Comment

    Hello Riley,

    Currently can we use generative-AI for complicated constraints and big-M parameters?

    Thanks. 

    0
  • Riley Clement
    Gurobi Staff Gurobi Staff

    Hi L Yan,

    Gen AI can be useful to a degree. Can you give us a bit more detail? Is your idea to use Gen AI for complicated constraints motivated by saving time, or where it is difficult to create the constraints yourself? By big-M parameters are you referring to PreSOS1BigM and PreSOS2BigM, or something else?

    - Riley

    0

Please sign in to leave a comment.