Page 1 of 1

Correctness of a piecewise NL constraint

Posted: Sat Feb 24, 2024 3:06 pm
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: https://github.com/Lere16/Sample.git

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

Re: Correctness of a piecewise NL constraint

Posted: Thu Mar 07, 2024 2:57 pm
by msoyturk
Hi,

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

Code: Select all

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