Hi everybody
Does anyone know about the possibility of linking C++ and GAMS?
something like calling GAMS from C++ and using optional solvers.
\
Hello,
You may find GAMS api in %GAMS.sysdir%\apifiles
there are two examples in C.
First you should have a model written in GAMS,
then you will need to do this:
write data using GDX API
set GAMS option using OptionAPI
start GAMS using GAMSAPI
read solution from using GDX API
I did’t try this out.
Please correct me if I made any mistake.
2012-04-27
Yan
å‘件人: Maria a. Rad
å‘é€æ—¶é—´ï¼š 2012-04-27 18:13:13
收件人: gamsworld
抄é€ï¼š
主题: C and GAMS
Hi everybody
Does anyone know about the possibility of linking C++ and GAMS?
something like calling GAMS from C++ and using optional solvers.
\
Hi, I am struggling with the same problem for several days but still cannot figure it out. There are example files in API fold written in C++. Maybe you are smarter than me and can solve this problem. I have another idea to solve this problem. We can write our data and options to a gdx file, and then call gams in C++. Calling GAMS in C++ can be easily done. The only problem is how to write data, like a table, to a gdx file. This is where I have headache.
Sent from my iPhone
On 2012-4-27, at 16:05, “Maria a. Rad” wrote:
Hi everybody
Does anyone know about the possibility of linking C++ and GAMS?
something like calling GAMS from C++ and using optional solvers.–
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, I did not see your reply. So I replied this thread with a naive answer. Actually I was following your steps before, the problem I have is how to write a table to a gdx file. The table contains the coefficient in the constraints of my model. Do you have any ideas?
Sent from my iPhone
On 2012-4-27, at 19:51, “任彦” wrote:
Hello,
You may find GAMS api in %GAMS.sysdir%\apifiles
there are two examples in C.First you should have a model written in GAMS,
then you will need to do this:write data using GDX API
set GAMS option using OptionAPI
start GAMS using GAMSAPI
read solution from using GDX APII did’t try this out.
Please correct me if I made any mistake.2012-04-27
Yanå‘件人: Maria a. Rad
å‘é€æ—¶é—´ï¼š 2012-04-27 18:13:13
收件人: gamsworld
抄é€ï¼š
主题: C and GAMSHi everybody
Does anyone know about the possibility of linking C++ and GAMS?
something like calling GAMS from C++ and using optional solvers.–
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,
if it only involves writing and reading gdx file, the problem will be simper,
you only need the gdx api.
%GAMS.sysdir%\apifiles\c\example1.c provides an example of writing and reading gdx in C,
C++\example1.cpp is an example in C++.
For the c version, you can found such routines:
create a file: gdxCreateD(…)
write: gdxOpenWrite( …)
gdxDataWriteStrStart(…)
WriteData(…);
…
read: gdxOpenRead(…)
…
close the file: gdxFree(…)
data writing to gdx file are key-value pairs,
for sets, keys = literal chars of elements in the set, and values = 0.
more details can be found in the example.
Finally you can compile you own standalone program file to process the gdx file.
Then in GMAS unload data to file, process it externally using your own program, and load data back to GAMS.
If you dont care the cost of calling an external program in GAMS (~ 150ms), I think this is the most covinent way
to exchange data between GAMS and C.
Alrough it is not convinent to use, It will work well if you spend some time to figure it out.
Note that GAMS stores data in sparse form, i.e. zeros are not stored in gdx file.
HTH,
Yan
å‘件人: Yan Kedong
å‘é€æ—¶é—´ï¼š 2012-04-30 14:47:46
收件人: gamsworld@googlegroups.com
抄é€ï¼š
主题: Re: C and GAMS
Hi, I did not see your reply. So I replied this thread with a naive answer. Actually I was following your steps before, the problem I have is how to write a table to a gdx file. The table contains the coefficient in the constraints of my model. Do you have any ideas?
Sent from my iPhone
On 2012-4-27, at 19:51, “任彦” wrote:
Hello,
You may find GAMS api in %GAMS.sysdir%\apifiles
there are two examples in C.First you should have a model written in GAMS,
then you will need to do this:write data using GDX API
set GAMS option using OptionAPI
start GAMS using GAMSAPI
read solution from using GDX API
–
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.