Omar
Omar

Reputation: 1

how to retrieve certain values from a varaibles?

I am developing a pricing model, where I need to determine the price of selling electricity. The pricing scheme should determine three pricing values where each value corresponds to a pricing period. Each pricing period consist of a set of number of hours (let's simplify it 8 hours). However, even though, the price of each period is constant over the period, there is an electricity demand which changes on hourly basis. therefore, the demand values of each period should be have the same price.

Based on that, I defined the following sets

Sets
j Time of Use Tariff Sectors /Industrial, Water/
k Time Periods /1*8760/
p Pricing Periods in Time of Use Tariff /1*3/
d Number of Days in a Year /1*365/
h Number of Hours in a Period /1*8/;

I have defined a variable called Demand_ToU (j,k) and as you can see it is indexed for two sectors (Industrial, Water) and each time period (from 1 to 8760) because these sector have to consume each hour. Also, I have defined also a variable called Price_ToU (j,p) and it is indexed for two sectors but only for three pricing periods, which resembles the time of use tariff, which means I need to apply the three pricing periods on all demand values (which are indexed with k).

In addition, I have defined 365 days (d), each day has 24 hours as you know. - I have divided the day into 3 equal periods (p) (1,2,3). - Each period will then have 8 hours, where each hour has its own value of demand_ToU (that's why I have defined demand_ToU(j,k)). However, these periods will repeat over the whole year (365 days) and I will always use the same pricing values for the periods (1,2,3). In other words, the first period (let's day the first eight hours) of each day, I will use always use p1.

Accordingly, to be able to call the right index value of Demand_ToU (j,k), I defined a equation [j, p-1+8*(d-1)+h] to help me find the right demand.value for each pricing period,

then, I added a function to calculate the total bills as follows:

Total_Bills.. B=e=sum((j,p),Price_ToU(j,p))*(sum(d,h),Demand_ToU(j,((p-1)*8+(d-1)*24+h)));

but I receive the following error,

Total_Bills.. B=e=sum((j,p),Price_ToU(j,p))*(sum(d,h),Demand_ToU(j,((p-1)*8+(d-1)*24+h)));
                                                        **** $148,8,409
**** 8 ')' expected
**** 148 Dimension different - The symbol is referenced with more/less
**** indices as declared
**** 409 Unrecognizable item - skip to find a new statement
**** looking for a ';' or a key word to get started again

I would be grateful if anybody could help me on these errors,

p.s. there are parts of the code, but I have excluded them to keep the question short

Upvotes: 0

Views: 41

Answers (1)

Roman
Roman

Reputation: 1

I think the issue is in considering the contents of p, d and h as numerical values, which they are not.

p, d and h are sets. Set elements (called "labels" in GAMS) do not have any numerical value.

For instance, p /1*3/ creates 3 labels: '1', '2' and '3'. p-1 has the meaning of taking the previous label from the set relative to the current p index. It doesn't retrieve the current value of p less one.

(p-1)*8 on the other hand has no meaning, which is probably why the interpreter throws the error messages at that place.

You might want to associate parameters with the set elements, as parameters do have numerical values. As an alternative, you could experiment with the set .val attribute (I have personally never used this feature) - see GAMS documentation ('Labels').

Upvotes: 0

Related Questions