Solved

# Why I can't constrain the objective variable with inequality？

• 2 replies
• 35 views +4
• Enthusiast
• 14 replies

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?

icon

Best answer by Marcel Hunting 7 April 2023, 14:40

View original

### 2 replies

Userlevel 5 +4

Hi @Chunyang. AIMMS (automatically) determined that the model type of your model is Constraint Programming which means that your model contains some nonlinear terms. Did you add nonlinear terms on purpose?

For Constraint Programming all variables must be integer (or binary) except for the objective variable which must be a continuous (i.e., real valued) variable. However, if you add an inequality constraint with the objective variable in it then AIMMS will create a new artificial objective variable underneath and the (old) objective variable is treated as a normal variable; Constraint Programming does not allow this.

If you want to use nonlinear terms in combination with integer and continuous variables then you should change the model type of the mathematical program to MINLP. +4

Thanks a lot!