# GUROBIO 11 - Support for Nonlinear Function

**URL:** <https://discuss.ampl.com/t/gurobio-11-support-for-nonlinear-function/844>\
**Category:** Support\
**Tags:** solvers\
**Created:** [December 5, 2023, 8:17pm UTC](https://discuss.ampl.com/t/gurobio-11-support-for-nonlinear-function/844 "2023-12-05T20:17:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![prat](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@prat](https://discuss.ampl.com/u/prat)\
**Post date:** [December 5, 2023, 8:17pm UTC](https://discuss.ampl.com/t/gurobio-11-support-for-nonlinear-function/844/1 "2023-12-05T20:17:55Z")

</div>

Hello,

The new Gurobi solver (Gurobi 11) supports some nonlinear functions, such as the logarithmic or the logistic ones.  
I would like to know whether this functionaliy is available through AMPL. and what AMPL keywords can be used to instruct Gurobi to consider (maximize) a logistic function for example. Can you tell me where I can find some documentation about this?  
Best regards,  
Pratim

---

<div class="post-metadata">

**Author:** ![4er](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/4er/32/530_2.png) [@4er](https://discuss.ampl.com/u/4er)\
**Post date:** [December 7, 2023, 11:45pm UTC](https://discuss.ampl.com/t/gurobio-11-support-for-nonlinear-function/844/2 "2023-12-07T23:45:01Z")

</div>

Gurobi 11 still has the default behavior of using piecewise-linear approximation for nonlinear functions, but you can set options to globally optimize instead. Here is a little example:

```auto
var x;
minimize f: 0.2*x^2 + 1/(1+exp(-x));
subj to bounds: -1 <= x <= 1;

```

This is the solution with no options set:

```auto
Gurobi 11.0.0: optimal solution; objective 0.4260218562
394 simplex iterations
35 branching nodes
 
f = 0.4262241326
x = -0.584057913

```

(Due to the p-l approximation, the objective value returned by Gurobi is a little different from the objective value computed by AMPL at the solution returned by Gurobi.)

To request global optimization, set the Gurobi option funcnonlinear to 1, by giving the command

```auto
option gurobi_options 'funcnonlinear=1';

```

before solving (or if you are already defining a gurobi\_options string, by adding ‘funcnonlinear=1’ to it.) Then Gurobi gives the following results:

```auto
Gurobi 11.0.0: optimal solution; objective 0.4262087102
33 simplex iterations
18 branching nodes
absmipgap=6.49552e-06, relmipgap=1.52402e-05

f = 0.4262087102
x = -0.575911649

```

Note that AMPL does not have a built-in logistic function, so you need to give an expression like `1/(1+exp(-x))` for it.
