Skip to main content

Quicksum in constraint leads to too many nonzeros

Ongoing

Comments

2 comments

  • Eli Towle
    Gurobi Staff Gurobi Staff

    The degradation at timestep 2 is the sum of degradation at timestep 0 and 1, etc.

    Your constraints set the degradation equal to the sum of the weighted statuses at previous timesteps. Do you mean the degradation at timestep 2 is the sum of the weighted statuses (not degradations) at previous timesteps?

    If I understand your problem correctly, an equivalent, sparser formulation would set the degradation at time \( t \) equal to the degradation at time \( t - 1 \) plus \( c \) times the status at time \( t - 1\). I don't know exactly how you define your Python variables, but something like this should work:

    model.addConstr(deg[0] == 0)
    for t in T[1:]:
    model.addConstr(deg[t] == deg[t - 1] + c * z[t - 1])

     

    0
  • Pieter Degeling
    First Question
    First Comment

    Hi Eli,

    Thanks so much for your quick response, it is really appreciated. I think this works perfectly!

    In this context, the coefficient c translates the on-off status to a degradation penalty. In my actual model, I defined various operations that lead to different degradation mechanisms. One of these is a penalty (degradation) for being on, described by c*z.
    The sum of degradation due to the various mechanisms leads to a degradation status for each timestep.
    In this example, the term 'sum of weighted statuses' is equal to the term 'total degradation'.

    Thanks again.

    Best regards,
    Pieter

    0

Please sign in to leave a comment.