Skip to main content

How to extract numerical values from the LinExpr objects

Answered

Comments

1 comment

  • 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

Please sign in to leave a comment.