Importing Multidimensional Parameters From Excel

Hello,

I have read with interest the post:

http://groups.google.com/group/gamsworld/browse_thread/thread/ba3c7bb5663a5fde?pli=1

on how to import parameters into GAMS from Excel. I simply wonder if
somebody can provide some help

I would expect to have to structure my Excel File like the example
below - where I have

Set i /i1i3/
Set j /i1
i3/
Set k /i1*i3/


It would be nice to have the command needed to import it or a
reference where I can look. I have tried my best but in vain.

Thanks

Paolo


k1 k2 k3
i1 j1 1 2 3
i1 j2 2 3 4
i1 j3 3 4 5
i2 j1 4 5 6
i2 j2 5 6 7
i2 j3 6 7 8
i3 j1 7 8 9
i3 j2 8 9 10
i3 j3 9 10 11

\

Hi Paolo,
In the $GDXXRW command, change the dimensions of your parameter (Cdim and Rdim). i.e.

$CALL GDXXRW file_name.xls par=ijk_data rng=sheet_name!A1:U10 Cdim=1 Rdim=2.

This should work. If not, try transposing the data in Excel and change Cdim to 2 and Rdim to 1.

Nikit

On Tue, May 1, 2012 at 8:47 AM, Paolo Rossi wrote:

Hello,

I have read with interest the post:

http://groups.google.com/group/gamsworld/browse_thread/thread/ba3c7bb5663a5fde?pli=1

on how to import parameters into GAMS from Excel. I simply wonder if
somebody can provide some help

I would expect to have to structure my Excel File like the example
below - where I have

Set i /i1i3/
Set j /i1
i3/
Set k /i1*i3/


It would be nice to have the command needed to import it or a
reference where I can look. I have tried my best but in vain.

Thanks

Paolo


k1 k2 k3
i1 j1 1 2 3
i1 j2 2 3 4
i1 j3 3 4 5
i2 j1 4 5 6
i2 j2 5 6 7
i2 j3 6 7 8
i3 j1 7 8 9
i3 j2 8 9 10
i3 j3 9 10 11


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.

\

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.

Hi Nikit,

I have not tried your suggestion as I have found a way by using xls2gms

$onecho > ProdCapCost.txt
I=“MyFile.xls”
R=Production!A23:D29
O=ProdCapCost.inc
$offecho
$call =xls2gms @ProdCapCost.txt
Table ProdCapCost(i,j,p) Capital cost of establishing plant type p of size j for product form i
$include ProdCapCost.inc
;

I will try your suggestion later when pressure is not so intense.

Thanks again

Paolo


On 2 May 2012 18:01, Nikit Abhyankar wrote:

Hi Paolo,
In the $GDXXRW command, change the dimensions of your parameter (Cdim and Rdim). i.e.

$CALL GDXXRW file_name.xls par=ijk_data rng=sheet_name!A1:U10 Cdim=1 Rdim=2.

This should work. If not, try transposing the data in Excel and change Cdim to 2 and Rdim to 1.

Nikit

On Tue, May 1, 2012 at 8:47 AM, Paolo Rossi wrote:

Hello,

I have read with interest the post:

http://groups.google.com/group/gamsworld/browse_thread/thread/ba3c7bb5663a5fde?pli=1

on how to import parameters into GAMS from Excel. I simply wonder if
somebody can provide some help

I would expect to have to structure my Excel File like the example
below - where I have

Set i /i1i3/
Set j /i1
i3/
Set k /i1*i3/


It would be nice to have the command needed to import it or a
reference where I can look. I have tried my best but in vain.

Thanks

Paolo


k1 k2 k3
i1 j1 1 2 3
i1 j2 2 3 4
i1 j3 3 4 5
i2 j1 4 5 6
i2 j2 5 6 7
i2 j3 6 7 8
i3 j1 7 8 9
i3 j2 8 9 10
i3 j3 9 10 11


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.

\

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.

\

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.

Paolo,



Thats how I would have done it. You should be able to use named ranges in Excel for R as well. So you basically treat Excel as a database with named ranges as tables.



Dewayne
From: gamsworld@googlegroups.com [gamsworld@googlegroups.com] on behalf of Paolo Rossi [statmailinglists@googlemail.com]
Sent: Wednesday, May 09, 2012 6:52 PM
To: gamsworld@googlegroups.com
Subject: Re: Importing Multidimensional Parameters From Excel

Hi Nikit,

I have not tried your suggestion as I have found a way by using xls2gms

$onecho > ProdCapCost.txt
I=“MyFile.xls”
R=Production!A23:D29
O=ProdCapCost.inc
$offecho
$call =xls2gms @ProdCapCost.txt
Table ProdCapCost(i,j,p) Capital cost of establishing plant type p of size j for product form i
$include ProdCapCost.inc
;

I will try your suggestion later when pressure is not so intense.

Thanks again

Paolo


On 2 May 2012 18:01, Nikit Abhyankar wrote:

Hi Paolo,
In the $GDXXRW command, change the dimensions of your parameter (Cdim and Rdim). i.e.

$CALL GDXXRW file_name.xls par=ijk_data rng=sheet_name!A1:U10 Cdim=1 Rdim=2.

This should work. If not, try transposing the data in Excel and change Cdim to 2 and Rdim to 1.

Nikit

On Tue, May 1, 2012 at 8:47 AM, Paolo Rossi wrote:

Hello,

I have read with interest the post:

http://groups.google.com/group/gamsworld/browse_thread/thread/ba3c7bb5663a5fde?pli=1

on how to import parameters into GAMS from Excel. I simply wonder if
somebody can provide some help

I would expect to have to structure my Excel File like the example
below - where I have

Set i /i1i3/
Set j /i1
i3/
Set k /i1*i3/


It would be nice to have the command needed to import it or a
reference where I can look. I have tried my best but in vain.

Thanks

Paolo


k1 k2 k3
i1 j1 1 2 3
i1 j2 2 3 4
i1 j3 3 4 5
i2 j1 4 5 6
i2 j2 5 6 7
i2 j3 6 7 8
i3 j1 7 8 9
i3 j2 8 9 10
i3 j3 9 10 11


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.

\

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.

\

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.


This e-mail transmission is strictly confidential. It is intended solely for the
addressee. If you are not the addressee, please delete the e-mail and notify us
by return email or by contacting our systems administrator on +44 131 243 4444
forthwith.

Moreover if you are not the addressee, you must not copy, use, act or rely on,
disclose or distribute this e-mail. Wood Mackenzie Limited accepts no
responsibility or liability for any harm to your, or any third party’s, system
or data caused by this e-mail or its attachments or any viruses or similar
contained in it.

Wood Mackenzie Limited may monitor and record e-mails and their content passing
through its network.


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.