Problem with GAMS Transfer R

Questions on using the GAMS APIs (Python, .NET, etc.)
Post Reply
Sophie
User
User
Posts: 2
Joined: 8 months ago

Problem with GAMS Transfer R

Post by Sophie »

Hello GAMS Forum
I tried to use GAMS Tranfer R.
I succeeded in installing the gamstransfer library but when I run the line: m = Container$new() I have an error message: "Error in find_gams() :
Could not find a GAMS installation, must manually specify system directory"
I understand that the system directory is not well specified in the find_gams function, but I don't know how to specify it manually.
can someone help me?
Thank you
Sophie
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Problem with GAMS Transfer R

Post by abhosekar »

Sophie,
There are a couple ways to get gams transfer R to identify the system directory.
1. Add gams system directory to your system variable PATH. Depending on the platform you use, there are different ways to achieve this. This is the recommended and easier solution.

2. Alternatively, you can use systemDirectory argument to the container constructor.
m=Container$new(systemDirectory=“C:/GAMS/44”)

You can view this in the documentation:

https://www.gams.com/44/docs/API_R_GAMS ... _CONTAINER

Hope this helps.

Best, Atharv
Sophie
User
User
Posts: 2
Joined: 8 months ago

Re: Problem with GAMS Transfer R

Post by Sophie »

Thank you so much
Regards
Sophie
lorenareyru
User
User
Posts: 3
Joined: 5 months ago

Re: Problem with GAMS Transfer R

Post by lorenareyru »

I'm trying to use GAMS Transfer and R since the gdxrrw package is no longer functioning. I've been following the instructions, but when I import the package, I encounter a warning that says, 'inferring 'repos = NULL' from 'pkgs'.' Furthermore, when attempting to import the library using library(gamstransfer), I receive the following error: 'Error: package or namespace load failed for ‘gamstransfer’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called ‘collections’.' Could someone please advise me on what might be causing this issue with the gamstransfer package import?
Last edited by lorenareyru 5 months ago, edited 1 time in total.
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Problem with GAMS Transfer R

Post by abhosekar »

Lorena,

Looks like you haven’t installed gams transfer dependencies.
Since gams transfer is not on cran or similar online repo, installation does not automatically find these dependencies. You have to manually install them.

To install all dependencies at once, you can just do
install.packages(c(“R6”, “Rcpp”, “collections”, “R.Utils”))
You can also do them individually
install.packages(“R6”) and so on

Hope this helps. This will resolve the error.

Best, Atharv
lorenareyru
User
User
Posts: 3
Joined: 5 months ago

Re: Problem with GAMS Transfer R

Post by lorenareyru »

Thank you for your reply. Unfortunately it doesn't work. This is my code.

install.packages("R6")
install.packages("Rcpp")
install.packages("R.utils")
install.packages("collections")
# install.packages("gamstransfer")
install.packages("/Library/Frameworks/GAMS.framework/Versions/42/Resources/apifiles/R/gamstransfer/binary/gamstransfer.tgz", type="binary")#library(gamstransfer)

setwd("/Users/lorenareyes/Desktop/LR/noPattern_Lagrangian/")

m = Container$new("4.3_output_zn_49_bn_64_nc_0.5_2055_lagrangian_noPattern.gdx", systemDirectory="/Library/Frameworks/GAMS.framework/Versions/42/Resources/")[/b][/b]


When I use the install.packages("gamstransfer") command I get this error:
package 'gamstransfer' is not available for this version of R

so I am using this command:
install.packages("/Library/Frameworks/GAMS.framework/Versions/42/Resources/apifiles/R/gamstransfer/binary/gamstransfer.tgz", type="binary")#library(gamstransfer)
There I get the following warning:
inferring 'repos = NULL' from 'pkgs'.
when I run the code it seems that the gamstransfer package is not installed because I get the following error:
Error: object 'Container' not found

Thanks for any help you can give me

Best,
Lorena
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Problem with GAMS Transfer R

Post by abhosekar »

Lorena,

Looks like you made progress.

Your second command (with full path) seems right. Are you loading gamstransfer before using Container$new() ? I see that you have commented out library(gamstransfer) command. You will need to load gamstransfer with library(gamstransfer) every time you use it.

If the error persists, please send the output of sessionInfo() command.

Best, Atharv
lorenareyru
User
User
Posts: 3
Joined: 5 months ago

Re: Problem with GAMS Transfer R

Post by lorenareyru »

Dear Atharv,
Thank you for your response. Yes, I am using library(gamstransfer) in my code.

Here is my code:

install.packages("R6")
install.packages("Rcpp")
install.packages("R.utils")
install.packages("collections")
# install.packages("gamstransfer")
install.packages("/Library/Frameworks/GAMS.framework/Versions/42/Resources/apifiles/R/gamstransfer/binary/gamstransfer.tgz", type="binary")
library(gamstransfer)
setwd("/Users/lorenareyes/Desktop/LR/noPattern_Lagrangian/")

m = Container$new("4.3_output_zn_49_bn_64_nc_0.5_2055_lagrangian_noPattern.gdx", systemDirectory="/Library/Frameworks/GAMS.framework/Versions/42/Resources/")


Hera are my errors I'm encountering:
Error: package or namespace load failed for ‘gamstransfer’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/gamstransfer/libs/gamstransfer.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/gamstransfer/libs/gamstransfer.so, 0x0006): tried: '/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/gamstransfer/libs/gamstransfer.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/gamstransfer/libs/gamstransfer.so' (no such file), '/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/gamstransfer/libs/gamstransfer.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
Error: object 'Container' not found

sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.2

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/Berlin
tzcode source: internal

attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base

loaded via a namespace (and not attached):
[1] compiler_4.3.2 R6_2.5.1 tools_4.3.2
[4] collections_0.3.7 rstudioapi_0.15.0 Rcpp_1.0.11
[7] R.methodsS3_1.8.2 R.utils_2.12.3 R.oo_1.25.0

I would greatly appreciate your assistance with this issue.

Best regards,

Lorena
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Problem with GAMS Transfer R

Post by abhosekar »

Please make sure you are downloading GAMS and R for ARM64 architecture and try installing again.

Best, Atharv
Post Reply