Skip to main content

How to Assign a Value to a Decision Variable? + How to Constrain for a Subset of Variables



1 comment

  • Mario Ruthmair
    Gurobi Staff Gurobi Staff


    Why isn't SoC[0,0]+SoC[1,0] = 0.1 when it seems like SoC[0,1] was successfully assigned in initial value of 0.1 in the model?

    You set SoC[0,0] = 0.1.
    Then, you set SoC[0,0] = SoC[1,0]. This implies that also SoC[1,0] = 0.1, so the sum is of course 0.2.

    In the definition of your constraints it seems you forgot to add the "increment" in the updatedSoC constraints.

    I am not sure what exactly you want to model with your schedule-variables.
    If you want to know how to write constraints with sums of variables, then you should consider our documentation, tutorials, and examples, e.g.:

    Best regards,


Please sign in to leave a comment.