Solved

how to write a definition of variable

  • 12 March 2020
  • 4 replies
  • 91 views

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] = 0.3

X[1] = X[0] + Y[1]

X[2] = X[1] + Y[2]

….

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

Userlevel 5
Badge +2

I would try:

0.3 $ (Ord(t) = 1)

+

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

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

Userlevel 5
Badge +5

@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)

….

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

Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator