Correctness of a piecewise NL constraint
Posted: Sat Feb 24, 2024 3:06 pm
Hello everyone,
I'm trying to model the constraint defined as the following piecewise function:
in a model:
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.
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.