Hi,
I have an array of values
"number Quantity{Item}=[0 0 30 40 50 0 60 70]" and want to assign these values to another array Quantity2 and change the index to -2 so it should equal [30 40 50 0 60 70 0 0]. How to achive that with optmodel.
Here's one way:
proc optmodel;
set Item = 0..7;
number Quantity{Item}=[0 0 30 40 50 0 60 70];
number Quantity2{i in Item} = Quantity[mod(i+2,8)];
print Quantity Quantity2;
quit;
SAS Output
| [1] | Quantity | Quantity2 |
|---|---|---|
| 0 | 0 | 30 |
| 1 | 0 | 40 |
| 2 | 30 | 50 |
| 3 | 40 | 0 |
| 4 | 50 | 60 |
| 5 | 0 | 70 |
| 6 | 60 | 0 |
| 7 | 70 | 0 |
Thanks Rob,
what I am trying to achieve is to take the optimized quantity "Quantity", offset it x places, and give this output (Quantity) as an input to Quantity2, where I will run another optimization model on it Quantity2. " I assume I can have both in the same program?"
So Quantity is not actually a number it's a variable and I receive the following error when saying that
Quantity2{i in Item} = Quantity[mod(i+2,8)];
as Quantity is a var and Quantity2 is number
537-782 the value of parameter "Quantity2" depends on a variable
If Quantity is a variable, then it sounds like you want to declare Quantity2 as an implicit variable (by using the IMPVAR statement).
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!