alias(var2, var3);
The alias command introduces an alternative set name for an existing
set, and the new set will contain the same elements as the original.
eg set var2 /a, b, c/;
alias(var2, var3)
will result in 2 sets:
var2 with the elements a, b, c
var3 with the elements a, b, c
You can define more than 1 alias at a time if you want, eg alias(var2,
var3, myAlias4, myAlias5) etc
I suppose you can just think of it as a quick way to copy an existing
set.
\
parameter var1(var2) how much to step to the right from target;
var1 = 0.05;
This declares a parameter, which is the object you use in GAMS for
storing numbers. It is like an array in regular programming, except
you use sets as the index to get into them.
For example in other programming languages you might have an array
called myArray in which you are storing the price of each separate
item of clothing, and it might be something like
myArray[1] = 10.99 'item 1 is a pair of socks
myArray[2] = 20 'item 2 is a hat
myArray[3] = 34.99 'item 3 is a pair of jeans
myJeansCost = myArray[3] 'get the cost of a pair of jeans
In GAMS it is basically the same but you use sets as the index, and
the parameter as the array.
set clothing /socks, hat, jeans/;
myParameter(“socks”) = 10.99
myParameter(“hat”) = 20
myParameter(“jeans”) = 34.99
myJeansCost = myParameter(“jeans”) 'get the cost of a pair of jeans
You can also do bulk commands whereby you do the same command (rhs)
across every item in the set at once.
Eg
myParameter(clothing) = 1.99; 'out of business sale, everything is
1.99
I suspect this is what the following command is doing, although I have
not seen it done without the var1() before
var1 = 0.05;
You can also have parameters with more than 1 set, which is just like
a multi-dim array
eg myPrice(clothing,store) would be used if you had a different price
for each element of clothing depending on what store it was at.
myPRice(“socks”,“centralBusinessDistrict”) = 20.99;
myPRice(“socks”,“mall”) = 10.99;
\
parameter var4(var5) total inventory by var5;
This make a parameter/array called var4, with the var5 set as its
index. So you use the var5 elements to access/edit the numbers in the
var4 array.
var4(var5) = sum(stores, inventory_init(colors, stores)) +
sum(periods, warehouse_receipts(colors,periods)) +
sales_todate(colors);
This is populating the var4 parameter. Clearly there is something
else going on here as without some controlling outer loop this would
not compile _, so it may be a bulk insert
(ie every var5 element is going to get the same value), or the
controlling outer loop may be looping over each var5 element and it
might be different depending on what is happening in the outer loop.
Regardless the main point here is that the var4 parameter is getting a
numerical value calculated and inserting it for the (or all if bulk)
var5 element.
To understand the equation you will need to understand the sum
function.
sum(, parameter())
This will sum all the parameter values for each element in .
In normal array programming this would be like:
loop (i = 1 to 3)
temp = temp + myArrayendloop
In our clothing example above sum(clothing, myParam(clothing)) is the
same as:
myParam(‘socks’) + myParam(‘hat’) + myParam(‘jeans’)
it is sums myParam for every element in the clothing set.
You can sum over more than 1 set as well
eg sum((clothing,store), myPrice(clothing,store)) will sum myPrice for
every element of clothing at every store.
In your case there is clearly something else going on as not all of
your sets are controlled.
eg >> sum(stores, inventory_init(colors, stores))
this sums inventory_init(colors, stores) for every store. However it
does not know what colors to use (the colors set is not controlled) so
it will not compile.
You may find an outer loop above this where it is looping over each
colour element
eg loop (colors) do
temp1 = sum(stores, inventory_init(colors, stores))
endloop;
in this case the loop goes through each color 1 by 1, and for each of
these individual colors temp1 will be the sum of the inventory at all
stores for that colour. temp1 will NOT be the total sum across all
colours, the outer loop does each color element 1 at a time. So
effectively the colors element is fixed (eg it is say blue) when the
sum command is undertaken, so the temp1 = sum… command will look at
every store, but only for the blue (say) one.
Hopefully the above helps answer your next question also:
\
what does model,loop option do?
I think you mean: loop (set) do… ?
It loops over each element in the set.
For example
file myfile /myfilename.txt/;
loop (clothing) do
put myfile "item of clothing: " clothing.tl ’ write the current set
element out to file
endloop
putclose myfile;
will result in the following:
item of clothing: socks
item of clothing: hat
item of clothing: jeans
Note that inside the loop, the particular element of clothing is fixed
at whatever element it is currently at, ie it is either socks or hat
or jeans. The other clothing elements cannot be accessed inside the
clothing set.
so something like
file myfile /myfilename.txt/;
loop (clothing) do
temp1 = myParam(clothing); ’ wrote:
hi,
i am a new user who is working with existing GAMS code and getting it
converted to another language
because of the restrictions avaiable i cant even install gams at my
place and do some research.
can some one please explain to me in genral terms what the following
does
alias(var2, var3);
parameter var1(var2) how much to step to the right from target;
var1 = 0.05;
parameter var4(var5) total inventory by var5;
var4(var5) = sum(stores, inventory_init(colors, stores)) +
sum(periods, warehouse_receipts(colors,periods)) +
sales_todate(colors);
what does model,loop option do?
which is the best procedure in SAS for nlp IP solver used in GAMS
–~–~---------~–~----~------------~-------~–~----~
To post to this group, send email to gamsworld@googlegroups.com
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en
-~----------~----~----~----~------~----~------~–~—
_