excel to gams

3,277 views
Skip to first unread message

Federico Perea

unread,
Jun 22, 2012, 3:30:42 AM6/22/12
to gams...@googlegroups.com
Hey gams community!

I have trouble importing data from Excel to GAMS. The following code
does not seem to work :(



set i passes /1*3/;

Parameter a(i);

$CALL GDXXRW.EXE data.xls par=a rng=data!A1:B3

$GDXIN data.gdx
$LOAD a
$GDXIN

Any ideas on how to solve this? I attach a zip file in case you want
to try it on your own.

Thanks a lot for your help!

Fede
exceltogams.zip

Pedro Javier Ramírez Torrealba

unread,
Jun 22, 2012, 5:01:55 AM6/22/12
to gams...@googlegroups.com
Hi Fede,

Maybe this can work:

SET i /1*3/;

PARAMETER a(i);

$call GDXXRW I=data.xls O=data.gdx par=a rng=data!A1:B3
$GDXIN data.gdx
$LOAD a
$GDXIN


Cheers,
Pedro



--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Federico Perea

unread,
Jun 22, 2012, 5:25:34 AM6/22/12
to gams...@googlegroups.com
Hello Pedro,

thanks but it did not work. It keeps giving errors. Here is the log
file I get when I write down the code you sent before to the gams file
I attached originally:



GDXXRW Feb 14, 2009 23.0.2 WIN 8239.9411 VIS x86/MS Windows
**** Input file not found = C:\Users\fepero.UPVNET\Desktop\exceltogams\data.xls
Total time = 531 Ms
--- file_2.gms(8) 3 Mb
*** GDXIN failed C:\Users\fepero.UPVNET\Desktop\exceltogams\data.gdx
*** Msg: No such file or directory
--- file_2.gms(8) 3 Mb 1 Error
*** Error 510 in C:\Users\fepero.UPVNET\Desktop\exceltogams\file_2.gms
Unable to open gdx file for $GDXIN
--- file_2.gms(9) 3 Mb 2 Errors
*** Error 502 in C:\Users\fepero.UPVNET\Desktop\exceltogams\file_2.gms
GDXIN file not open - ignore rest of line
--- file_2.gms(14) 3 Mb 3 Errors
*** Error 141 in C:\Users\fepero.UPVNET\Desktop\exceltogams\file_2.gms
Symbol neither initialized nor assigned
A wild shot: You may have spurious commas in the explanatory
text of a declaration. Check symbol reference list.
--- file_2.gms(17) 3 Mb 3 Errors
*** Status: Compilation error(s)
--- Job file_2.gms Stop 06/22/12 11:19:13 elapsed 0:00:00.680
Exit code = 2


Any ideas on how to solve this? I've been struggling with this for some time :(

Fede

Pedro Javier Ramírez Torrealba

unread,
Jun 22, 2012, 5:48:33 AM6/22/12
to gams...@googlegroups.com
Hi Fede,

The name of the excel file was: "data.xls.xls". I have also made some improvements to your code :) (attached).


Cheers,
Pedro
exceltogams_fede.zip

Federico Perea

unread,
Jun 22, 2012, 6:29:29 AM6/22/12
to gams...@googlegroups.com
Dear Pedro,

thank you so much for your help! It sometimes happens to me that the
simplest mistake is impossible to find :(

Honestly, thanks for taking your time to help me out.

Fede

On Fri, Jun 22, 2012 at 11:48 AM, Pedro Javier Ramírez Torrealba

Renger van Nieuwkoop

unread,
Jun 22, 2012, 7:03:30 AM6/22/12
to gams...@googlegroups.com

Hi Fedrico

 

The most simple way is:

 

* Sets and Parameters definition

SET         i ;

* Data importation from Excel

$CALL GDXXRW I=data.xls O=Data.gdx set=i rdim=1   rng=data!A1:a3 par=a  rdim=1 rng=data!A1:b3   trace=3

 

PARAMETER   a(i);

 

 

$GDXIN data.gdx

$LOAD i,a

$GDXIN

 

display a,i;

 

Notice that you have a parameter a(i) with one dimension, so you have to set rdim=1.

 

 

Cheers

 

Renger

Federico Perea

unread,
Jun 22, 2012, 8:13:49 AM6/22/12
to gams...@googlegroups.com
Thanks Renger!

Savitsky Andre

unread,
May 15, 2013, 9:47:06 AM5/15/13
to gams...@googlegroups.com
 Try this! Nadia!
 
***********************************************************************************
 
par= cm rng= your_list_name!g6 rdim=1 cdim=1
 
 
***********************************************************************************
g6 = left upper cotner of table
 
 
All the best!
 
 
 
 
 
 
15.05.2013, 13:43, "nadia" <n.mosh...@gmail.com>:


Dear all,

I have the same problem.
here is my code:

$CALL GDXXRW.EXE book.xls par=cm rng=C3:G7
Parameter cm(*,*);
$GDXIN book.gdx
$LOAD cm
$GDXIN

I encounter the same errors(ERROR 502 & 510)





On Friday, 22 June 2012 12:00:42 UTC+4:30, fedperea wrote:
Hey gams community!

I have trouble importing data from Excel to GAMS. The following code
does not seem to work :(



set i passes /1*3/;

Parameter a(i);

$CALL GDXXRW.EXE data.xls par=a rng=data!A1:B3

$GDXIN data.gdx
$LOAD a
$GDXIN

thanks for you help.

Any ideas on how to solve this? I attach a zip file in case you want
to try it on your own.

Thanks a lot for your help!

Fede

 

--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
 
--
With kindly regards!
Andre Savitsky
E-mail:andre...@yandex.ru
andre...@yahoo.com

nadia moshahedi

unread,
May 16, 2013, 10:38:08 AM5/16/13
to gams...@googlegroups.com
sorry, I did'nt understand what to do. would you please write the entire code?


--
You received this message because you are subscribed to a topic in the Google Groups "gamsworld" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamsworld/Lca85EO48-o/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to gamsworld+...@googlegroups.com.

Ines TR

unread,
Jun 25, 2013, 1:14:32 PM6/25/13
to gams...@googlegroups.com
Hello Renger!
I found your response in this post and would like to ask for your help if possible.

I tried entering the code as you suggested, however, I still get the message "no such file or directory".
If I take away the 
$GDXIN data.gdx 

I get "GDX file not open", although I don´t get the previous message anymore.


Any ideas why this is happenning ??
Thanks so much!
Ines

Paul Van der Eijk

unread,
Jun 25, 2013, 2:27:56 PM6/25/13
to gams...@googlegroups.com
The name of the Excel file is your problem. It is called
data.xls.xls (extension twice) Rename to data.xls.

Looks like you want to read a parameter with dim=1 so
this will make it work:

$CALL GDXXRW.EXE data.xls par=a rng=data!A1:B3 rdim=1 cdim=0

--Paul


--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.




--
Paul van der Eijk
GAMS Development Corporation
Tel  : (202) 342-0180  Fax  : (202) 342-0181
Email: pvand...@gams.com  
Web : http://www.gams.com

Ines TR

unread,
Jun 25, 2013, 2:41:14 PM6/25/13
to gams...@googlegroups.com
Paul,
can you help me?
I get the follwing errors:
error 1: Unknown identifier entered as set
error 2: GDXIN file not open -ignore rest of file

My code look like this:

SET
i
alias(i,j)
r;

$CALL GDXXRW.EXE I=InputGAMS.xlsx  O=InputGAMS.gdx set=i   rng=product rdim=1  set=j rng=supplier rdim=1  set=r rng=interval rdim=1  par=d rng=demand Cdim=1 Rdim=1 par=c rng=capacity Cdim=1 Rdim=1 par=B rng=B Cdim=1 Rdim=2 par=k rng=K Cdim=1 Rdim=2 par=P rng=P Cdim=1 Rdim=2  par=Q rng=Q Cdim=1 Rdim=2   par=L rng=L Cdim=1 Rdim=2   par=S rng=S Cdim=1 Rdim=2 Trace=3


PARAMETERS
         d(i)    annual demand of product i
         c(j)    capacity at supplier j
         B(j,r)  busines vol interval     <----error 1 points here
         k(j,r)  upper limit r for j 
         P(i,j)  price data

$load d,c,b,k,p,q,l,s;
$gdxin

Thanks,
Ines

Paul Van der Eijk

unread,
Jun 26, 2013, 1:00:10 PM6/26/13
to gams...@googlegroups.com
Inez,

1. I do not see a declaration of the set R

2. Before doing a $LOAD you need a $GDXIN <filename>

--Paul



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.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

inest

unread,
Jun 26, 2013, 3:25:22 PM6/26/13
to gams...@googlegroups.com
Yes, I forgot to mention that when adding $GDXIN <filename> what i get  is "unable to open gdx file for GDXIN"
Any clues why?


2013/6/26 Paul Van der Eijk <pvand...@gams.com>

--
You received this message because you are subscribed to a topic in the Google Groups "gamsworld" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamsworld/Lca85EO48-o/unsubscribe.
To unsubscribe from this group and all its topics, 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/groups/opt_out.
 
 



--
*   ***   *  ***   *   ***   *
Aineth Torres
Frontier Market Scout
Village Capital Program Associate
Siguenos en facebook

fux...@gmail.com

unread,
Sep 25, 2013, 1:57:50 PM9/25/13
to gams...@googlegroups.com
Hi, Pedro
I am try to input the SAM data from the xls to Gams. I use the following code.

execute "gdxxrw sam.xls output=sam.gdx par=sam rng=a1:f6 cdim=1 rdim=1" ;
Parameter SAM (u,v) social accounting matrix;
$gdxin sam.gdx
$loaddc sam
$gdxin

But it is error like:

*** GDXIN failed C:\users\fuxue\Documents\gamsdir\projdir\sam.gdx
***Msg:No such file or directory
--- splcge.gms(14) 3 Mb 1 Error
*** Error 510 in C:\Users\fuxue\Documents\gamsdir\projdir\splcge.gms
       Unable to open gdx file for $ GDXIN
--- splcge.gms(14) 3 Mb 2 Error
*** Error 502 in C:\Users\fuxue\Documents\gamsdir\projdir\splcge.gms

    GDXIN file not open - ignore rest of line
*** Error 141 in C:\Users\fuxue\Documents\gamsdir\projdir\splcge.gms

    Symbol neither initialized nor assigned

Thanks!

Xue

在 2012年6月22日星期五UTC-4上午5时01分55秒,PowerChile写道:
splcge.gms
sam.xls

Paul Van der Eijk

unread,
Sep 25, 2013, 3:13:52 PM9/25/13
to gams...@googlegroups.com
Execute 'happens' at execution time; the $GDXIN and $LOAD at compile time. So you will create your sam.gdx file too late. Using $call GDXXRW should help you.

--Paul


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.

fux...@gmail.com

unread,
Sep 25, 2013, 8:59:29 PM9/25/13
to gams...@googlegroups.com

Hi, Paul

Thank you for your help. But I met another problem when I input io.xls to cge1.gms

The code and error are shown as followed:

Parameter io(sec,sec2) io table;
$call "gdxxrw io.xls output=io.gdx par=io  rng=a1:f7 cdim=1 rdim=1" ;


$gdxin io.gdx
$loaddc io
$gdxin

***Input file not found =C:\Users\fuxue\Documents\gamsdir\projdir\io.xls
Total time =437 Ms
---CGE0.GMS(21) 3 Mb
*** GDXIN failed C:\Users\fuxue\Documents\gamsdir\projdir\io.gdx

***Msg: No such file or directory
---CGE0.GMS(21) 3 Mb 2 Errors
***Error 510 in C:\Users\fuxue\Documents\gamsdir\projdir\CGE0.GMS

Unable to open gdx file for $GDXIN
---CGE0.GMS(22) 3 Mb 2 Errors
***Error 502 in C:\Users\fuxue\Documents\gamsdir\projdir\CGE0.GMS

GDXIN file not open - ignore rest of line
---CGE0.GMS(45) 3 Mb 3 Errors
***Error 141 in C:\Users\fuxue\Documents\gamsdir\projdir\CGE0.GMS
Symbol neither initialized nor assgned

Kind regards

Xue

在 2013年9月25日星期三UTC-4下午3时13分52秒,Paul Van der Eijk写道:
CGE0.GMS
io.xlsx

Diego Broz

unread,
Oct 31, 2013, 12:28:35 AM10/31/13
to gams...@googlegroups.com
Hi 
I a have a problem with export from Excel to GRAMS. This occur only with three dimensional matrix.
The parameters are vol(i,k,p), pv(i,k,p), CCC(i,k,p)

Gams sentence is::
---------
$onecho > taskinput.txt

par=vol      rng=vol!D5:H21     dim=3 rdim=2 cdim=1
par=pv       rng=preve!D11:H27  dim=3 rdim=2 cdim=1
par=CCC      rng=cos!I8:M24     dim=3 rdim=2 cdim=1

$offecho
$call gdxxrw.exe database.xlsx @taskinput.txt
$gdxin database.gdx
$load  vol pv CCC 
display vol, pv, CCC, ;
------------
thanks

Steven Dirkse

unread,
Oct 31, 2013, 4:29:37 AM10/31/13
to gams...@googlegroups.com
Diego,

The code you send includes several distinct steps, using multiple parameters.  It would be better if you would check which step is failing, for just one parameter.  For example, take out everything after the call of gdxrrw.  If that call fails in some way or does not work as expected, what's the point in loading data from the GDX file?  Also, look at the parameters individually: if you can read one you can probably read all of them.  Once you have that, you can use the trace flag to gdxrrw and use the GAMS IDE or gdxdump to look at the GDX file produced.  For example, just run from the command line and do:

gdxxrw.exe database.xlsx trace=3 par=vol      rng=vol!D5:H21     dim=3 rdim=2 cdim=1
and if this produces a GDX file do
gdxdump database.gdx    (or view in the IDE)

-Steve


--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
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.



--
Steven Dirkse, Ph.D.
GAMS Development Corp.,  Washington DC
Voice: (202)342-0180     Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com

parul mathuria

unread,
Oct 31, 2013, 4:35:08 AM10/31/13
to gams...@googlegroups.com
Hi Fede,

try this
set i /1*3/;
Parameter a(i);
$CALL GDXXRW data.xls  Par=a rng=data!A1:B3 Rdim=1 Cdim=0
$GDXIN data.gdx
$LOAD a
$GDXIN

pls check

data.xls should be at same folder where your GAMS file is saved


--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
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/groups/opt_out.



--
With Regards,

Parul Mathuria
ID- 2010REE505
Research Scholar
MNIT, Jaipur

Message has been deleted

Diego Broz

unread,
Nov 2, 2013, 11:01:28 PM11/2/13
to gams...@googlegroups.com
Hello Parul 
I have a problem with parameter load from Excel.
I have 11 parameters, but 4 do not load, they are: vol(i,k,p), pv(i,k,p), CCC(i,k,p) and adya(i,ii) (Attached the file in question). This procedure is  easy but I tried several forms but it is imposible of load and I do not understand. 

Sorry for me English and sorry to bother.
Regards
Problem load.rar

Renger van Nieuwkoop

unread,
Nov 3, 2013, 12:18:09 PM11/3/13
to gams...@googlegroups.com

Hi Diego

Chec k your code: you let the first command for gdxxrw start with D5, but this should b e B5. If you change just that, vol is imported correctly.

Same kind of errors for the other imported stuff

Renger

 

From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Diego Broz
Sent: Friday, November 1, 2013 7:25 PM
To: gams...@googlegroups.com
Subject: Re: excel to gams

 

Dear Steven.

Thank for contestar my question.

I tried the way you told me, I tried with two EXCEL files, etc.. but not loaded the parameters.

I attached the file (.gms, .xls, .gpr).

Thank for help me.

Diego Broz

unread,
Nov 4, 2013, 10:14:28 AM11/4/13
to gams...@googlegroups.com
Renger 
Thank so much and a big thank to member of this group.
See you 

Diego

AleX Pineda

unread,
Nov 18, 2013, 1:53:07 PM11/18/13
to gams...@googlegroups.com
Hello! I'm working on a group projejct for college and I'm getting around 46-50 errors, and i think most of them have to do with my excel. This is my code and my errors, any ideas, please?


Sets
         i       tipo de nucleos          /1*3/
         j       localidad de centro     /1*42/;
Alias (j, k);

Parameters M(i) Capacidad de cada centro de salud;
$libinclude xlimport M Tablas_OPT.xlsx Data!A3:C4
Display M;

Parameters C(i) Costo por abrir centro de servicio tipo i;
$libinclude xlimport C Tablas_OPT.xlsx Data!A7:C8
Display C;

Parameters P(j) Población de localidades;
$libinclude xlimport P Tablas_OPT.xlsx Data!A11:AP12
Display P;

Parameters D(j,k) Distancia;
$libinclude xlimport D Tablas_OPT.xlsx Data!A15:AQ57
Display D;

Variables

x(i,j) Para Abrir un centro en la localidad j
y(k,i,j) Para asignar poblacion de la localidad k en el centro tipo i ubicado en la localidad j
z Costo total de abrir un centro;


         Binary Variable x;
         Binary Variable y;

Equations
         Costo funcion objetivo
         Centro(i,j)  Centro tipo i en localidad j
         Capacidad1(k,1,j)  Capacidad de un centro tipo 1 en la localidad j para poblacion de localidad k
         Capacidad2(k,2,j)  Capacidad de un centro tipo 1 en la localidad j para poblacion de localidad k
         Capacidad3(k,3,j)  Capacidad de un centro tipo 1 en la localidad j para poblacion de localidad k
         Distancia(k,i,j) Distancia de un centro tipo i en la localidad j para la poblacion de la localidad k ;

Costo .. z=e=f*sum ((i,j),c(i)*x(i,j));
Centro(i,j) .. sum(i, x(i,j)) =l= 1;
Capacidad1(k,1,j) .. sum (k, y(k,1,j)*P) =l= 3000;
Capacidad2(k,2,j) .. sum (k, y(k,2,j)*P) =l= 6000;
Capacidad3(k,3,j) .. sum (k, y(k,3,j)*P) =l= 9000;
Distancia(k,i,j) .. sum (k, i(k,i,j)*D)=l= 10;

model  centros /all/;

solve transporte using mip minimizing z ;

Display x.l, x.m, y.l, y.m, z.l;

execute_unload "Tablas_OPT.gdx" x.l,y.l,z.l ;
execute 'gdxxrw.exe Tablas_OPT.gdx var=x.L rng=Results!A7'
execute 'gdxxrw.exe Tablas_OPT.gdx var=y.L rng=Results!C2'
execute 'gdxxrw.exe Tablas_OPTgdx var=z.L rng=Results!H2' 


----------------------------------------------------------------------------------------------------------------------------------------------------
1  Sets
   2           i       tipo de nucleos          /1*3/
   3           j       localidad de centro     /1*42/;
   4  Alias (j, k);
   5   
   6  Parameters M(i) Capacidad de cada centro de salud;
LIBINCLUDE C:\GAMS\win64\24.1\inclib\xlimport.gms
**** File: C:\Users\user\Documents\gamsdir\projdir\xllink.gdx
**** Msg : No such file or directory
  36  $gdxin xllink.gdx
****                  $510
**** LINE     53 LIBINCLUDE  C:\GAMS\win64\24.1\inclib\xlimport.gms
                             %3  Data!A3:C4
                             %2  Tablas_OPT.xlsx
                             %1  M
**** LINE      7 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
  37  $loadDC M
****        $502
**** LINE     54 LIBINCLUDE  C:\GAMS\win64\24.1\inclib\xlimport.gms
                             %3  Data!A3:C4
                             %2  Tablas_OPT.xlsx
                             %1  M
**** LINE      7 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
  39  Display M;
****          $141
**** LINE      8 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
  40   
  41  Parameters C(i) Costo por abrir centro de servicio tipo i;
LIBINCLUDE C:\GAMS\win64\24.1\inclib\xlimport.gms
**** File: C:\Users\user\Documents\gamsdir\projdir\xllink.gdx
**** Msg : No such file or directory
  71  $gdxin xllink.gdx
****                  $510
**** LINE     53 LIBINCLUDE  C:\GAMS\win64\24.1\inclib\xlimport.gms
                             %3  Data!A7:C8
                             %2  Tablas_OPT.xlsx
                             %1  C
**** LINE     11 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
  72  $loadDC C
****        $502
**** LINE     54 LIBINCLUDE  C:\GAMS\win64\24.1\inclib\xlimport.gms
                             %3  Data!A7:C8
                             %2  Tablas_OPT.xlsx
                             %1  C
**** LINE     11 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
  74  Display C;
****          $141
**** LINE     12 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
  75   
  76  Parameters P(j) Población de localidades;
LIBINCLUDE C:\GAMS\win64\24.1\inclib\xlimport.gms
**** File: C:\Users\user\Documents\gamsdir\projdir\xllink.gdx
**** Msg : No such file or directory
 106  $gdxin xllink.gdx
****                  $510
**** LINE     53 LIBINCLUDE  C:\GAMS\win64\24.1\inclib\xlimport.gms
                             %3  Data!A11:AP12
                             %2  Tablas_OPT.xlsx
                             %1  P
**** LINE     15 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 107  $loadDC P
****        $502
**** LINE     54 LIBINCLUDE  C:\GAMS\win64\24.1\inclib\xlimport.gms
                             %3  Data!A11:AP12
                             %2  Tablas_OPT.xlsx
                             %1  P
**** LINE     15 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 109  Display P;
****          $141
**** LINE     16 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 110   
 111  Parameters D(j,k) Distancia;
LIBINCLUDE C:\GAMS\win64\24.1\inclib\xlimport.gms
**** File: C:\Users\user\Documents\gamsdir\projdir\xllink.gdx
**** Msg : No such file or directory
 141  $gdxin xllink.gdx
****                  $510
**** LINE     53 LIBINCLUDE  C:\GAMS\win64\24.1\inclib\xlimport.gms
                             %3  Data!A15:AQ57
                             %2  Tablas_OPT.xlsx
                             %1  D
**** LINE     19 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 142  $loadDC D
****        $502
**** LINE     54 LIBINCLUDE  C:\GAMS\win64\24.1\inclib\xlimport.gms
                             %3  Data!A15:AQ57
                             %2  Tablas_OPT.xlsx
                             %1  D
**** LINE     19 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 144  Display D;
****          $141
**** LINE     20 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 145   
 146  Variables
 147   
 148  x(i,j) Para Abrir un centro en la localidad j
 149  y(k,i,j) Para asignar poblacion de la localidad k en el centro tipo i ubic
      ado en la localidad j
 150  z Costo total de abrir un centro;
 151   
 152   
 153           Binary Variable x;
 154           Binary Variable y;
 155   
 156  Equations
 157           Costo funcion objetivo
 158           Centro(i,j)  Centro tipo i en localidad j
 159           Capacidad1(k,1,j)  Capacidad de un centro tipo 1 en la localidad 
****                        $2,185
      j para poblacion de localidad k
**** LINE     35 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 160           Capacidad2(k,2,j)  Capacidad de un centro tipo 1 en la localidad 
****                        $2,185
      j para poblacion de localidad k
**** LINE     36 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 161           Capacidad3(k,3,j)  Capacidad de un centro tipo 1 en la localidad 
****                        $2,185
      j para poblacion de localidad k
**** LINE     37 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 162           Distancia(k,i,j) Distancia de un centro tipo i en la localidad j 
      para la poblacion de la localidad k ;
 163   
 164  Costo .. z=e=f*sum ((i,j),c(i)*x(i,j));
****               $140
**** LINE     40 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 165  Centro(i,j) .. sum(i, x(i,j)) =l= 1;
****                      $125
**** LINE     41 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 166  Capacidad1(k,1,j) .. sum (k, y(k,1,j)*P) =l= 3000;
****               $145,148      $125  $145,171,148,148
**** LINE     42 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 167  Capacidad2(k,2,j) .. sum (k, y(k,2,j)*P) =l= 6000;
****               $145,148      $125  $145,171,148,148
**** LINE     43 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 168  Capacidad3(k,3,j) .. sum (k, y(k,3,j)*P) =l= 9000;
****               $145,148      $125  $145,171,148,148
**** LINE     44 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 169  Distancia(k,i,j) .. sum (k, i(k,i,j)*D)=l= 10;
****                            $125     $148,148
**** LINE     45 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 170   
 171  model  centros /all/;
 172   
 173  solve transporte using mip minimizing z ;
****                 $140,241                 $257
**** LINE     49 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 174   
 175  Display x.l, x.m, y.l, y.m, z.l;
****            $141      $141      $141
**** LINE     51 INPUT       C:\Users\user\Documents\gamsdir\projdir\Proyecto.gm
                             s
 176   
 177  execute_unload "Tablas_OPT.gdx" x.l,y.l,z.l ;
 178  execute 'gdxxrw.exe Tablas_OPT.gdx var=x.L rng=Results!A7'
 179  execute 'gdxxrw.exe Tablas_OPT.gdx var=y.L rng=Results!C2'
 180  execute 'gdxxrw.exe Tablas_OPTgdx var=z.L rng=Results!H2'
 181   
 182   
 183   
 184   
 185   
 186   
 187   
 188   
 189   
 190   
 191   
 192   
GAMS 24.1.3  r41464 Released Jul 26, 2013 WEX-WEI x86_64/MS Windows 11/18/13 12:44:51 Page 2
G e n e r a l   A l g e b r a i c   M o d e l i n g   S y s t e m
Error Messages


  2  Identifier expected
125  Set is under control already
140  Unknown symbol
141  Symbol neither initialized nor assigned
        A wild shot: You may have spurious commas in the explanatory
        text of a declaration. Check symbol reference list.
145  Set identifier or quoted element expected
148  Dimension different - The symbol is referenced with more/less
        indices as declared
171  Domain violation for set
185  Set identifier or '*' expected
241  Model has not been defined
257  Solve statement not checked because of previous errors
502  GDXIN  file not open - ignore rest of line
510  Unable to open gdx file for $GDXIN

**** 50 ERROR(S)   0 WARNING(S)

ömer solakli

unread,
May 20, 2014, 6:55:04 PM5/20/14
to gams...@googlegroups.com

Hey Gams Community, 

i have the following excel file, but however i tried, i wasnt able to read data from the file.

i have 6 months (January, February, April, May, June, July)

working days for each month 

and units demanded for each month in the excel file. 
data.xls

Renger van Nieuwkoop

unread,
May 21, 2014, 7:01:15 AM5/21/14
to gams...@googlegroups.com

Hi

Read the guidelines to this google group and repost your question accordingly.

Cheers

Renger

 

____________________

Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

In...@modelworks.ch

blog.modelworks.ch

--

You received this message because you are subscribed to the Google Groups "gamsworld" group.
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.

sara ahmadi

unread,
Sep 29, 2014, 6:31:23 PM9/29/14
to gams...@googlegroups.com
Hello, I have the same problem...
Can anyone help me?
I don't know what is the problem!!!
i demand points/d1*d232/;
parameter de(i) demand of the points
$CALL GDXXRW C:\Users\sony\Desktop\distances.xlsx par=de rng=de!B3:B234 Cdim=0 Rdim=1
$GDXIN distances.gdx
$LOAD de
$GDXIN
display de;

Moein Ch

unread,
Nov 11, 2014, 3:26:24 PM11/11/14
to gams...@googlegroups.com
Hello everybody,

I have a problem to import Excel files to GAMS and GAMS to excel. For converting Excel to GAMS I use xls2gm toolbar and after that I use $include X.inc but I don't know why it doesn't work! Also, I use following command to convert GAMS file to excel but it doesn't work either:

execute_unload "outU.gdx" u.l
execute 'gdxxrw.exe outU.gdx var=u.l'  

Can anybody tell me why it is happening?

Thank you in advance.

Renger van Nieuwkoop

unread,
Nov 12, 2014, 5:44:12 AM11/12/14
to gams...@googlegroups.com

Hi Moein

This works fine for me, if the variable has non-zero values (if zero just add EPS)

Perhaps this is the problem, but as you don’t give much more information it is hard to tell.

You can add trace=3 to see if gdxxrw gives you an error.

execute 'gdxxrw.exe outU.gdx var=u.l trace=3'  

 

Cheers

Renger

 

From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Moein Ch
Sent: Tuesday, November 11, 2014 21:26
To: gams...@googlegroups.com
Subject: Re: excel to gams

 

Hello everybody,

--

Azad Mirzaiee

unread,
Nov 14, 2014, 9:02:55 AM11/14/14
to gams...@googlegroups.com
hi Maryam  you should your  set before the numbers in excel file the load them both together :)

Jörg Schlutter

unread,
Nov 17, 2014, 4:44:43 AM11/17/14
to gams...@googlegroups.com

Hello

 

I work often in Excel and I found this neat Excel-AddIn, which lets you use GAMS out of Excel:

 

http://solverstudio.org/

 

Greetings from Germany

Jörg Schlutter


Portfoliomanagement SchwarmStrom
Energiewirtschaft

LichtBlick SE
Zirkusweg 6
20359 Hamburg

Telefon:
Telefax:

+49 40 / 6360 - 2412
+49 40 / 6360 - 2125


joerg.s...@lichtblick.de

www.lichtblick.de
www.lichtblickblog.de
www.facebook.de/lichtblick.de



Bitte prüfen Sie der Umwelt zuliebe, ob der Ausdruck dieser E-Mail erforderlich ist.

 

LichtBlick SE
Geschaeftsfuehrung: Heiko von Tschischwitz (Vorsitzender), Gero Luecking, Mustafa Oezen, Olaf Westermann

Vorsitzender des Verwaltungsrats: Michael Saalfeld

Sitz der Gesellschaft: Hamburg
Amtsgericht Hamburg HRB 126094

Arash Beheshtian

unread,
Jan 22, 2015, 9:51:01 PM1/22/15
to gams...@googlegroups.com
Hi Renger, 

I am working on a large-size logistic problem (but simple code) and I receive error 66 (The Symbol shown has not defined ...). 
After doing a day research, I am guessing two issues; the size of excel file and using alias. 
Is there any chance that you could assist me. 




Thanks, 
Arash 
start with just T.gms

Renger van Nieuwkoop

unread,
Jan 23, 2015, 1:59:20 AM1/23/15
to gams...@googlegroups.com

Hi Arash

Without the excel file I can’t do much.

Cheers

Renger

 

From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Arash Beheshtian
Sent: Freitag, 23. Januar 2015 03:51
To: gams...@googlegroups.com
Subject: Re: excel to gams

 

Hi Renger, 

--

Manuel Rivera

unread,
Nov 26, 2015, 4:35:15 AM11/26/15
to gamsworld
hello,
i'm working on this assignment, but i got stuck in the ecuations part, honestly i tried changing the dimentions but can't figure out what's wrong.
i have 4 parameters and 2 equations, and the problem seems to be in the second equation. i would apreciate a lot if you could help me.
regards.
assignment.rar

Manuel Rivera

unread,
Nov 26, 2015, 4:35:56 AM11/26/15
to gams...@googlegroups.com
assignment.rar

Manuel Rivera

unread,
Nov 26, 2015, 4:35:58 AM11/26/15
to gamsworld
Hello,
I'm working on this assignment, but i got stuck in the ecuations part, honestly i tried changing the dimentions but can't figure out what's wrong
assignment.rar
Reply all
Reply to author
Forward
0 new messages