Skip to main content

How Can I Reduce The Value Of Coefficients for a Decision Variable?

Answered

Comments

4 comments

  • Jaromił Najman
    • Gurobi Staff Gurobi Staff

    You can adjust the objective coefficient of a linear variable via its Obj attribute, e.g.,

    ActionVar[1,1].Obj = 1

    Would this work?

    1
  • SB
    • Gurobi-versary
    • First Comment
    • First Question

    I am currently running it. Do I have to change the Obj attribute in the defining decision variable part?

    as in:

    ActionVar = {}
    for t in periods:
      for i in decision:
          ActionVar[t,i] = m.addVar(obj=1, vtype=GRB.BINARY)

    Funny thing, I no longer get the incremented coefficients in the display part. Unfortunately, it still takes too long for model to run.

    Also, since my model uses parameters that are very large, I have cropped my main dataframe in order to tried to see the model clearly, I noticed something in the stats part.

    When I run the model that is on a smaller scale, I get this result:

    m.printStats()
    Output:
    Statistics for model:
    Linear constraint matrix: 90 Constrs, 50 Vars, 280 NZs
    Variable types: 0 Continuous,
    50 Integer (50 Binary)
    Matrix coefficient range: [ 1, 1 ]
    Objective coefficient range: [ 1, 1 ]
    Variable bound range: [ 1, 1 ]
    RHS coefficient range: [ 1, 1 ]


    But when I run my model that is on a larger scale (actual model), I get this result when I run m.printStats():

    Statistics for model:
    Linear constraint matrix: 7706 Constrs, 3670 Vars, 148972 NZs
    Variable types : 0 Continuous, 3670 Integer (3670 Binary)
    Matrix coefficient range: [ 1, 3 ]
    Objective coefficient range : [ 1, 1 ]
    Variable bound range: [ 1, 1 ]
    RHS coefficient range: [ 1, 1 ]

    I noticed that Matrix Coefficient Range is = [1,3] a different range compared to smaller scaled model. How can I interpret this? I really really only cropped my dataframe I'm extracting the data, so I doubt it's caused by my data size.

     

    Thanks in advance!

    1
  • Jaromił Najman
    • Gurobi Staff Gurobi Staff

    Do I have to change the Obj attribute in the defining decision variable part?

    No this might not work in your case, because you create the objective afterwards. To be sure that all objective coefficients are set to 1 after you created your objective, you have to set the objective attribute of each variable

    #Objective Function
    m.setObjective(quicksum([ActionVar[t,i] for t in periods for i in decision]))
    m.modelSense = GRB.MINIMIZE

    for t in periods:
      for i in decision:
          ActionVar[t,i].Obj = 1

    I noticed that Matrix Coefficient Range is = [1,3] a different range compared to smaller scaled model. How can I interpret this?

    The matrix coefficient range means that there are coefficients between 1 and 3 in your linear coefficient matrix. You can use the write method to write an LP file and have a closer look at the model you built.

    m.write("myLP.lp")
    0
  • SB
    • Gurobi-versary
    • First Comment
    • First Question

    Hi, apologies for the late response. We have decided to use Lagrangian Relaxation to reduce the solving time, but not yet formed the updated obj function. This problem request can be closed. Thanks so much for your time and effort.

    0

Please sign in to leave a comment.