Closed imen-ch-93 closed 1 year ago
Using rAMPL you can pass/retrieve data from/to R dataframes as shown in https://rampl.readthedocs.io/en/latest/quick-start.html#complete-listing.
Using rAMPL you can pass/retrieve data from/to R dataframes as shown in https://rampl.readthedocs.io/en/latest/quick-start.html#complete-listing.
Thank you for your answer, I wanted to check about the code line "ampl <- new(AMPL, env)";
I already defind in the line before as follow : "env <- new(Environment, "C:\rAmpl\ampl_mswin64\ampl.exe")", seems it was well understood because I didn't get any error
Though, I got the error for "ampl <- new(AMPL, env)":
Error in new_CppObject_xp(fields$.module, fields$.pointer, ...) : AMPL could not be started: Le fichier spécifié est introuvable.
Can you help me find the problem and solve it ?
You need to instantiate the environment with the path to the folder containing AMPL, not the path to the executable (see, e.g., https://rampl.readthedocs.io/en/latest/getting-started.html#initial-test).
Since your path contains backslashes you need to escape them as follows: env <- new(Environment, "C:\\rAmpl\\ampl_mswin64")
Hello,
I tried to instantiate the environment as mentioned but still get the same error. Could it be related to the expired licence of AMPL?
I now changed to work with another machine, where I have a new licence of Ampl while having the same version of R I was using 4.0.2; the problem now is with installing the package "rAMPL", a problem I didn't have in the first case. (btw , Rtools is installed, I don't know why it keeps mentioning it as a warning)
> install.packages('rAMPL')
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/ Installing package into ‘C:/Users/AMPL08/Documents/R/win-library/4.0’ (as ‘lib’ is unspecified) Warning in install.packages : package ‘rAMPL’ is not available (for R version 4.0.2)
> install_version("rAMPL", version = "2.0.1", repos="https://ampl.com/dl/API/rAMPL.tar.gz" )
Warning: unable to access index for repository https://ampl.com/dl/API/rAMPL.tar.gz/src/contrib: impossible d'ouvrir l'URL 'https://ampl.com/dl/API/rAMPL.tar.gz/src/contrib/PACKAGES' Error in download_version_url(package, version, repos, type) : couldn't find package 'rAMPL'
> install.packages("Rcpp", type="source")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/ Installing package into ‘C:/Users/AMPL08/Documents/R/win-library/4.0’ (as ‘lib’ is unspecified) essai de l'URL 'https://cran.rstudio.com/src/contrib/Rcpp_1.0.6.tar.gz' Content type 'application/x-gzip' length 2952876 bytes (2.8 MB) downloaded 2.8 MB
- installing source package 'Rcpp' ... package 'Rcpp' correctement décompressé et sommes MD5 vérifiées using staged installation ** libs
*** arch - i386 Warning in system(cmd) : 'make' not found ERROR: compilation failed for package 'Rcpp'
- removing 'C:/Users/AMPL08/Documents/R/win-library/4.0/Rcpp'
- restoring previous 'C:/Users/AMPL08/Documents/R/win-library/4.0/Rcpp' Warning in install.packages : installation of package ‘Rcpp’ had non-zero exit status
The downloaded source packages are in ‘C:\Users\AMPL08\AppData\Local\Temp\RtmpS8bxBK\downloaded_packages’
> install.packages("https://ampl.com/dl/API/rAMPL.tar.gz", repos=NULL)
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/ Installing package into ‘C:/Users/AMPL08/Documents/R/win-library/4.0’ (as ‘lib’ is unspecified) essai de l'URL 'https://ampl.com/dl/API/rAMPL.tar.gz' Content type 'application/x-gzip' length 3231971 bytes (3.1 MB) downloaded 3.1 MB
- installing source package 'rAMPL' ... using staged installation libs
*** arch - i386 Warning in system(cmd) : 'make' not found ERROR: compilation failed for package 'rAMPL'
- removing 'C:/Users/AMPL08/Documents/R/win-library/4.0/rAMPL' Warning in install.packages : installation of package ‘C:/Users/AMPL08/AppData/Local/Temp/RtmpS8bxBK/downloaded_packages/rAMPL.tar.gz’ had non-zero exit status
The error message when the license has expired is different unless it is a time-limited course license.
Regarding the installation of rAMPL, you can find the instructions at https://rampl.readthedocs.io/en/latest/getting-started.html#installation:
install.packages("Rcpp", type="source")
install.packages("https://ampl.com/dl/API/rAMPL.tar.gz", repos=NULL)
Hello,
That is what I put at the end but I got:
> install.packages("Rcpp", type="source")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/ Installing package into ‘C:/Users/AMPL08/Documents/R/win-library/4.0’ (as ‘lib’ is unspecified) essai de l'URL 'https://cran.rstudio.com/src/contrib/Rcpp_1.0.6.tar.gz' Content type 'application/x-gzip' length 2952876 bytes (2.8 MB) downloaded 2.8 MB
installing source package 'Rcpp' ... package 'Rcpp' correctement décompressé et sommes MD5 vérifiées using staged installation ** libs *** arch - i386 Warning in system(cmd) : 'make' not found ERROR: compilation failed for package 'Rcpp'
removing 'C:/Users/AMPL08/Documents/R/win-library/4.0/Rcpp' restoring previous 'C:/Users/AMPL08/Documents/R/win-library/4.0/Rcpp' Warning in install.packages : installation of package ‘Rcpp’ had non-zero exit status The downloaded source packages are in ‘C:\Users\AMPL08\AppData\Local\Temp\RtmpS8bxBK\downloaded_packages’
> install.packages("https://ampl.com/dl/API/rAMPL.tar.gz", repos=NULL)
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/ Installing package into ‘C:/Users/AMPL08/Documents/R/win-library/4.0’ (as ‘lib’ is unspecified) essai de l'URL 'https://ampl.com/dl/API/rAMPL.tar.gz' Content type 'application/x-gzip' length 3231971 bytes (3.1 MB) downloaded 3.1 MB
installing source package 'rAMPL' ... using staged installation libs *** arch - i386 Warning in system(cmd) : 'make' not found ERROR: compilation failed for package 'rAMPL'
removing 'C:/Users/AMPL08/Documents/R/win-library/4.0/rAMPL' Warning in install.packages : installation of package ‘C:/Users/AMPL08/AppData/Local/Temp/RtmpS8bxBK/downloaded_packages/rAMPL.tar.gz’ had non-zero exit status
I think you may have 64-bit Rtools installed and you are using 32-bit R ("*** arch - i386"). Using 64-bit R should fix the problem. You may also install 64-bit Rtools again from https://cran.r-project.org/bin/windows/Rtools/ in order to be sure you have everything for 64-bit builds.
You need to instantiate the environment with the path to the folder containing AMPL, not the path to the executable (see, e.g., https://rampl.readthedocs.io/en/latest/getting-started.html#initial-test).
Since your path contains backslashes you need to escape them as follows:
env <- new(Environment, "C:\\rAmpl\\ampl_mswin64")
Hello, thank you for your answer.
I tried to instantiate the environment as mentioned but I keep receive the same error with a note at the top of the function tab (Function: new_CppObject_xp(namespace:Rcpp))
" Debug location is approximate because the source is not availble"
The error message " Debug location is approximate because the source is not availble" seems to be related to https://github.com/rstudio/rstudio/issues/6854. Please try with env <- new(Environment, "C:/rAmpl/ampl_mswin64/" instead.
Hello,
I need some help regarding the link between ampl and R;
All my data is already prepared in tables in R.
I was wondering if these data can be directly read by ampl code through the same R code, where I defined the inputs as tables.
Thank you,