Hello everyone. I want to define the cardinal sine function,
sinc. I do it as follows:
def Sinc(x):
if x==0:
sinc = 1.0
else:
sinc = sin(x)/(x)
return sinc
I used this code in the past. However, I had to swich between computers and now I am getting the following error:
PyomoException: Cannot convert non-constant expression to bool. This error is usually caused by using an expression in a boolean context such as an if statement. For example,
m.x = Var()
if m.x <= 0:
...
would cause this exception.
The line in which I am using the expression is
def Wind_lammda_definition3(model, i):
return m.Wind_lammda[i,3]==32.07*Sinc(1.79*(-10. +m.lammda[i,3]*180/np.pi))*Sinc(2.09*(-40. + m.phi[i,3]*180/np.pi))
m.Wind_lammda_const3 = Constraint(m.N, rule = Wind_lammda_definition3)
I have no idea why this is happening now. Can it be a issue of version?
Please, any help is appreciated.
Best regards.
Jaime.