Skip to main content

Can we change the linear expression's lines randomly in gurobi ??



1 comment

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    It is quite hard to help here, because the snippets you provided are not reproducible.

    I would guess that it some identation + editor issue which is not correctly displayed. You should try using a backslash when you want to write multi line expressions in Python.

    lin_exp_2 = K * sum(
      z_dual[i, l].x * model.getVarByName('z_' + str(i) + '_' + str(l)) for l in L for i in range(N + 1)) \
    + K * sum(r_dual[i, j].x * model.getVarByName('r_' + str(i) + '_' + str(j)) for j in range(N+1) for i in range(N+1))

    If this does not help, you can always use parentheses to make sure that the whole expression is used instead of putting it into 1 long line.


Please sign in to leave a comment.