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

Nonlinear Convex Objective (Natural Log)

回答済み

コメント

1件のコメント

  • Ryuta Tamura
    • Gurobi Staff

    Hi Ethan,

    As you saw in the error, Gurobi accepts a linear or quadratic function as the objective function. NLExpr is only available for constraints. However, you can use auxiliary variables to set the nonlinear function to the objective function like follows:

    # x,y are arguments to log(x+y)
    # z = log(x+y)
    model.addConstr(z == nlfunc.log(x+y))
    model.setObjective(z)

    Thanks,
    Ryuta

    1

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