The objective variable is A(t) contains t = 1 to 24.

The mathematical program is to maximize the sum of all the elements in A, i. e. Max sum(A(t)), t = 1 to 24.

At the same time I hope to constrain the property of the objective variable that the standard deviation SD(A) is no larger than a constant “a”. So I defined a variable “SD(A) = standard deviation of A”. Then a constraint “SD(A) <= a”.

When I run the program, it reminds me of “*constraint programming constraints cannot be used in combination with real valued variables, only with integer valued variables, element valued variables, and activities. The real valued objective variable is an exception. The mathematical program has both constraint programming constraints and real valued variables.*”

However, when I revise the constraint from inequality to equality, i.e. SD(A) = a. Then no error arises and I get the answer.

Why dose this happen? And How can I deal with it if I want the inequality constraint?