Solved

# How to get ranges for specific values of variables

• 2 replies
• 67 views

Userlevel 1
• Ace
• 8 replies

Hello, everyone！Now I have a problem about how to set ranges for specific values of a variable.

I have a variable “Cmatrix(t,x,conv) ” and “t,x,conv” are some sets.  I need that Cmatrix(t,x,conv) ∈ [-1,1] only when conv ≠ 'Heat_pump' . And Cmatrix(t,x,conv) >1 only when conv = 'Heat_pump'.

How do I write this in the red box?

When I set a constraint to bound the “Cmatrix(t,x,conv) ”, there will be errors as “The solver CONOPT 4.1 cannot handle the ranged constraint Cmatrix_except_HP(1,Elec,CHP_engine) in mathematical program "Cost_minimization"; please define the middle term as a variable and add bounds.”

Can some kind person save me? Thank you so so so much! Wish you happy every day.

icon

Best answer by gdiepen 14 March 2022, 20:43

View original

### 2 replies

Userlevel 5
+7

Wouldn’t it be an option to use the range attribute?

You could create a parameter cMatrix_lowerbound(conv)  and parameter cMatrix_upperbound(conv) that have definition based on the equality to ‘Heat_pump’. In the cMatrix variable, you would then use these lowerbound and upperbound  parameters in the range (if you open  the wizard you will be able to select them)

Userlevel 1

Wouldn’t it be an option to use the range attribute?

You could create a parameter cMatrix_lowerbound(conv)  and parameter cMatrix_upperbound(conv) that have definition based on the equality to ‘Heat_pump’. In the cMatrix variable, you would then use these lowerbound and upperbound  parameters in the range (if you open  the wizard you will be able to select them)

Thank you so much！