Hi,
after giving an example about how to call OPL from Python at https://www.ibm.com/developerworks/community/forums/html/topic?id=0b6cacbe-4dda-4da9-9282-f527c3464f47 , I got the question: what about R ?
So today if you want to call CPLEX from R you may use RCPLEX : https://cran.r-project.org/web/packages/Rcplex/index.html
But through an external call you may also call OPL (oplrun)
Which means that you can not only call CPLEX but also CPO!
diet.r is taking as input 3 csv file , will turn them in diet.dat (OPL format) and then call diet.mod through oplrun
system("oplrun diet.mod diet.dat")
To run this example, simply do
Rscript.exe diet.r
And in Rscript.exe diet.r you ll get
quantity = [0 2.1552 0 0 0 10 1.8312 0 0.9297]
cost = 2.690409172
amount = [2000 800 11.278 8518.4 25 256.81 51.174]
I hope this may help some people
regards
Alex Fleischer
PS:
Many how to with OPL at https://www.linkedin.com/pulse/how-opl-alex-fleischer/
Many examples from a very good book : https://www.linkedin.com/pulse/model-building-oplcplex-alex-fleischer/
Making optimization simple : https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/
#DecisionOptimization#OPLusingCPLEXOptimizer