Solved

# Index domain with certain indices without mentioning separate set

• 22 views

+2
• Enthusiast

Hi,

I am trying to write a constraint with index domain on certain indices

vBinary1('1') + vBinary1('3') + vBinary1('5') = 3 * vBinary2;

‘h’ is the index. Here ‘h’ is taking value {‘1’, ‘3’, ‘5’}. Do not consider it as ODD.

I tried with

```

index domain: | h in {"1", "3", "5"}

sum[h, vBinary1(h)] = 3 * vBinary2;

```

It is giving errors by saying

The scope of index "h" has not been specified. Help to understand it.

Do not define another set for these indices only. That I know how to do it.

icon

Best answer by gdiepen 4 April 2024, 08:33

View original

Userlevel 5
+7

Not sure what you want to achieve.

You want to write the constraint using a sum without defining another set for just these indices? Isn’t it just easier to write the original line you had?

Otherwise it will be just a bit more complex, something like:

sum( h | (h = ‘1’) or (h=’3’) or (h=’5’) , vBinary1(h) ) = 3*vBinary2