Skip to main content

How to extract numerical values from the LinExpr objects

Answered

Comments

2 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support.
  • Marika Karbstein
    • Gurobi Staff

    You are creating the Gurobi model when defining the list simulated_lossed. That means there is no solution value for the x variables. Mathematical operations on the x-variables give you linear expressions. But getValue() is not possible as long as the model is not solved.

    Hence, the list simulated_lossed contains linear expressions that depend on the model variables x.
    Now, you can define linear constraints on the expressions. In the documentation Constraints - Gurobi Optimization you can see which type of constraints are possible and can be added to a Gurobi model.
    You can define for example min and max constraints (see also Model.addGenConstrMin() and Model.addGenConstrMax() ). But there is no such thing as a sorting constraint.
    So what you try to achieve is not possible.
    Try to formulate your problem with variables and constraints based on the documentation Variables and Constraints and Objectives.

    0

Post is closed for comments.