Need some advice on using GAMS from my Java App

Hello all, I got here after searching in the web for some help on using GAMS in a Java Application, given that I couldn’t find anything that could answer my questions.

What I need is simple: I have a model and the input data, and I want that my Java App call GAMS, and then get the solution to be able to keep working with that. My question is: Is there any library (*.jar) or any tutorial on how to do this? I was able to find a ppt over this topic but it isn’t very deep, and has no possible download links or anything of that kind.

I will apreciatte any hints on this topic.

Thank you for reading.


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

You cam find examples here:
http://interfaces.gams-software.com/doku.php?id=env:spawning_gams_from_java

Make a .jar with a similar file from the link above and write a text file with the results (xml, or other) inside gams and make your java process the text file. You can also use JDBC to save the results to databanks, in this case, you need to save a text file with a .sql statements and process it inside Java.
Good luck

2012/10/13 Melina Vidoni

Hello all, I got here after searching in the web for some help on using GAMS in a Java Application, given that I couldn’t find anything that could answer my questions.

What I need is simple: I have a model and the input data, and I want that my Java App call GAMS, and then get the solution to be able to keep working with that. My question is: Is there any library (*.jar) or any tutorial on how to do this? I was able to find a ppt over this topic but it isn’t very deep, and has no possible download links or anything of that kind.

I will apreciatte any hints on this topic.

Thank you for reading.


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



\

Edson Valle
edsoncv@gmail.com


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.

Thanks for the answer, it helped. But, I have two more questions:

  • Do I need to download something? In this case, what?
  • I want to write the inputs of my model in a txt or xml file, and then make that GAMS use that model and that input file to load the parameters. How can I do this?

Thanks again, for taking your time in reading/asnwering.

Greetings.




El sábado, 13 de octubre de 2012 15:17:03 UTC-3, Edsoncv escribió:

You cam find examples here:
http://interfaces.gams-software.com/doku.php?id=env:spawning_gams_from_java

Make a .jar with a similar file from the link above and write a text file with the results (xml, or other) inside gams and make your java process the text file. You can also use JDBC to save the results to databanks, in this case, you need to save a text file with a .sql statements and process it inside Java.
Good luck

2012/10/13 Melina Vidoni

Hello all, I got here after searching in the web for some help on using GAMS in a Java Application, given that I couldn’t find anything that could answer my questions.

What I need is simple: I have a model and the input data, and I want that my Java App call GAMS, and then get the solution to be able to keep working with that. My question is: Is there any library (*.jar) or any tutorial on how to do this? I was able to find a ppt over this topic but it isn’t very deep, and has no possible download links or anything of that kind.

I will apreciatte any hints on this topic.

Thank you for reading.


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



\

Edson Valle
eds...@gmail.com


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

Melina
If you only going to read the inputs from txt and write to txt, no download is required.

The txt reading can be done in GAMS using the $include command.
The txt writing can also be done in GAMS with put statement.
So the java only need to run GAMS.
After the results in txt, you may need to process the .txt in Java.
bellow a small code snippet, I have some experience in this topic and if you want can provide some consulting and codes.

*for reading
Sets myset /
$include my_txt_source.inc
/;

*put your optimization code here.

loop(my_result,

put "here is some text from my variable "/;
** below you write the value of the variable
put “my_result”/;
);


Regards
2012/10/13 Melina Vidoni

Thanks for the answer, it helped. But, I have two more questions:

  • Do I need to download something? In this case, what?
  • I want to write the inputs of my model in a txt or xml file, and then make that GAMS use that model and that input file to load the parameters. How can I do this?

Thanks again, for taking your time in reading/asnwering.

Greetings.




El sábado, 13 de octubre de 2012 15:17:03 UTC-3, Edsoncv escribió:

You cam find examples here:
http://interfaces.gams-software.com/doku.php?id=env:spawning_gams_from_java

Make a .jar with a similar file from the link above and write a text file with the results (xml, or other) inside gams and make your java process the text file. You can also use JDBC to save the results to databanks, in this case, you need to save a text file with a .sql statements and process it inside Java.
Good luck

2012/10/13 Melina Vidoni

Hello all, I got here after searching in the web for some help on using GAMS in a Java Application, given that I couldn’t find anything that could answer my questions.

What I need is simple: I have a model and the input data, and I want that my Java App call GAMS, and then get the solution to be able to keep working with that. My question is: Is there any library (*.jar) or any tutorial on how to do this? I was able to find a ppt over this topic but it isn’t very deep, and has no possible download links or anything of that kind.

I will apreciatte any hints on this topic.

Thank you for reading.


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



\

Edson Valle
eds...@gmail.com


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/xq5i1zkUFvYJ.

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.



\

Edson Valle
edsoncv@gmail.com


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.

Thanks Edson,

I suppose that you mean “nothing to download besides GAMS”, right? I was asking if besides the GAMS here: http://www.gams.de/download/ I should look for any GAMS’s Java Library too…

Sadly I have no code since I was first researching the topic before coding. I do have another question about the code in the first link you linked before:

cmdArray[0] = “” + File.separator + “gams”; cmdArray[1] = “” + File.separator + “trnsport.gms”; Will this be the path to GAMS.exe?

cmdArray[2] = “WDIR=” + File.separator + “TMP”; Is this the path to the results file?

cmdArray[3] = “SCRDIR=” + File.separator + “TMP”; Could this be the input file directory ?

cmdArray[4] = “LO=2”; What is this?
I haven’t been able to found any comments or any in-deep guide, or how-to answering this.


Thanks again,


Regards.


El sábado, 13 de octubre de 2012 19:51:43 UTC-3, Edsoncv escribió:

Melina
If you only going to read the inputs from txt and write to txt, no download is required.
The txt reading can be done in GAMS using the $include command.
The txt writing can also be done in GAMS with put statement.
So the java only need to run GAMS.
After the results in txt, you may need to process the .txt in Java.
bellow a small code snippet, I have some experience in this topic and if you want can provide some consulting and codes.

*for reading
Sets myset /
$include my_txt_source.inc
/;

*put your optimization code here.

loop(my_result,

put "here is some text from my variable "/;
** below you write the value of the variable
put “my_result”/;
);


Regards


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

Melina
Below are my answers:

2012/10/14 Melina Vidoni

Thanks Edson,

I suppose that you mean “nothing to download besides GAMS”, right? I was asking if besides the GAMS here: http://www.gams.de/download/ I should look for any GAMS’s Java Library too…


Yes, only GAMS and your prefered Java IDE (Eclipse, Netbeans, etc)


Sadly I have no code since I was first researching the topic before coding. I do have another question about the code in the first link you linked before:




cmdArray[0] = “” + File.separator + “gams”; cmdArray[1] = “” + File.separator + “trnsport.gms”; Will this be the path to GAMS.exe?

Yes, the path to GAMS. Don’t forget to use “//” instead of “/” for file separator:
cmdArray[0] = “C:\Program Files\GAMS23.6\gams”;



cmdArray[2] = “WDIR=” + File.separator + “TMP”; Is this the path to the results file?

WDIR is the working directory or project directory


cmdArray[3] = “SCRDIR=” + File.separator + “TMP”; Could this be the input file directory ?

SCRDIR is the temporary file (or scratch files) can be the same as WDIR


cmdArray[4] = “LO=2”; What is this?

This is the log level

I haven’t been able to found any comments or any in-deep guide, or how-to answering this.




You can find this information in the users manual giving a ctrl+f in the words above (WDIR SCRDIR LO)
Good luck
Regards

Thanks again,


Regards.


El sábado, 13 de octubre de 2012 19:51:43 UTC-3, Edsoncv escribió:

Melina
If you only going to read the inputs from txt and write to txt, no download is required.
The txt reading can be done in GAMS using the $include command.
The txt writing can also be done in GAMS with put statement.
So the java only need to run GAMS.
After the results in txt, you may need to process the .txt in Java.
bellow a small code snippet, I have some experience in this topic and if you want can provide some consulting and codes.

*for reading
Sets myset /
$include my_txt_source.inc
/;

*put your optimization code here.

loop(my_result,

put "here is some text from my variable "/;
** below you write the value of the variable
put “my_result”/;
);


Regards


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/bHq0gA-S65gJ.

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.



\

Edson Valle
edsoncv@gmail.com


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.

Edson,

Thanks again, that was very usefull. I’m glad I was able to find the answers I need.

Best regards,


Melina.


El domingo, 14 de octubre de 2012 14:21:08 UTC-3, Edsoncv escribió:

Melina
Below are my answers:

2012/10/14 Melina Vidoni

Thanks Edson,

I suppose that you mean “nothing to download besides GAMS”, right? I was asking if besides the GAMS here: http://www.gams.de/download/ I should look for any GAMS’s Java Library too…


Yes, only GAMS and your prefered Java IDE (Eclipse, Netbeans, etc)


Sadly I have no code since I was first researching the topic before coding. I do have another question about the code in the first link you linked before:




cmdArray[0] = “” + File.separator + “gams”; cmdArray[1] = “” + File.separator + “trnsport.gms”; Will this be the path to GAMS.exe?

Yes, the path to GAMS. Don’t forget to use “//” instead of “/” for file separator:
cmdArray[0] = “C:\Program Files\GAMS23.6\gams”;



cmdArray[2] = “WDIR=” + File.separator + “TMP”; Is this the path to the results file?

WDIR is the working directory or project directory


cmdArray[3] = “SCRDIR=” + File.separator + “TMP”; Could this be the input file directory ?

SCRDIR is the temporary file (or scratch files) can be the same as WDIR


cmdArray[4] = “LO=2”; What is this?

This is the log level

I haven’t been able to found any comments or any in-deep guide, or how-to answering this.




You can find this information in the users manual giving a ctrl+f in the words above (WDIR SCRDIR LO)
Good luck
Regards

Thanks again,


Regards.


El sábado, 13 de octubre de 2012 19:51:43 UTC-3, Edsoncv escribió:

Melina
If you only going to read the inputs from txt and write to txt, no download is required.
The txt reading can be done in GAMS using the $include command.
The txt writing can also be done in GAMS with put statement.
So the java only need to run GAMS.
After the results in txt, you may need to process the .txt in Java.
bellow a small code snippet, I have some experience in this topic and if you want can provide some consulting and codes.

*for reading
Sets myset /
$include my_txt_source.inc
/;

*put your optimization code here.

loop(my_result,

put "here is some text from my variable "/;
** below you write the value of the variable
put “my_result”/;
);


Regards


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/bHq0gA-S65gJ.

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.



\

Edson Valle
eds...@gmail.com


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