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

Creating a relaxed version of my model

回答済み

コメント

1件のコメント

  • Riley Clement
    • Gurobi Staff

    Hi Miriana,

    Your code:

    for i in range(nr):
        u[i].setAttr('vtype', 'C')

    is doing what is it supposed to do.

    You can see this by running

    for i in range(nr):     
       print(u[i].vType)

    after calling m.update().

    At the optimal solution the values of u are 0 or 1 - regardless of whether u is declared binary or not.  This can be seen by setting the u variables to be continuous right from the start and solving:

    u = m.addVars(nr, vtype=gp.GRB.CONTINUOUS, name="u")

    Will u variables take binary values in every feasible solution?  Perhaps.  Some MILP models produce polyhedra which are naturally integral and the solution to the LP is the solution to the MILP.  Although your model does not produce a polyhedron that is integral in general, it may be integral when projected onto the u variables (i.e. with respect to the u variables).

    - Riley

    0

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