https://github.com/ibmdecisionoptimization/doopl-r-sample
Example showing how to use OPL from R.
https://github.com/ibmdecisionoptimization/doopl-r-sample
Last synced: 4 months ago
JSON representation
Example showing how to use OPL from R.
- Host: GitHub
- URL: https://github.com/ibmdecisionoptimization/doopl-r-sample
- Owner: IBMDecisionOptimization
- Created: 2018-10-25T13:53:58.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-25T13:58:48.000Z (over 7 years ago)
- Last Synced: 2025-10-10T00:31:18.647Z (8 months ago)
- Language: AMPL
- Size: 6.84 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md/LICENSE.md
Awesome Lists containing this project
README
# doopl-R
This is an example on how to use OPL with the R framework and the reticulate library (open source library).
It shows how to run an OPL model with R dataframes as inputs, and R dataframes as solution outputs.
In this example, we use SQLite to retrieve data from a database.
To make it work, you need:
* R runtime
* a Python interpreter (2.7, 3.5 or 3.6)
* doopl library installed in your Python environment (https://pypi.org/project/doopl/)
* CPLEX Studio 128 runtime (Windows, Linux or Mac are the only supported platforms of doopl)
First, install doopl library in your Python interpreter: 'pip install doopl'. You alternatively download it and put it in your PYTHONPATH).
Second, set the environment path variable to point to the OPL runtime:
* on Mac OS, it will be something like DYLD_LIBRARY_PATH=/Applications/CPLEX_Studio128/opl/bin/x86-64_osx
* on Linux, it will be LD_LIBRARY_PATH
* on Windows, it will be PATH.
Now, you can run R and the carseq.r script.
All the doopl functionalities are available in R. You can find the doopl examples here: https://github.com/IBMDecisionOptimization/doopl-examples/tree/master/examples
You can access the reticulate documentation here: https://rstudio.github.io/reticulate/articles/calling_python.html where you will find all the R-Python conversions.