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

NotImplementedError:

回答済み

コメント

1件のコメント

  • Maliheh Aramon
    • Gurobi Staff

    Hi, 

    There are a number of issues with the code snippet

    1) Based on the documentation, the input to the Gurobi general constraint max_() should be a Var, a list of Var, or a tupledict of Var. In your snippet, the input to this function is a list of tupledict of Var objects. 

    2) The variables \(z\) do not depend on the scenario number \(j\). It is not clear why you are redefining them for each scenario number. 

    3) The Gurobi Optimizer does not know what \(a\) represents. You need to first define it as a decision variable and then add a constraint to force it to represent the maximum value of the \(z\) variables.

    4) The Gurobi Optimizer does not support strict inequality constraints. It should be \(\geq\) and not \(>\).

    Please see the modified snippet below.

    z = mod.addVars(number_scenario, vtype = GRB.CONTINUOUS)
    for
    j in number_scenario: mod.addConstr(z[j] == gp.quicksum(x[i] * p[j][i] for i in number_asset))
    a = mod.addVar(name="a") mod.addConstr(a == gp.max_(z)) mod.addConstr(a >= initial_value)

    Best regards,

    Maliheh

    0

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