I have constructed a pyomo code in which I calculate the weighted mean of 3 vectors as
def meanX_definition(model, i):
return m.meanX[i] ==(m.x1[i]+4*m.x2[i]+m.x3[i])/6
m.meanX_const = Constraint(m.N, rule = meanX_definition)
And then, I have calculated the variance as
def varX_definition(model, i):
return m.varX[i] ==((m.x1[i]-m.meanX[i])**2+ 4*(m.x2[i]-m.meanX[i])**2+(m.x3[i]-m.meanX[i])**2)/6
m.varX_const = Constraint(m.N, rule = varX_definition)
Since my model is a stochastic one, I want to put restrictions as x1, x2 and x3 have to be localidez between the mean and +-2 standard deviations.
For that, I have attempted to calculate the standard deviation as
def stdX_definition(model, i):
return m.desvestX[i] == sqrt(m.varX[i])
m.stdX_const = Constraint(m.N, rule = stdX_definition)
and
def stdX_definition(model, i):
return m.desvestX[i] == m.varX[i]**(0.5)
m.stdX_const = Constraint(m.N_notinitial_notfinal, rule = stdX_definition)
I have also tried to define the standard deviation at all points but the first and the last in case the error was the standard deviation of 0 at [0] and [n], since the start and endpoints are the same for all 3 vectors.
Unfortunately, an error occurs ApplicationError: Solver (ipopt) did not exit normally
. Can someone please tell me how to fix it so I can get the standard deviation?