简体   繁体   English

R:安装 cplexAPI 错误

[英]R: Install cplexAPI errors

I am trying to use cplexAPI in R. I am getting persistent errors.我正在尝试在 R 中使用 cplexAPI。我遇到了持久性错误。 I am using Microsoft R Open 3.3.1 and have installed IBM ILOG CPLEX Optimization Studio Version: 12.7.0.0 on Windows 10. Here is what I have done, and what has resulted.我正在使用 Microsoft R Open 3.3.1 并在 Windows 10 上安装了 IBM ILOG CPLEX Optimization Studio 版本:12.7.0.0。这是我所做的,以及结果。 I am going to go into painstaking detail on the hope that you see my error somewhere!我将详细介绍,希望您能在某处看到我的错误!

  1. Unpacked the tar file to a folder on my desktop.将 tar 文件解压到我桌面上的一个文件夹中。
  2. Edit the file: C:\\Users\\zejas\\Desktop\\cplexAPI\\cplexAPI\\src\\Makevars.win to say:编辑文件: C:\\Users\\zejas\\Desktop\\cplexAPI\\cplexAPI\\src\\Makevars.win说:

PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I"$C:\\Program Files\\IBM\\ILOG\\CPLEX_Studio127\\cplex\\include" PKG_LIBS=-L"$C:\\Program Files\\IBM\\ILOG\\CPLEX_Studio127\\cplex\\lib" -lm -lcplex1270

  1. Microsoft put their own spin on the Reviron.site file.微软对Reviron.site文件进行了自己的Reviron.site They put Rcmd_environ in: C:\\Program Files\\Microsoft\\MRO-3.3.1\\etc\\Rcmd_environ Within that file I added the bottom three lines:他们将Rcmd_environ放在: C:\\Program Files\\Microsoft\\MRO-3.3.1\\etc\\Rcmd_environ在该文件中,我添加了底部三行:

## from R.sh R_SHARE_DIR=${R_HOME}/share R_INCLUDE_DIR=${R_HOME}/include R_DOC_DIR=${R_HOME}/doc R_ARCH= ## from Rcmd R_OSTYPE=windows TEXINPUTS=.;${TEXINPUTS};${R_SHARE_DIR}/texmf/tex/latex; BIBINPUTS=.;${BIBINPUTS};${R_SHARE_DIR}/texmf/bibtex/bib; BSTINPUTS=.;${BSTINPUTS};${R_SHARE_DIR}/texmf/bibtex/bst; ## from etc/Renviron # R_PLATFORM='i386-pc-mingw32' R_PAPERSIZE_USER=${R_PAPERSIZE} R_PAPERSIZE=${R_PAPERSIZE-'a4'} # for Rd2dpf, reference manual R_RD4PDF=${R_RD4PDF-'times,inconsolata,hyper'} ## used for options("texi2dvi") # R_TEXI2DVICMD=${R_TEXI2DVICMD-${TEXI2DVI-'texi2dvi'}} ## used by INSTALL, check, build R_GZIPCMD=${R_GZIPCMD-'gzip'} ## Default zip/unzip commands R_UNZIPCMD=${R_UNZIPCMD-'unzip'} R_ZIPCMD=${R_ZIPCMD-'zip'} R_BZIPCMD=${R_BZIPCMD-'bzip2'} ## Default browser # R_BROWSER=${R_BROWSER-'open'} ## Default editor # EDITOR=${EDITOR-${VISUAL-vi}} ## Default pager # PAGER=${PAGER-''} ## Default PDF viewer # R_PDFVIEWER=${R_PDFVIEWER-'open'} # MAKE=${MAKE-make} SED=${SED-sed} # CPLEX_STUDIO_DIR=C:/Program Files/IBM/ILOG/CPLEX_Studio127 CPLEX_STUDIO_LIB=C:/Program Files/IBM/ILOG/CPLEX_Studio127/cplex/bin/x64_win64

  1. In Environment Variables System Variables Path I had already added:在我已经添加的Environment Variables System Variables Path

%CPLEX_STUDIO_BINARIES127%; C:\\Program Files (x86)\\Intel\\OpenCL SDK\\6.1\\bin\\x64; C:\\Program Files (x86)\\Intel\\OpenCL SDK\\6.1\\bin\\x86; C:\\Program Files (x86)\\Intel\\OpenCL SDK\\6.1\\bin\\Pin; C:\\Program Files (x86)\\Intel\\OpenCL SDK\\6.1\\bin\\GTPin; C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\bin; C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\libnvvp; C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\; C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem; C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\; C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL; C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL; C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT; C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT; C:\\Program Files (x86)\\Skype\\Phone\\; C:\\Program Files\\MATLAB\\R2016b\\bin; C:\\Program Files\\MATLAB\\R2016a\\bin; C:\\Program Files\\Microsoft\\MRO-3.3.1\\bin\\x64; C:\\Users\\zejas\\.dnx\\bin;C:\\Program Files\\Microsoft DNX\\Dnvm\\; C:\\Program Files\\Microsoft SQL Server\\130\\Tools\\Binn\\; C:\\Program Files (x86)\\Windows Kits\\8.1\\Windows Performance Toolkit\\; C:\\WINDOWS\\system32;C:\\WINDOWS; C:\\WINDOWS\\System32\\Wbem; C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\; C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common; C:\\Program Files\\Git\\cmd; C:\\Program Files\\IBM\\ILOG\\CPLEX_Studio127\\cplex\\bin\\x64_win64; C:\\Program Files\\IBM\\ILOG\\CPLEX_Studio127\\cplex\\include; C:\\Rtools\\bin

  1. I rebuild the package:我重建包:

C:\\Users\\zejas>R CMD build --no-build-vignettes --no-manual --md5 C:\\Users\\zejas\\Desktop\\cplexAPI\\cplexAPI * checking for file 'C:\\Users\\zejas\\Desktop\\cplexAPI\\cplexAPI/DESCRIPTION' ... OK * preparing 'cplexAPI': * checking DESCRIPTION meta-information ... OK * cleaning src * checking vignette meta-information ... OK * checking for LF line-endings in source and make files * checking for empty or unneeded directories * adding MD5 file * building 'cplexAPI_1.3.2.tar.gz' Warning: file 'cplexAPI/cleanup' did not have execute permissions: corrected Warning: file 'cplexAPI/configure' did not have execute permissions: corrected

  1. I attempt install of the package:我尝试安装软件包:

C:\\Users\\zejas>"C:\\Program Files\\Microsoft\\MRO-3.3.1\\bin\\x64\\R.exe" CMD INSTALL --build --no-multiarch ./cplexAPI.tar.gz * installing to library 'C:/Users/zejas/Documents/R/win-library/3.3' * installing *source* package 'cplexAPI' ... ** package 'cplexAPI' successfully unpacked and MD5 sums checked ** libs c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I":\\Program Files\\IBM\\ILOG\\CPLEX_Studio127\\cplex\\include" -I"C:/swarm/workspace/External- R-3.3.1/vendor/extsoft/include" -O2 -Wall -std=gnu99 -mtune=core2 -c cplexAPI.c -o cplexAPI.o In file included from cplexAPI.h:26:0, from cplexAPI.c:26: cplexR.h:50:27: fatal error: ilcplex/cplex.h: No such file or directory #include <ilcplex/cplex.h> ^ compilation terminated. make: *** [cplexAPI.o] Error 1 Warning: running command 'make -f "Makevars.win" -f "C:/PROGRA~1/MICROS~1/MRO-33~1.1/etc/x64/Makeconf" -f "C:/PROGRA~1/MICROS~1/MRO- 33~1.1/share/make/winshlib.mk" SHLIB="cplexAPI.dll" WIN=64 TCLBIN=64 OBJECTS="cplexAPI.o cplexR.o cplex_checkAPI.o cplex_longparamAPI.o init.o"' had status 2 ERROR: compilation failed for package 'cplexAPI' * removing 'C:/Users/zejas/Documents/R/win-library/3.3/cplexAPI'

There absolutely is a cplex.h file in that directory!该目录中绝对有一个cplex.h文件!

C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include\ilcplex>dir

 Volume in drive C is OS
 Volume Serial Number is 0A1B-3F26
 Directory of C:\Program    Files\IBM\ILOG\CPLEX_Studio127\cplex\include\ilcplex
01/09/2017  10:43 AM    <DIR>          .
01/09/2017  10:43 AM    <DIR>          ..
01/09/2017  10:43 AM             2,499 annotation.xsd
01/09/2017  10:43 AM            72,321 cplex.h
01/09/2017  10:43 AM             6,429 cplexcheck.h
01/09/2017  10:43 AM             1,703 cplexdistmip.h
01/09/2017  10:43 AM             1,857 cplexdistmipl.h
01/09/2017  10:43 AM             1,857 cplexdistmips.h
01/09/2017  10:43 AM             2,569 cplexdistmipx.h
01/09/2017  10:43 AM            76,659 cplexl.h
01/09/2017  10:43 AM             2,826 cplexremote.h
01/09/2017  10:43 AM             2,944 cplexremotel.h
01/09/2017  10:43 AM           111,312 cplexremotemaster.h
01/09/2017  10:43 AM           107,895 cplexremotemasterl.h
01/09/2017  10:43 AM           107,777 cplexremotemasters.h
01/09/2017  10:43 AM           220,496 cplexremotemasterx.h
01/09/2017  10:43 AM             2,944 cplexremotes.h
01/09/2017  10:43 AM             3,379 cplexremoteworker.h
01/09/2017  10:43 AM             3,505 cplexremoteworkerl.h
01/09/2017  10:43 AM             3,511 cplexremoteworkers.h
01/09/2017  10:43 AM             4,554 cplexremoteworkerx.h
01/09/2017  10:43 AM             3,289 cplexremotex.h
01/09/2017  10:43 AM            76,354 cplexs.h
01/09/2017  10:43 AM           119,712 cplexx.h
01/09/2017  10:43 AM            70,061 cpxconst.h
01/09/2017  10:43 AM               675 ilm.h
01/09/2017  10:43 AM             7,158 ilocarray.h
01/09/2017  10:43 AM           186,959 ilocplex.h
01/09/2017  10:43 AM           205,973 ilocplexi.h
01/09/2017  10:43 AM            13,174 iloextrmgr.h
01/09/2017  10:43 AM            13,496 ilogoals.h
01/09/2017  10:43 AM            15,241 iloparam.h
01/09/2017  10:43 AM             5,705 solution.xsd
01/09/2017  10:43 AM             5,504 solution.xsl
01/09/2017  10:43 AM             1,397 vmc.dtd
01/09/2017  10:43 AM             2,837 vmc.xsd
34 File(s)      1,464,572 bytes
2 Dir(s)  333,053,566,976 bytes free

Any ideas?有任何想法吗?


Update with input from @c0bra and @rkersh使用来自 @c0bra 和 @rkersh 的输入进行更新

I update Makevars.win :我更新Makevars.win

PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"
PKG_LIBS=-L"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\lib" -lm -lcplex1270

Rebuild at the command line:在命令行重建:

C:\Users\zejas>R CMD build --no-build-vignettes --no-manual  --md5     C:\Users\zejas\Desktop\cplexAPI\cplexAPI
* checking for file 'C:\Users\zejas\Desktop\cplexAPI\cplexAPI/DESCRIPTION' ... OK
* preparing 'cplexAPI':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking vignette meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* adding MD5 file
* building 'cplexAPI_1.3.2.tar.gz'
Warning: file 'cplexAPI/cleanup' did not have execute permissions: corrected
Warning: file 'cplexAPI/configure' did not have execute permissions: corrected

I attempt to install from the command line:我尝试从命令行安装:

C:\Users\zejas>"C:\Program Files\Microsoft\MRO-3.3.1\bin\x64\R.exe" CMD  INSTALL --build --no-multiarch .\cplexAPI_1.3.2.tar.gz
* installing to library 'C:/Users/zejas/Documents/R/win-library/3.3'
* installing *source* package 'cplexAPI' ...
** package 'cplexAPI' successfully unpacked and MD5 sums checked
** libs
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplexAPI.c -o cplexAPI.o
cplexAPI.c: In function 'addChannel':
cplexAPI.c:5198:5: warning: implicit declaration of function 'CPXaddchannel' [-Wimplicit-function-declaration]
     newch = CPXaddchannel(R_ExternalPtrAddr(env));
     ^
cplexAPI.c:5198:11: warning: assignment makes pointer from integer without a cast
     newch = CPXaddchannel(R_ExternalPtrAddr(env));
           ^
cplexAPI.c: In function 'delChannel':
cplexAPI.c:5234:5: warning: implicit declaration of function 'CPXdelchannel' [-Wimplicit-function-declaration]
     CPXdelchannel(R_ExternalPtrAddr(env), &delch);
     ^
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplexR.c -o cplexR.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplex_checkAPI.c -o cplex_checkAPI.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplex_longparamAPI.c -o cplex_longparamAPI.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c init.c -o init.o
c:/Rtools/mingw_64/bin/gcc -m64 -shared -s -static-libgcc -o cplexAPI.dll tmp.def cplexAPI.o cplexR.o cplex_checkAPI.o cplex_longparamAPI.o init.o -LC:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\lib -lm -lcplex1270 -LC:/swarm/workspace/External-R-3.3.1/vendor/extsoft/lib/x64 -LC:/swarm/workspace/External-R-3.3.1/vendor/extsoft/lib -LC:/PROGRA~1/MICROS~1/MRO-33~1.1/bin/x64 -lR
C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcplex1270
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'cplexAPI'
* removing 'C:/Users/zejas/Documents/R/win-library/3.3/cplexAPI'

I edit Makevars.win我编辑 Makevars.win

PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"
PKG_LIBS=-L"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include/lib" -lm -lcplex1270

I rebuild:我重建:

C:\Users\zejas>R CMD build --no-build-vignettes --no-manual  --md5 C:\Users\zejas\Desktop\cplexAPI\cplexAPI
* checking for file 'C:\Users\zejas\Desktop\cplexAPI\cplexAPI/DESCRIPTION' ... OK
* preparing 'cplexAPI':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking vignette meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* adding MD5 file
* building 'cplexAPI_1.3.2.tar.gz'
Warning: file 'cplexAPI/cleanup' did not have execute permissions: corrected
Warning: file 'cplexAPI/configure' did not have execute permissions: corrected

I attempt to install:我尝试安装:

C:\Users\zejas>"C:\Program Files\Microsoft\MRO-3.3.1\bin\x64\R.exe" CMD  INSTALL --build --no-multiarch .\cplexAPI_1.3.2.tar.gz
* installing to library 'C:/Users/zejas/Documents/R/win-library/3.3'
* installing *source* package 'cplexAPI' ...
** package 'cplexAPI' successfully unpacked and MD5 sums checked
** libs
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplexAPI.c -o cplexAPI.o
cplexAPI.c: In function 'addChannel':
cplexAPI.c:5198:5: warning: implicit declaration of function 'CPXaddchannel' [-Wimplicit-function-declaration]
     newch = CPXaddchannel(R_ExternalPtrAddr(env));
     ^
cplexAPI.c:5198:11: warning: assignment makes pointer from integer without a cast
     newch = CPXaddchannel(R_ExternalPtrAddr(env));
           ^
cplexAPI.c: In function 'delChannel':
cplexAPI.c:5234:5: warning: implicit declaration of function 'CPXdelchannel' [-Wimplicit-function-declaration]
     CPXdelchannel(R_ExternalPtrAddr(env), &delch);
     ^
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplexR.c -o cplexR.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplex_checkAPI.c -o cplex_checkAPI.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplex_longparamAPI.c -o cplex_longparamAPI.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c init.c -o init.o
c:/Rtools/mingw_64/bin/gcc -m64 -shared -s -static-libgcc -o cplexAPI.dll tmp.def cplexAPI.o cplexR.o cplex_checkAPI.o cplex_longparamAPI.o init.o -LC:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include/lib -lm -lcplex1270 -LC:/swarm/workspace/External-R-3.3.1/vendor/extsoft/lib/x64 -LC:/swarm/workspace/External-R-3.3.1/vendor/extsoft/lib -LC:/PROGRA~1/MICROS~1/MRO-33~1.1/bin/x64 -lR
C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcplex1270
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'cplexAPI'
* removing 'C:/Users/zejas/Documents/R/win-library/3.3/cplexAPI'

Those are new errors!这些都是新的错误!

For me it looks as you have left the $ signs in front of the paths in the Makevars.win file.对我来说,看起来你在 Makevars.win 文件中的路径前面留下了 $ 符号。 Please try to correct to:请尝试更正为:

PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"
PKG_LIBS=-L"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\lib" -lm -lcplex1270

edit2: As baydoganm pointed out there are two functions missing in cplex 1270. When removing those, cplexAPI compiles fine with windows, too: cplexAPI_1.3.3.tar.gz编辑 2:正如 baydoganm 指出的,cplex 1270 中缺少两个函数。删除这些函数时,cplexAPI 也可以在 Windows 中正常编译: cplexAPI_1.3.3.tar.gz

I was facing similar problem while integrating CPLEX with R, and installing the cplexAPI package, see https://cran.r-project.org/web/packages/cplexAPI/ there were few mistakes that I was doing, first of all, the problem arises because R does not know where IBM CPLEX is installed, so you have to manually change the file Makevars.win in the cplexAPI_1.3.3.tar.gz package that is downloaded while you were trying to install cplexAPI from rstudio GUI.在将 CPLEX 与 R 集成并安装 cplexAPI 包时,我遇到了类似的问题,请参阅https://cran.r-project.org/web/packages/cplexAPI/我在做的错误很少,首先,问题出现了,因为R不知道安装了IBM CPLEX哪里,所以你必须手动更改文件Makevars.win中,而你正在试图从rstudio GUI安装cplexAPI所下载的cplexAPI_1.3.3.tar.gz包。 look for following codes:寻找以下代码:

PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I"${CPLEX_STUDIO_DIR}\cplex\include"
PKG_LIBS=-L"${CPLEX_STUDIO_LIB}" -lm -lcplex1261

two thing that you need to check is -L"${CPLEX_STUDIO_LIB}" is replaced by in my case, -L"C:/Program Files/IBM/ILOG/CPLEX_Studio1271/cplex/bin/x64_win64" (see bin/x64_win64) , replace $ too您需要检查的两件事是-L"${CPLEX_STUDIO_LIB}"在我的情况下被替换为-L"C:/Program Files/IBM/ILOG/CPLEX_Studio1271/cplex/bin/x64_win64" (请参阅 bin/x64_win64) , 也替换$

second inside the folder x64_win64, look for cplex12**.dll file, this the file where -lcplex1261 is pointing to, here manually change -lcplex1261 to whatever your file name is (in my case it was cplex1271.dll, so I changed -lcplex1261 to -lcplex1271,在文件夹 x64_win64 中的第二个,查找cplex12**.dll文件,这是 -lcplex1261 指向的文件,这里手动将 -lcplex1261 更改为您的文件名(在我的情况下是 cplex1271.dll,所以我更改了 - lcplex1261 到 -lcplex1271,

similarly ${CPLEX_STUDIO_DIR} must be replaced by C:/Program Files/IBM/ILOG/CPLEX_Studio1271 (in my case).同样, ${CPLEX_STUDIO_DIR}必须替换为C:/Program Files/IBM/ILOG/CPLEX_Studio1271 (在我的情况下)。

After this, follow the instruction given in https://www.r-bloggers.com/using-cplex-in-r-installing-cplexapi-in-windows-10/ , essentially use the following command (from command lines) to repackage and install cplexAPI_1.3.3.tar.gz (make sure you have Rtools installed, and make sure environment variables have PATH pointing to installation files of R, essentially taking to R.exe and Rcmd.exe for the commands to run), and在此之后,按照https://www.r-bloggers.com/using-cplex-in-r-installing-cplexapi-in-windows-10/ 中给出的说明,基本上使用以下命令(从命令行)重新打包并安装 cplexAPI_1.3.3.tar.gz(确保安装了 Rtools,并确保环境变量的 PATH 指向 R 的安装文件,本质上是使用 R.exe 和 Rcmd.exe 来运行命令),以及

R CMD build --no-build-vignettes --no-manual --md5 C:\Users{computer name here}\Desktop\cplexAPI

R CMD INSTALL --build --no-multiarch .\cplexAPI_1.3.3.tar.gz

I have the exactly same problem and could not find a way to install the packages although tried everything similar to the post here.我有完全相同的问题,虽然尝试了与此处帖子类似的所有内容,但找不到安装软件包的方法。 I am not sure if the problem is related to a version change in the CPLEX after the package is released.我不确定该问题是否与发布包后 CPLEX 中的版本更改有关。

Edit: I was able to confirm the problem.编辑:我能够确认问题。 Apparently callable library elements addchannel, delchannel together with several others are removed in version 12.7.显然可调用的库元素 addchannel、delchannel 以及其他几个在 12.7 版中被删除。 Here is the link:链接在这里:

http://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.0/ilog.odms.cplex.help/CPLEX/ReleaseNotes/topics/releasenotes127/removed.html http://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.0/ilog.odms.cplex.help/CPLEX/ReleaseNotes/topics/releasenotes127/removed.html

In one of the package's source files, it has already been mentioned that "R Interface to C API of IBM ILOG CPLEX Version 12.1 to 12.6."在包的源文件之一中,已经提到“IBM ILOG CPLEX 版本 12.1 到 12.6 的 C API 的 R 接口”。

Looks like downgrading cplex will help.看起来降级 cplex 会有所帮助。

GNU R package cplexAPI: R Interface to C API of IBM ILOG CPLEX GNU R 包 cplexAPI:IBM ILOG CPLEX 的 C API 的 R 接口

The installation procedure for the cplexAPI package needs to know where to find the CPLEX include directory and where to find the callable library. cplexAPI 包的安装过程需要知道在哪里可以找到 CPLEX 包含目录以及在哪里可以找到可调用库。

I have a very large mixed integer problem to solve.我有一个非常大的混合整数问题要解决。 COIN's solver accessed through Rsymphony did a decent job, but had trouble finding feasible solutions.通过 Rsymphony 访问的 COIN 求解器做得不错,但很难找到可行的解决方案。 I had been told that the IBM cplex solver was the best on the market for mixed integer programming.有人告诉我 IBM cplex 求解器是市场上最好的混合整数规划。

Installing cplex is a relatively easy task.安装 cplex 是一项相对容易的任务。 The difficulties began when I tried to install a link from R. Either cplexAPI or Rcplex.当我尝试从 R 安装链接时,困难就开始了。cplexAPI 或 Rcplex。 You can search and see that there is very little helpful information in the usual places.你可以搜索一下,发现在平常的地方,有用的信息很少。 I reached out to the developers and Jonathan of cplexAPI responded with very helpful troubleshooting and instructions.我联系了开发人员,cplexAPI 的 Jonathan 回复了非常有用的故障排除和说明。

We (honestly, all Jonathan) determined that the following sequence should correctly install cplexAPI.我们(老实说,所有 Jonathan)确定以下顺序应该正确安装 cplexAPI。 First, read the directions.首先,阅读说明。

  1. After downloading, unpack the .tar.gz file someplace.下载后,将 .tar.gz 文件解压到某处。 I am going to unpack mine on the desktop.我要在桌面上打开我的包装。

  2. Open the newly created folder cplexAPI and you will find a directory labeled src.打开新创建的文件夹 cplexAPI,你会发现一个名为 src 的目录。 Open the Makevars.win file within that folder.打开该文件夹中的 Makevars.win 文件。 I have Notepad++ installed, so I right click Makevars.win and open withNotepad++.我安装了 Notepad++,所以我右键单击 Makevars.win 并使用 Notepad++ 打开。 The instructions note that you will need to find each of these directories and type them in. They may (and probably will if you are using any other version).说明指出,您需要找到这些目录中的每一个并输入它们。它们可能(如果您使用任何其他版本,也可能会)。

PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I"C:/Program Files/IBM/ILOG/CPLEX_Studio127/cplex/include" PKG_LIBS=-L"C:/Program Files/IBM/ILOG/CPLEX_Studio127/cplex/bin/x64_win64" -lm -lcplex1270 PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I"C:/Program Files/IBM/ILOG/CPLEX_Studio127/cplex/include" PKG_LIBS=-L"C:/Program Files/IBM/ILOG/CPLEX_Studio127/cplex/ bin/x64_win64" -lm -lcplex1270

After saving you will need to repackage cplexAPI.保存后,您需要重新打包 cplexAPI。 Head over to the command line (remember I unpacked my tar.gz file on my desktop) and use the command:转到命令行(请记住,我在桌面上解压了 tar.gz 文件)并使用以下命令:

3. 3.

a.一种。 goto C:\\Users{{your name here}}\\Documents\\R\\win-library\\3.5转到 C:\\Users{{你的名字在这里}}\\Documents\\R\\win-library\\3.5

b.create a new folder called cplexAPI创建一个名为 cplexAPI 的新文件夹

c. C。 Create another folder inside cplexAPI called libs在 cplexAPI 中创建另一个名为 libs 的文件夹

d. d. Create another folder inside libs called x64在 libs 中创建另一个名为 x64 的文件夹

so, you have this folder C:\\Users{{your name here}}\\Documents\\R\\win-library\\3.5\\cplexAPI\\libs\\x64所以,你有这个文件夹 C:\\Users{{你的名字在这里}}\\Documents\\R\\win-library\\3.5\\cplexAPI\\libs\\x64

The goto the installation folder for CPLEX application C:\\Program Files\\IBM\\ILOG\\CPLEX_Enterprise_Server1210\\CPLEX_Studio\\cplex\\bin\\x64_win64 and copy the file cplex12100.dll into the folder C:\\Users{{your name here}}\\Documents\\R\\win-library\\3.5\\cplexAPI\\libs\\x64转到 CPLEX 应用程序的安装文件夹 C:\\Program Files\\IBM\\ILOG\\CPLEX_Enterprise_Server1210\\CPLEX_Studio\\cplex\\bin\\x64_win64 并将文件 cplex12100.dll 复制到文件夹 C:\\Users{{your name here}}\\Documents \\R\\win-library\\3.5\\cplexAPI\\libs\\x64

  1. R CMD build --no-build-vignettes --no-manual --md5 C:\\Users{your name here}\\Desktop\\cplexAPI R CMD build --no-build-vignettes --no-manual --md5 C:\\Users{你的名字在这里}\\Desktop\\cplexAPI

This will repackage the folder, avoiding the md5 error you can find while searching for solutions.这将重新打包文件夹,避免您在搜索解决方案时发现的 md5 错误。 After a successful repackage you can then install the package at the command line.成功重新打包后,您可以在命令行安装该包。

  1. R CMD INSTALL --build --no-multiarch .\\cplexAPI_1.3.3.tar.gz R CMD INSTALL --build --no-multiarch .\\cplexAPI_1.3.3.tar.gz

At this point, you may have errors.此时,您可能会遇到错误。 The key you are looking for is this output:您正在寻找的关键是这个输出:

packaged installation of 'cplexAPI' as cplexAPI_1.3.3.zip DONE (cplexAPI)将“cplexAPI”打包安装为 cplexAPI_1.3.3.zip DONE (cplexAPI)

Credit to https://jholderieath.wordpress.com/2017/01/26/using-cplex-in-r-installing-cplexapi-in-windows-10/ https://github.com/cran/cplexAPI/blob/master/inst/INSTALL归功于https://jholderieath.wordpress.com/2017/01/26/using-cplex-in-r-installing-cplexapi-in-windows-10/ https://github.com/cran/cplexAPI/blob/主/安装/安装

This procedure was tested successfully with IBM ILOG CPLEX 12.10此过程已使用 IBM ILOG CPLEX 12.10 成功测试
on 64-bit Windows 10 using Rtools 3.5.在使用 Rtools 3.5 的 64 位 Windows 10 上。

Example:例子:

library(cplexAPI)
 env <- openEnvCPLEX()
 prob <- initProbCPLEX(env)
 chgProbNameCPLEX(env, prob, "sample")
nc <- 3
 nr <- 3
 obj <- c(5, 4, 3)
 rhs <- c(5, 11, 8)
 sense <- rep("L", 3)
 lb <- rep(0, 3)
ub <- rep(CPX_INFBOUND, 3)
 cn <- c("x1", "x2", "x3")
 
rn <- c("q1", "q2", "q3")
beg <- c(0, 3, 6)

beg <- c(0, 3, 6)

 cnt <- rep(3, 3)
 ind <- c(0, 1, 2, 0, 1, 2, 0, 1, 2)
 val <- c(2, 4, 3, 3, 1, 4, 1, 2, 2)

copyLpwNamesCPLEX(env, prob, nc, nr, CPX_MAX, obj, rhs, sense, beg, cnt, ind, val, lb, ub, NULL, cn, rn)
lpoptCPLEX(env, prob)
 solutionCPLEX(env, prob)

https://github.com/bayesteecal/cplexAPI/blob/master/inst/INSTALL https://github.com/bayesteecal/cplexAPI/blob/master/inst/INSTALL

It took me some time to figure it out, but here is my solution:我花了一些时间才弄明白,但这是我的解决方案:

As user3575499 already pointed out, there is a good explanation on how to install cplexAPI at https://www.r-bloggers.com/2017/01/using-cplex-in-r-installing-cplexapi-in-windows-10/ .正如 user3575499 已经指出的,在https://www.r-bloggers.com/2017/01/using-cplex-in-r-installing-cplexapi-in-windows-10上有一个关于如何安装 cplexAPI 的很好的解释/ .

However, after following those instructions, you might get the following error:但是,按照这些说明操作后,您可能会收到以下错误:

"C:\\Program Files\\IBM\\ILOG\\CPLEX_Studio_Community129\\cplex\\include/ilcplex/cpxconst.h:243:62: error: expected ')' before 'deprecated' # define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)" “C:\\

The solution to this error is to add "-DBUILD_CPXSTATIC" at the end of the first line of Makevars.win, so that the file looks something like this:解决这个错误的方法是在Makevars.win的第一行末尾添加“-DBUILD_CPXSTATIC”,使文件看起来像这样:

PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I"${CPLEX_STUDIO_DIR}\cplex\include" -DBUILD_CPXSTATIC
PKG_LIBS=-L"${CPLEX_STUDIO_LIB}" -lm -lcplex1261

After you changed that file just follow the instructions again and you should be fine.更改该文件后,只需再次按照说明操作即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM