Solved

# How can I use part of an index

+4

Like one day have 24 hours, I need to calculate the variables for 24 periods, but these variables are defined by 25 points, so I define the index t as “25”.

For example variable A contains 24 elements, A(1) = B(2)-B(1)…...A(24)=B(25)-B(24).

If I define an index “t” as 25, I can simply define the B as B(t) using t (1 to 25) as the domain. But How can i define A which only contains 24 elements, actually from 1 to 24, can I use part of t domain from 1 to 24?

Hi @Chunyang. You can use the domain condition t | t <> last(Periods) in the index domain of A:

``Set Periods {    Index: t;    Definition: {        { 1 .. 25 }    }}Variable B {    IndexDomain: t;    Range: nonnegative;}Variable A {    IndexDomain: t | t <> last(Periods);    Range: nonnegative;}``

### 2 replies

Userlevel 5
+4

Hi @Chunyang. You can use the domain condition t | t <> last(Periods) in the index domain of A:

``Set Periods {    Index: t;    Definition: {        { 1 .. 25 }    }}Variable B {    IndexDomain: t;    Range: nonnegative;}Variable A {    IndexDomain: t | t <> last(Periods);    Range: nonnegative;}``

+4

Hi @Chunyang. You can use the domain condition t | t <> last(Periods) in the index domain of A:

``Set Periods {    Index: t;    Definition: {        { 1 .. 25 }    }}Variable B {    IndexDomain: t;    Range: nonnegative;}Variable A {    IndexDomain: t | t <> last(Periods);    Range: nonnegative;}``

Thanks a lot!