Correctness of a piecewise NL constraint

Hello everyone,

I’m trying to model the constraint defined as the following piecewise function:
in a model:

def _function(x): 
            condlist= [(x>=x1) & (x<x2),
                       (x>=x2) & (x<x3),
                       (x>=x3) & (x<=x4)]
            funclist= [lambda x: k1 * (x-x1) - high,
                       lambda x: CHF_base,
                       lambda x: k3 * (x-x3) + base]
            return np.piecewise(x, condlist, funclist)

The deterministic function outside the model seems to give expected results. But the implementation in the model (deflevel) in NLP form (using the sigmoid function) does not give the expected results (the variable ‘level’ should evolve according to ‘net_l’). The other hypothesis is that specific options are required for the solver.

Model link: https://github.com/Lere16/Sample.git

Any help you can give me would be a great help.
Thank you so much.

Hi,

You can provide solver options as a dictionary. For example:

m.solve(solver="CPLEX", solver_options={"dettilim": 10})