Skip to main content

Nonlinear Convex Objective (Natural Log)

Answered

Comments

1 comment

  • Ryuta Tamura
    • Gurobi Staff 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

Please sign in to leave a comment.