Predecessor/Sucessor

Hello,

I’m new to GAMS (although not new to MIP programming) and hope I can
find help for a problem a currently have.

I have variables with two indices, e.g. x(d,h), where d and h are sets
of days and hours.

My problem is to make a predecessor/sucessor relation between those x
variables. E.g. I have to model the difference between two neighboring
x variables like:

delta(d,h) =e= x(d,h) - x(pred(d,h)) ;

delta(d,) =l= constant ;

Are there any ideas how to make this in an easy and elegant way?

Regards,
Daniel
–~–~---------~–~----~------------~-------~–~----~
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
-~----------~----~----~----~------~----~------~–~—

\

Daniel,

The GAMS lingo for this is lag and lead operators: x(d,h-1) e.g. shows
the previous hour. The ‘-’ is not a numercial minus but a lag. Trouble
is that the predecessor for x(d,‘h1’) is x(d-1,‘h24’). You also have
to decide what predecessor of ‘d1’,‘h1’ is. If you do a steady state
model you could have ‘d365’,‘h24’ or you can decide that there is no
predecessor (meaning delta(‘d1’,‘h1’) = x(‘d1’,'h1)). I am assuming
your sets look like this

set d / d1d365 /
h / h1
h24 /

Now here is what you can do:

delta(d,h) =e= x(d,h) - x(d-(1$sameas(‘h1’)),h–1)) ;

Not so elegant, but it will work. I prefer working with an additional
set of all hours in the year:
and a map between d,h and all hours in the year:

sets h /h1h24/, d /d1d365/, dh(d,h) /#d.#h/
sets t /t1*t8760/, tdh(t,d,h) /#t:#dh/, dht/#dh:#t/

This matching operators (. and :slight_smile: are new syntax and will work with
22.7 and higher. You can do the maps also with older GAMS statements.
Now I would have the variable x and delta over t and then the
constraint looks simple:

delta(t) =e= x(t) - x(t-1) (or x(t–1) for steady state)

In case you have data by d,h you can use the map tdh, for example:

delta(t) =l= sum(tdh(t,d,h), maxdeviation(d,h));

Hope this helps,
Michael Bussieck, GAMSWorld Admin




On Jul 18, 4:24 am, Daniel wrote:

Hello,

I’m new to GAMS (although not new to MIP programming) and hope I can
find help for a problem a currently have.

I have variables with two indices, e.g. x(d,h), where d and h are sets
of days and hours.

My problem is to make a predecessor/sucessor relation between those x
variables. E.g. I have to model the difference between two neighboring
x variables like:

delta(d,h) =e= x(d,h) - x(pred(d,h)) ;

delta(d,) =l= constant ;

Are there any ideas how to make this in an easy and elegant way?

Regards,
Daniel
–~–~---------~–~----~------------~-------~–~----~
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
-~----------~----~----~----~------~----~------~–~—

\

Hello,

Thanks for you help. Very nice solution, but I was a little bit short
sighted and therefor I need a little more help.

I have data that is given with respect to sets d and h and my
variables are indexed by d and h, too. I need this because I have
constraints like this

con1(d,h)… xdmin =l= sum(d, x(d,h) ) ;
con2(d,h)… xdmax =g= sum(d, x(d,h) ) ;

on the other hand I also have the already mentionend constraints like,
where the lag/lead operators are needed.

con3a(t)… x(t) =e= x(t-1) + delta_i(t) - delta_d(t) ;
con3b(t)… deltamax =g= delta_i(t) + delta_d(t) ;

Is there a way to use the sets tdt and dht (of the previous message)
to ‘convert’ the indices?

Regards,
Daniel

On 18 Jul., 11:16, Gamsworld Admin wrote:

Daniel,

The GAMS lingo for this is lag and lead operators: x(d,h-1) e.g. shows
the previous hour. The ‘-’ is not a numercial minus but a lag. Trouble
is that the predecessor for x(d,‘h1’) is x(d-1,‘h24’). You also have
to decide what predecessor of ‘d1’,‘h1’ is. If you do a steady state
model you could have ‘d365’,‘h24’ or you can decide that there is no
predecessor (meaning delta(‘d1’,‘h1’) = x(‘d1’,'h1)). I am assuming
your sets look like this

set d / d1d365 /
h / h1
h24 /

Now here is what you can do:

delta(d,h) =e= x(d,h) - x(d-(1$sameas(‘h1’)),h–1)) ;

Not so elegant, but it will work. I prefer working with an additional
set of all hours in the year:
and a map between d,h and all hours in the year:

sets h /h1*h24/, d /d1*d365/, dh(d,h) /#d.#h/
sets t /t1*t8760/, tdh(t,d,h) /#t:#dh/, dht/#dh:#t/

This matching operators (. and :slight_smile: are new syntax and will work with
22.7 and higher. You can do the maps also with older GAMS statements.
Now I would have the variable x and delta over t and then the
constraint looks simple:

delta(t) =e= x(t) - x(t-1) (or x(t–1) for steady state)

In case you have data by d,h you can use the map tdh, for example:

delta(t) =l= sum(tdh(t,d,h), maxdeviation(d,h));

Hope this helps,
Michael Bussieck, GAMSWorld Admin

On Jul 18, 4:24 am, Daniel wrote:

Hello,

I’m new to GAMS (although not new to MIP programming) and hope I can
find help for a problem a currently have.

I have variables with two indices, e.g. x(d,h), where d and h are sets
of days and hours.

My problem is to make a predecessor/sucessor relation between those x
variables. E.g. I have to model the difference between two neighboring
x variables like:

delta(d,h) =e= x(d,h) - x(pred(d,h)) ;

delta(d,) =l= constant ;

Are there any ideas how to make this in an easy and elegant way?

Regards,
Daniel
–~–~---------~–~----~------------~-------~–~----~
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
-~----------~----~----~----~------~----~------~–~—

\

Daniel,

These statement would not compile (summation set d already controlled
on the equation index):

con1(d,h)… xdmin =l= sum(d, x(d,h) ) ;
con2(d,h)… xdmax =g= sum(d, x(d,h) ) ;

I guess you have

con1(h)… xdmin =l= sum(d, x(d,h) ) ;
con2(h)… xdmax =g= sum(d, x(d,h) ) ;

(don’t know if this makes sense).

You have to select one domain for your variable x. You used t and d,h.
I think you can savely work with just t. Assuming that the change from
above makes sense, you can rewrite these as follows:

con1(h)… xdmin =l= sum(tdh(t,d,h), x(t) ) ;
con2(h)… xdmax =g= sum(tdh(t,d,h), x(d,h) ) ;

Hope this makes sense to you.

Regards,
Michael Bussieck, GAMSWorld Coordinator
On Jul 23, 9:24 am, Daniel Wagner wrote:

Hello,

Thanks for you help. Very nice solution, but I was a little bit short
sighted and therefor I need a little more help.

I have data that is given with respect to sets d and h and my
variables are indexed by d and h, too. I need this because I have
constraints like this

con1(d,h)… xdmin =l= sum(d, x(d,h) ) ;
con2(d,h)… xdmax =g= sum(d, x(d,h) ) ;

on the other hand I also have the already mentionend constraints like,
where the lag/lead operators are needed.

con3a(t)… x(t) =e= x(t-1) + delta_i(t) - delta_d(t) ;
con3b(t)… deltamax =g= delta_i(t) + delta_d(t) ;

Is there a way to use the sets tdt and dht (of the previous message)
to ‘convert’ the indices?

Regards,
Daniel

On 18 Jul., 11:16, Gamsworld Admin wrote:

Daniel,

The GAMS lingo for this is lag and lead operators: x(d,h-1) e.g. shows
the previous hour. The ‘-’ is not a numercial minus but a lag. Trouble
is that the predecessor for x(d,‘h1’) is x(d-1,‘h24’). You also have
to decide what predecessor of ‘d1’,‘h1’ is. If you do a steady state
model you could have ‘d365’,‘h24’ or you can decide that there is no
predecessor (meaning delta(‘d1’,‘h1’) = x(‘d1’,'h1)). I am assuming
your sets look like this

set d / d1d365 /
h / h1
h24 /

Now here is what you can do:

delta(d,h) =e= x(d,h) - x(d-(1$sameas(‘h1’)),h–1)) ;

Not so elegant, but it will work. I prefer working with an additional
set of all hours in the year:
and a map between d,h and all hours in the year:

sets h /h1*h24/, d /d1*d365/, dh(d,h) /#d.#h/
sets t /t1*t8760/, tdh(t,d,h) /#t:#dh/, dht/#dh:#t/

This matching operators (. and :slight_smile: are new syntax and will work with
22.7 and higher. You can do the maps also with older GAMS statements.
Now I would have the variable x and delta over t and then the
constraint looks simple:

delta(t) =e= x(t) - x(t-1) (or x(t–1) for steady state)

In case you have data by d,h you can use the map tdh, for example:

delta(t) =l= sum(tdh(t,d,h), maxdeviation(d,h));

Hope this helps,
Michael Bussieck, GAMSWorld Admin

On Jul 18, 4:24 am, Daniel wrote:

Hello,

I’m new to GAMS (although not new to MIP programming) and hope I can
find help for a problem a currently have.

I have variables with two indices, e.g. x(d,h), where d and h are sets
of days and hours.

My problem is to make a predecessor/sucessor relation between those x
variables. E.g. I have to model the difference between two neighboring
x variables like:

delta(d,h) =e= x(d,h) - x(pred(d,h)) ;

delta(d,) =l= constant ;

Are there any ideas how to make this in an easy and elegant way?

Regards,
Daniel- Hide quoted text -

Hi, I’m affraid that I’m not who answer the message, there must be another Daniel at Gamsworld
Best regards

2008/7/25 Gamsworld Admin


Daniel,

These statement would not compile (summation set d already controlled
on the equation index):

con1(d,h)… xdmin =l= sum(d, x(d,h) ) ;
con2(d,h)… xdmax =g= sum(d, x(d,h) ) ;

I guess you have

con1(h)… xdmin =l= sum(d, x(d,h) ) ;
con2(h)… xdmax =g= sum(d, x(d,h) ) ;

(don’t know if this makes sense).

You have to select one domain for your variable x. You used t and d,h.
I think you can savely work with just t. Assuming that the change from
above makes sense, you can rewrite these as follows:

con1(h)… xdmin =l= sum(tdh(t,d,h), x(t) ) ;
con2(h)… xdmax =g= sum(tdh(t,d,h), x(d,h) ) ;

Hope this makes sense to you.

Regards,
Michael Bussieck, GAMSWorld Coordinator
On Jul 23, 9:24 am, Daniel Wagner wrote:

Hello,

Thanks for you help. Very nice solution, but I was a little bit short
sighted and therefor I need a little more help.

I have data that is given with respect to sets d and h and my
variables are indexed by d and h, too. I need this because I have
constraints like this

con1(d,h)… xdmin =l= sum(d, x(d,h) ) ;
con2(d,h)… xdmax =g= sum(d, x(d,h) ) ;

on the other hand I also have the already mentionend constraints like,
where the lag/lead operators are needed.

con3a(t)… x(t) =e= x(t-1) + delta_i(t) - delta_d(t) ;
con3b(t)… deltamax =g= delta_i(t) + delta_d(t) ;

Is there a way to use the sets tdt and dht (of the previous message)
to ‘convert’ the indices?

Regards,
Daniel

On 18 Jul., 11:16, Gamsworld Admin wrote:

Daniel,

The GAMS lingo for this is lag and lead operators: x(d,h-1) e.g. shows
the previous hour. The ‘-’ is not a numercial minus but a lag. Trouble
is that the predecessor for x(d,‘h1’) is x(d-1,‘h24’). You also have
to decide what predecessor of ‘d1’,‘h1’ is. If you do a steady state
model you could have ‘d365’,‘h24’ or you can decide that there is no
predecessor (meaning delta(‘d1’,‘h1’) = x(‘d1’,'h1)). I am assuming
your sets look like this

set d / d1d365 /
h / h1
h24 /

Now here is what you can do:

delta(d,h) =e= x(d,h) - x(d-(1$sameas(‘h1’)),h–1)) ;

Not so elegant, but it will work. I prefer working with an additional
set of all hours in the year:
and a map between d,h and all hours in the year:

sets h /h1*h24/, d /d1*d365/, dh(d,h) /#d.#h/
sets t /t1*t8760/, tdh(t,d,h) /#t:#dh/, dht/#dh:#t/

This matching operators (. and :slight_smile: are new syntax and will work with
22.7 and higher. You can do the maps also with older GAMS statements.
Now I would have the variable x and delta over t and then the
constraint looks simple:

delta(t) =e= x(t) - x(t-1) (or x(t–1) for steady state)

In case you have data by d,h you can use the map tdh, for example:

delta(t) =l= sum(tdh(t,d,h), maxdeviation(d,h));

Hope this helps,
Michael Bussieck, GAMSWorld Admin

On Jul 18, 4:24 am, Daniel wrote:

Hello,

I’m new to GAMS (although not new to MIP programming) and hope I can
find help for a problem a currently have.

I have variables with two indices, e.g. x(d,h), where d and h are sets
of days and hours.

My problem is to make a predecessor/sucessor relation between those x
variables. E.g. I have to model the difference between two neighboring
x variables like:

delta(d,h) =e= x(d,h) - x(pred(d,h)) ;

delta(d,) =l= constant ;

Are there any ideas how to make this in an easy and elegant way?

Regards,
Daniel- Hide quoted text -

  • Show quoted text -





    Daniel Andrés Navia López
    Mg.Sc.(c) Ciencias de la Ingeniería Mención Ingeniería Química
    89674421

–~–~---------~–~----~------------~-------~–~----~
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
-~----------~----~----~----~------~----~------~–~—