Modeling trigonometric constraints
AnsweredDear Comunity,
I can model the COS constraint y = cos (x) using the general constraint in Python, but I don't know if there is possible to model the following nonlinear constraint:
pl = k cos (d1 - d2)
Where pl, d1, d2 are variables, and k is a constant value.
I look forward to hearing your comments and support.
Regards,
Victor
0
-
Hi Victor,
You can take advantage of auxiliary variables:
- Define an auxiliary variable \(z\) and add the constraint \(z = d_1 - d_2\).
- Define another auxiliary variable \(y\) and add the constraint \(y = \cos(x)\) using the Model.addGenConstrCos() method
- Add the constraint \(p_l = k y\)
An alternative to step 2) and 3) is to use the Model.addGenConstrPWL() method and implement \(p_l = k \cos(z)\) using supporting points for \(z\) and \(p_l\).
Best regards,
Maliheh
0 -
Thank you so much for your message and support.
Best Regards,
Victor
0 -
Isn't it y = cos(z) ?
0
Please sign in to leave a comment.
Comments
3 comments