Correctness of a piecewise NL constraint

Problems with modeling
Post Reply
Posts: 5
Joined: 3 months ago

Correctness of a piecewise NL constraint

Post by Maclean16 »

Hello everyone,

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

Code: Select all

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:

Any help you can give me would be a great help.
Thank you so much.
Posts: 3
Joined: 4 months ago

Re: Correctness of a piecewise NL constraint

Post by msoyturk »


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

Code: Select all

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