merge gdx file without adding the new index

Dear All,

I am trying to merge a few gdx files however I do not want to have the new index(filename) as a set.
Can I merge the files without adding this index?

I did some searching and found: http://support.gams.com/interfaces:how_to_merge_a_parameter_from_two_gdx_files_without_increasing_the_dimension

However I want to merge variables and I think it is not applicable in my case.

I am designing several reactors in series however to be able to have better results I run each one independently and created the correspondent gdx file.

Now I want to merge all gdx files and use the results as level values of the new model.

Thank you very much.
All the best,
Ines


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Hi Ines,



If you are a Windows user: goto http://www3.lei.wur.nl/gamstools/

and download the tools. One of the tools is GDXmerge2.exe

This should do what you want.



Another way of merging variables from GDX files is to write some GAMS code that will load and combine the data.



Best wishes

Wietse



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Ines
Sent: Tuesday, October 13, 2015 16:58
To: gamsworld
Subject: merge gdx file without adding the new index



Dear All,

I am trying to merge a few gdx files however I do not want to have the new index(filename) as a set.
Can I merge the files without adding this index?

I did some searching and found: http://support.gams.com/interfaces:how_to_merge_a_parameter_from_two_gdx_files_without_increasing_the_dimension

However I want to merge variables and I think it is not applicable in my case.

I am designing several reactors in series however to be able to have better results I run each one independently and created the correspondent gdx file.

Now I want to merge all gdx files and use the results as level values of the new model.

Thank you very much.
All the best,
Ines


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Reply-to: gamsworld@googlegroups.com

Hi Wietse,

I also tried to use that program but it colapses. Maybe due to the number of variables.

“Another way of merging variables from GDX files is to write some GAMS code that will load and combine the data.”

I’ll be very happy with this way however I am not managing to find the right way as when I merge I have the extra index.

I saw some examples but they have in the gdx file parameters instead of variables.
for example:

parameter mpar(i,j,k) Merged parA and parB
par (j,k) parA and parB wihtout dimension i;

  • Remove the additional index i
    par(j,k) = sum(i, mpar(i,j,k));

Do you have any ideia on how to do this with variables?

Thanks,
Inês



On Wednesday, 14 October 2015 11:01:27 UTC+1, Dol, Wietse wrote:

Hi Ines,



If you are a Windows user: goto http://www3.lei.wur.nl/gamstools/

and download the tools. One of the tools is GDXmerge2.exe

This should do what you want.



Another way of merging variables from GDX files is to write some GAMS code that will load and combine the data.



Best wishes

Wietse



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Ines
Sent: Tuesday, October 13, 2015 16:58
To: gamsworld
Subject: merge gdx file without adding the new index



Dear All,

I am trying to merge a few gdx files however I do not want to have the new index(filename) as a set.
Can I merge the files without adding this index?

I did some searching and found: http://support.gams.com/interfaces:how_to_merge_a_parameter_from_two_gdx_files_without_increasing_the_dimension

However I want to merge variables and I think it is not applicable in my case.

I am designing several reactors in series however to be able to have better results I run each one independently and created the correspondent gdx file.

Now I want to merge all gdx files and use the results as level values of the new model.

Thank you very much.
All the best,
Ines


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Reply-to: gamsworld@googlegroups.com

Hi Ines,



For a variable you can do



variable mvar(i,j,k) Merged varA and parB

var (j,k) varA and varB wihtout dimension i;

  • Remove the additional index i

var.l(j,k) = sum(i, mvar.l(i,j,k));

var.up(j,k) = sum(i, mvar.up(i,j,k));

var.lo(j,k) = sum(i, mvar.lo(i,j,k));

var.m(j,k) = sum(i, mvar.m(i,j,k));



But the question remains: do you want to merge or aggregate?

Suppose I have a simulation model with variable outcome(Product,Year)

And I first run the model for Year=2014 getting Run1.gdx (with variable outcome in it).

Then run with Year=2015 and creating Run2.gdx…



No I want to merge the outcome(Product,Year), then I would write GAMS:

Set Year/2014,2015/;

Set Product/…./;



Variable outcome(Product,Year);

$onmulti

$gdxin “Run1.gdx”

$load outcome

$gdxin



$gdxin “Run2.gdx”

$load outcome

$gdxin



Execute_unload “Combined.gdx”,outcome,Product,Year;

Please do not forget the $onmulti



Here the onmulti will ensure that if values (set combinations) that were already having a value in Run1.gdx will be overwritten with values from Run2.gdx. If you want the values to add up then the approach at the start of the mail should be taken, but again highly questionable because how can you add-up lower and upper values as well as marginal values?



Greetings

Wietse



From: Ines [mailto:inessvilarinho@gmail.com]
Sent: Wednesday, October 14, 2015 12:47
To: gamsworld
Cc: Dol, Wietse
Subject: Re: merge gdx file without adding the new index



Hi Wietse,

I also tried to use that program but it colapses. Maybe due to the number of variables.

“Another way of merging variables from GDX files is to write some GAMS code that will load and combine the data.”

I’ll be very happy with this way however I am not managing to find the right way as when I merge I have the extra index.

I saw some examples but they have in the gdx file parameters instead of variables.
for example:

parameter mpar(i,j,k) Merged parA and parB

par (j,k) parA and parB wihtout dimension i;

  • Remove the additional index i

par(j,k) = sum(i, mpar(i,j,k));

Do you have any ideia on how to do this with variables?

Thanks,
Inês



On Wednesday, 14 October 2015 11:01:27 UTC+1, Dol, Wietse wrote:

Hi Ines,



If you are a Windows user: goto http://www3.lei.wur.nl/gamstools/

and download the tools. One of the tools is GDXmerge2.exe

This should do what you want.



Another way of merging variables from GDX files is to write some GAMS code that will load and combine the data.



Best wishes

Wietse



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Ines
Sent: Tuesday, October 13, 2015 16:58
To: gamsworld
Subject: merge gdx file without adding the new index



Dear All,

I am trying to merge a few gdx files however I do not want to have the new index(filename) as a set.
Can I merge the files without adding this index?

I did some searching and found: http://support.gams.com/interfaces:how_to_merge_a_parameter_from_two_gdx_files_without_increasing_the_dimension

However I want to merge variables and I think it is not applicable in my case.

I am designing several reactors in series however to be able to have better results I run each one independently and created the correspondent gdx file.

Now I want to merge all gdx files and use the results as level values of the new model.

Thank you very much.
All the best,
Ines


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Reply-to: gamsworld@googlegroups.com


Hello Wietse,

I want the values to be added up.

"I first run the model for Year=2014 getting Run1.gdx (with variable outcome in it).

Then run with Year=2015 and creating Run2.gdx " Correct.


In Run1.gdx file I have outcome(2014)

In Run2.gdx I have outcome (2015)


In my final gdx file I would like to have outcome(year), in this, case outcome(2014) and outcome(2015).


If I merge I will have: outcome(runX, year). (Not what I want)


I didn’t want to do what you suggested earlier because I have more than 600 variables and more than 10 runs.

For each run I have to change the name of the variables (Moutcome(year) ), then merge, and then remove the extra index to outcome(year).


But maybe that’s the only way…


Thanks again,

Inês





On Wednesday, 14 October 2015 13:33:00 UTC+1, Dol, Wietse wrote:

Hi Ines,



For a variable you can do



variable mvar(i,j,k) Merged varA and parB

var (j,k) varA and varB wihtout dimension i;

  • Remove the additional index i

var.l(j,k) = sum(i, mvar.l(i,j,k));

var.up(j,k) = sum(i, mvar.up(i,j,k));

var.lo(j,k) = sum(i, mvar.lo(i,j,k));

var.m(j,k) = sum(i, mvar.m(i,j,k));



But the question remains: do you want to merge or aggregate?

Suppose I have a simulation model with variable outcome(Product,Year)

And I first run the model for Year=2014 getting Run1.gdx (with variable outcome in it).

Then run with Year=2015 and creating Run2.gdx…



No I want to merge the outcome(Product,Year), then I would write GAMS:

Set Year/2014,2015/;

Set Product/…./;



Variable outcome(Product,Year);

$onmulti

$gdxin “Run1.gdx”

$load outcome

$gdxin



$gdxin “Run2.gdx”

$load outcome

$gdxin



Execute_unload “Combined.gdx”,outcome,Product,Year;

Please do not forget the $onmulti



Here the onmulti will ensure that if values (set combinations) that were already having a value in Run1.gdx will be overwritten with values from Run2.gdx. If you want the values to add up then the approach at the start of the mail should be taken, but again highly questionable because how can you add-up lower and upper values as well as marginal values?



Greetings




From: Ines [mailto:inessvi...@gmail.com]
Sent: Wednesday, October 14, 2015 12:47
To: gamsworld
Cc: Dol, Wietse
Subject: Re: merge gdx file without adding the new index



Hi Wietse,

I also tried to use that program but it colapses. Maybe due to the number of variables.

“Another way of merging variables from GDX files is to write some GAMS code that will load and combine the data.”

I’ll be very happy with this way however I am not managing to find the right way as when I merge I have the extra index.

I saw some examples but they have in the gdx file parameters instead of variables.
for example:

parameter mpar(i,j,k) Merged parA and parB

par (j,k) parA and parB wihtout dimension i;

  • Remove the additional index i

par(j,k) = sum(i, mpar(i,j,k));

Do you have any ideia on how to do this with variables?

Thanks,
Inês



On Wednesday, 14 October 2015 11:01:27 UTC+1, Dol, Wietse wrote:

Hi Ines,



If you are a Windows user: goto http://www3.lei.wur.nl/gamstools/

and download the tools. One of the tools is GDXmerge2.exe

This should do what you want.



Another way of merging variables from GDX files is to write some GAMS code that will load and combine the data.



Best wishes

Wietse



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Ines
Sent: Tuesday, October 13, 2015 16:58
To: gamsworld
Subject: merge gdx file without adding the new index



Dear All,

I am trying to merge a few gdx files however I do not want to have the new index(filename) as a set.
Can I merge the files without adding this index?

I did some searching and found: http://support.gams.com/interfaces:how_to_merge_a_parameter_from_two_gdx_files_without_increasing_the_dimension

However I want to merge variables and I think it is not applicable in my case.

I am designing several reactors in series however to be able to have better results I run each one independently and created the correspondent gdx file.

Now I want to merge all gdx files and use the results as level values of the new model.

Thank you very much.
All the best,
Ines


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.