Freigeben über


Arithmetics on indexes in OML

Here is the link to the original post (thank Shahar for posting the trick). The trick to make arithmetics valid on Decision/Parameter indexes in OML is to declare the Sets on which the indexes are defined as Integers. Here is the OML model that illustrates how arithmetics is done.

Model[

  //define the set as an Integer

  Parameters[Sets[Integers], Month],

  Parameters[Reals, param[Month]],

 

  Decisions[Reals, decision[Month]],

 

  // You can use FilteredForeach if you want to make sure you don't get non existing month

  Constraints[

    FilteredForeach[{i,Month}, i > 1, decision[i] * param[i] >= decision[i - 1] ]

  ]

]

Parameter "param" is bound to the spreadsheet that has the following table.

Month

param

1

20

2

21

3

22

4

23

5

24

6

25

7

26

8

27

9

28

10

29

11

30

12

31

The Excel workbook of this sample is available as the attachment of this post.

- Lengning Liu

IntegerSetIndexes.xlsx

Comments