Matlab-GAMS loop error

Gentlemen,

I have to call GAMS in a loop from Matlab but I get irregular errors.
I use a calculated value of the previous GAMS execution and use it in
the next execution.
I do this for 96 times (96 quarters in a day)

Very seldom Matlab completes this loop (96running times of GAMS),
often it breaks somewhere irregularly with the error appended below.
If I continue the loop manually from the 2nd last iteration of the
error till the end, it works. So I don’t think it depends on the
values in the model since I use the second last value which was
calculated by the loop which ended up throwing an error.

In short, with the same data, GAMS throws an error for a different
progression in the loop!

for index = 1:length_RT_schedule
loadxls_realtime(index+startpoint-1, e_bufferRT(index),pricedata);
tic
index
a = gams(‘real_time’);
toc
e_bufferRT(index+1) = a.val(2,2);
end

to get an output with the “gams()” commando, I used these lines in
GAMS:

$set matout "‘realtimeout.gdx’, e_buffer ";
$if exist matdata.gms $include matdata.gms


execute_unload %matout%;


the error:


Microsoft Visual C++ Runtime Library
Runtime Error!

Program: C:\Program Files\GAMS23.7\gams.exe

This application has requested the Runtime to terminate it in an
unusual way.

Another error I sometimes get is a.val(2.2) is empty. If I look in
the .lst file, I find a SOLVER & MODEL error no. 13


Thank you very much

\

Hi Thomas,

A workaround for your problem is provided at:

http://support.gams-software.com/doku.php?id=matlab_and_gams:interfacing_optimization_and_visualization_software_via_the_gdxmrw_utilities

Hope this helps!

On Mon, Apr 9, 2012 at 4:34 PM, tjjjc wrote:

Gentlemen,

I have to call GAMS in a loop from Matlab but I get irregular errors.
I use a calculated value of the previous GAMS execution and use it in
the next execution.
I do this for 96 times (96 quarters in a day)

Very seldom Matlab completes this loop (96running times of GAMS),
often it breaks somewhere irregularly with the error appended below.
If I continue the loop manually from the 2nd last iteration of the
error till the end, it works. So I don’t think it depends on the
values in the model since I use the second last value which was
calculated by the loop which ended up throwing an error.

In short, with the same data, GAMS throws an error for a different
progression in the loop!

for index = 1:length_RT_schedule
loadxls_realtime(index+startpoint-1, e_bufferRT(index),pricedata);
tic
index
a = gams(‘real_time’);
toc
e_bufferRT(index+1) = a.val(2,2);
end

to get an output with the “gams()” commando, I used these lines in
GAMS:

$set matout "‘realtimeout.gdx’, e_buffer ";
$if exist matdata.gms $include matdata.gms


execute_unload %matout%;


the error:


Microsoft Visual C++ Runtime Library
Runtime Error!

Program: C:\Program Files\GAMS23.7\gams.exe

This application has requested the Runtime to terminate it in an
unusual way.

Another error I sometimes get is a.val(2.2) is empty. If I look in
the .lst file, I find a SOLVER & MODEL error no. 13


Thank you very much


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.

Thank you very much,

I finally got it working properly after 2 days of mystery!



On Monday, April 9, 2012 4:34:47 PM UTC+2, tjjjc wrote:

Gentlemen,

I have to call GAMS in a loop from Matlab but I get irregular errors.
I use a calculated value of the previous GAMS execution and use it in
the next execution.
I do this for 96 times (96 quarters in a day)

Very seldom Matlab completes this loop (96running times of GAMS),
often it breaks somewhere irregularly with the error appended below.
If I continue the loop manually from the 2nd last iteration of the
error till the end, it works. So I don’t think it depends on the
values in the model since I use the second last value which was
calculated by the loop which ended up throwing an error.

In short, with the same data, GAMS throws an error for a different
progression in the loop!

for index = 1:length_RT_schedule
loadxls_realtime(index+startpoint-1, e_bufferRT(index),pricedata);
tic
index
a = gams(‘real_time’);
toc
e_bufferRT(index+1) = a.val(2,2);
end

to get an output with the “gams()” commando, I used these lines in
GAMS:

$set matout "‘realtimeout.gdx’, e_buffer ";
$if exist matdata.gms $include matdata.gms


execute_unload %matout%;


the error:


Microsoft Visual C++ Runtime Library
Runtime Error!

Program: C:\Program Files\GAMS23.7\gams.exe

This application has requested the Runtime to terminate it in an
unusual way.

Another error I sometimes get is a.val(2.2) is empty. If I look in
the .lst file, I find a SOLVER & MODEL error no. 13


Thank you very much


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/3kZuFCKIsAMJ.
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.

Reply-to: gamsworld@googlegroups.com

Hi tjjjc,

I m exactly facing the same problem. The same error message appears after i=85 iterations. How did you fix it ? I would prefer not spend to it two days of mystery :wink:

Thanks a lot

Le lundi 9 avril 2012 16:34:47 UTC+2, tjjjc a écrit :

Gentlemen,

I have to call GAMS in a loop from Matlab but I get irregular errors.
I use a calculated value of the previous GAMS execution and use it in
the next execution.
I do this for 96 times (96 quarters in a day)

Very seldom Matlab completes this loop (96running times of GAMS),
often it breaks somewhere irregularly with the error appended below.
If I continue the loop manually from the 2nd last iteration of the
error till the end, it works. So I don’t think it depends on the
values in the model since I use the second last value which was
calculated by the loop which ended up throwing an error.

In short, with the same data, GAMS throws an error for a different
progression in the loop!

for index = 1:length_RT_schedule
loadxls_realtime(index+startpoint-1, e_bufferRT(index),pricedata);
tic
index
a = gams(‘real_time’);
toc
e_bufferRT(index+1) = a.val(2,2);
end

to get an output with the “gams()” commando, I used these lines in
GAMS:

$set matout "‘realtimeout.gdx’, e_buffer ";
$if exist matdata.gms $include matdata.gms


execute_unload %matout%;


the error:


Microsoft Visual C++ Runtime Library
Runtime Error!

Program: C:\Program Files\GAMS23.7\gams.exe

This application has requested the Runtime to terminate it in an
unusual way.

Another error I sometimes get is a.val(2.2) is empty. If I look in
the .lst file, I find a SOLVER & MODEL error no. 13


Thank you very much


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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\

hi
I had faced similar error, before. You can copy mex function in each iteration, See this page:

http://support.gams-software.com/doku.php?id=matlab_and_gams:interfacing_optimization_and_visualization_software_via_the_gdxmrw_utilities

From: EL
To: gamsworld@googlegroups.com
Cc: thomascoppens@gmail.com
Sent: Sunday, February 24, 2013 7:13 PM
Subject: Re: Matlab-GAMS loop error

Hi tjjjc,

I m exactly facing the same problem. The same error message appears after i=85 iterations. How did you fix it ? I would prefer not spend to it two days of mystery :wink:

Thanks a lot

Le lundi 9 avril 2012 16:34:47 UTC+2, tjjjc a écrit :

Gentlemen,

I have to call GAMS in a loop from Matlab but I get irregular errors.
I use a calculated value of the previous GAMS execution and use it in
the next execution.
I do this for 96 times (96 quarters in a day)

Very seldom Matlab completes this loop (96running times of GAMS),
often it breaks somewhere irregularly with the error appended below.
If I continue the loop manually from the 2nd last iteration of the
error till the end, it works. So I don’t think it depends on the
values in the model since I use the second last value which was
calculated by the loop which ended up throwing an error.

In short, with the same data, GAMS throws an error for a different
progression in the loop!

for index = 1:length_RT_schedule
loadxls_realtime(index+ startpoint-1, e_bufferRT(index),pricedata);
tic
index
a = gams(‘real_time’);
toc
e_bufferRT(index+1) = a.val(2,2);
end

to get an output with the “gams()” commando, I used these lines in
GAMS:

$set matout "‘realtimeout.gdx’, e_buffer ";
$if exist matdata.gms $include matdata.gms


execute_unload %matout%;


the error:


Microsoft Visual C++ Runtime Library
Runtime Error!

Program: C:\Program Files\GAMS23.7\gams.exe

This application has requested the Runtime to terminate it in an
unusual way.

Another error I sometimes get is a.val(2.2) is empty. If I look in
the .lst file, I find a SOLVER & MODEL error no. 13


Thank you very much


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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



\

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\

Hi
I got access denied:

mexext

mexw64

which gams
C:\Program Files\GAMS23.7\gams.mexw64
cd

C:\Program Files\GAMS23.7

system (‘copy gams.mexw64 rgams.mexw64’)
Access is denied.
0 file(s) copied.

ans =

1
Can I just copy/paste the file and rename it as rgams.mexw64 ?
Thanks a lot

On Mon, Feb 25, 2013 at 6:39 AM, Hajinezhad wrote:

hi
I had faced similar error, before. You can copy mex function in each iteration, See this page:

http://support.gams-software.com/doku.php?id=matlab_and_gams:interfacing_optimization_and_visualization_software_via_the_gdxmrw_utilities

From: EL
To: gamsworld@googlegroups.com
Cc: thomascoppens@gmail.com
Sent: Sunday, February 24, 2013 7:13 PM
Subject: Re: Matlab-GAMS loop error

Hi tjjjc,

I m exactly facing the same problem. The same error message appears after i=85 iterations. How did you fix it ? I would prefer not spend to it two days of mystery :wink:

Thanks a lot

Le lundi 9 avril 2012 16:34:47 UTC+2, tjjjc a écrit :

Gentlemen,

I have to call GAMS in a loop from Matlab but I get irregular errors.
I use a calculated value of the previous GAMS execution and use it in
the next execution.
I do this for 96 times (96 quarters in a day)

Very seldom Matlab completes this loop (96running times of GAMS),
often it breaks somewhere irregularly with the error appended below.
If I continue the loop manually from the 2nd last iteration of the
error till the end, it works. So I don’t think it depends on the
values in the model since I use the second last value which was
calculated by the loop which ended up throwing an error.

In short, with the same data, GAMS throws an error for a different
progression in the loop!

for index = 1:length_RT_schedule
loadxls_realtime(index+ startpoint-1, e_bufferRT(index),pricedata);
tic
index
a = gams(‘real_time’);
toc
e_bufferRT(index+1) = a.val(2,2);
end

to get an output with the “gams()” commando, I used these lines in
GAMS:

$set matout "‘realtimeout.gdx’, e_buffer ";
$if exist matdata.gms $include matdata.gms


execute_unload %matout%;


the error:


Microsoft Visual C++ Runtime Library
Runtime Error!

Program: C:\Program Files\GAMS23.7\gams.exe

This application has requested the Runtime to terminate it in an
unusual way.

Another error I sometimes get is a.val(2.2) is empty. If I look in
the .lst file, I find a SOLVER & MODEL error no. 13


Thank you very much


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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



\

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



\

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\

Elise,

The problem you are hitting has been fixed. The fix is available in the last few maintenance releases of GAMS. I just updated the Wiki with details:

http://support.gams-software.com/doku.php?id=matlab_and_gams:interfacing_optimization_and_visualization_software_via_the_gdxmrw_utilities&#error_running_gams_function_in_a_matlab_loop

-Steve


On Mon, Feb 25, 2013 at 11:56 AM, Elise Landenne wrote:

Hi
I got access denied:

mexext

mexw64

which gams
C:\Program Files\GAMS23.7\gams.mexw64
cd

C:\Program Files\GAMS23.7

system (‘copy gams.mexw64 rgams.mexw64’)
Access is denied.
0 file(s) copied.

ans =

1
Can I just copy/paste the file and rename it as rgams.mexw64 ?
Thanks a lot

On Mon, Feb 25, 2013 at 6:39 AM, Hajinezhad wrote:

hi
I had faced similar error, before. You can copy mex function in each iteration, See this page:

http://support.gams-software.com/doku.php?id=matlab_and_gams:interfacing_optimization_and_visualization_software_via_the_gdxmrw_utilities

From: EL
To: gamsworld@googlegroups.com
Cc: thomascoppens@gmail.com
Sent: Sunday, February 24, 2013 7:13 PM
Subject: Re: Matlab-GAMS loop error

Hi tjjjc,

I m exactly facing the same problem. The same error message appears after i=85 iterations. How did you fix it ? I would prefer not spend to it two days of mystery :wink:

Thanks a lot

Le lundi 9 avril 2012 16:34:47 UTC+2, tjjjc a écrit :

Gentlemen,

I have to call GAMS in a loop from Matlab but I get irregular errors.
I use a calculated value of the previous GAMS execution and use it in
the next execution.
I do this for 96 times (96 quarters in a day)

Very seldom Matlab completes this loop (96running times of GAMS),
often it breaks somewhere irregularly with the error appended below.
If I continue the loop manually from the 2nd last iteration of the
error till the end, it works. So I don’t think it depends on the
values in the model since I use the second last value which was
calculated by the loop which ended up throwing an error.

In short, with the same data, GAMS throws an error for a different
progression in the loop!

for index = 1:length_RT_schedule
loadxls_realtime(index+ startpoint-1, e_bufferRT(index),pricedata);
tic
index
a = gams(‘real_time’);
toc
e_bufferRT(index+1) = a.val(2,2);
end

to get an output with the “gams()” commando, I used these lines in
GAMS:

$set matout "‘realtimeout.gdx’, e_buffer ";
$if exist matdata.gms $include matdata.gms


execute_unload %matout%;


the error:


Microsoft Visual C++ Runtime Library
Runtime Error!

Program: C:\Program Files\GAMS23.7\gams.exe

This application has requested the Runtime to terminate it in an
unusual way.

Another error I sometimes get is a.val(2.2) is empty. If I look in
the .lst file, I find a SOLVER & MODEL error no. 13


Thank you very much


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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



\

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



\

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.





\

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