メインコンテンツへスキップ

Can get the value of LinExpr for dictionary type?

回答済み

コメント

8件のコメント

  • Silke Horn
    Gurobi Staff Gurobi Staff

    Could you give us some more information about what exactly you are trying to do and what you need help with? Do you need help getting the values? (Both LinExpr and QuadExpr have a getValue method.) What are the keys of your dictionary?

    0
  • bert li
    Gurobi-versary
    First Comment
    First Question

    I have tried to use getValue method , but I can't get the value

     

     

    0
  • Silke Horn
    Gurobi Staff Gurobi Staff

    Which are the expressions for which you want to get the values?

    Please note that you are using the variable name s twice (in the outer loop and in the loop inside quicksum) while i will be undefined. Maybe the inner loop should be over i instead?

    0
  • bert li
    Gurobi-versary
    First Comment
    First Question

    I‘m sorry.It's my mistake.

    And I want to get the value of A[s].If I print it directly,I get a expression involve parameter like this.

    This expression is not my objective function.And I don't know the method that document given us how to use. So I can't get the value of the expression. Thank you for your patient.

    0
  • Silke Horn
    Gurobi Staff Gurobi Staff

    You can call getValue on the A[s]. E.g.

    for s in range(2):

        print(A[s].getValue())

     

    Note though that you first need a solution for this. I.e., you should first call optimize on your model.

    0
  • bert li
    Gurobi-versary
    First Comment
    First Question

    I have optimized the model and used your method.But the result like this.

    0
  • Silke Horn
    Gurobi Staff Gurobi Staff

    Could you please show a complete code sample?

    0
  • bert li
    Gurobi-versary
    First Comment
    First Question

    Thanks a lot, I have solved it .

    0

サインインしてコメントを残してください。