Hi everyone,
I’m trying to formulate constraints involving sine and cosine functions applied to the difference of angles in buses of electrical power systems. I identified a problem with calculating the cosine of the difference between two angles when they correspond to the same variable.
I reduced the model to a simple formulation in which trying to calculate y=cos(t-t)
leads to y=0, instead of y=1. However, using y=cos(t-t*0.999999)
leads to the correct value y=1.
I’m using AMPL Version 20230228 with Artelys Knitro 13.2.0 and CONOPT 3.17A. Please find an example of this behavior in the model below. Alternatives 1 and 2 produce y=0, while alternative 3 results in y=1.
Do you have any idea of why this is happening?
reset;
option solver conopt;
option solver knitro;
option knitro_options 'feastol=1e-15';
var t;
var y;
minimize calculation: y^2;
subject to def:
y = cos(t-t); # alternative 1
# y = cos(t-t*0.99999999999999999); # alternative 2
# y = cos(t-t*0.9999999999999999); # alternative 3
solve calculation;
display y;