Solved

# how to write a definition of variable

• 4 replies
• 87 views

• Newcomer
• 3 replies

Dear all

I have two variables: X and Y with index domain t.

I want to write in definition of X such as

X = 0.3

X = X + Y

X = X + Y

….

How do I write in definition part of variable X ? Please help me

Thank you so much

icon

Best answer by mateusarakawa 12 March 2020, 18:24

View original

### 4 replies

this command is easy to understand and useful. Thank you a lot @mohansx

Userlevel 5 +2

@Huy , as your condition is dependent on the index domain and not on a variable, you could also use an if block in the definition of variable x(t).

`if ord(t) = 1 then`

`0.3`

`else`

`x(t-1) + y(t)`

`endif`

This will generate the below constraints - assuming that the elements in set T are {0,1,2,3,...}

`x(0) = 0.3`

`x(1) = x(0) + y(1)`

`x(2) = x(1) + y(2)`

`….`

It is very helpful. Thank you very much, @mateusarakawa

Userlevel 5 +2

I would try:

0.3 \$ (Ord(t) = 1)

+

x(t-1) + y(t) \$ (Ord(t) > 1)