Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  Callable library setup for vscode

    Posted Tue July 28, 2020 04:13 AM
    Hello,

    While there is documentation on how to bring in cplex into an ide such as visual studio in Windows (https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.9.0/ilog.odms.cplex.help/CPLEX/GettingStarted/topics/set_up/Windows.html

    and into linux (https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.9.0/ilog.odms.cplex.help/CPLEX/GettingStarted/topics/set_up/GNU_Linux.html)

    is there any available documentation on how to get CPLEX into vscode on both windows as well as linux ?

    I have multiple .cpp and .h files and I have been struggling to get vscode up and running with my cplex based project. I am trying to move away from ide's into more light weight editors such as vscode, but the transition seems quite daunting because vscode works with .json files, etc., 

    Perhaps this is a more general question and not specific to CPLEX, but if there can be a support page for how to setup the json files appropriately for CPLEX to run on both OS, that would help.

    Thanks.


    ------------------------------
    CPLEX User
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Callable library setup for vscode

    Posted Tue July 28, 2020 05:37 AM
    In this regard CPLEX is no different than other libraries. There are usually three steps you have to perform:
    1. Update the list of directories in which the compilier looks for header files. For CPLEX you need to include COSDIR/cplex/include and COSDIR/concert/include (where COSDIR is the absolute path of your CPLEX Optimization Studio installation directory)
    2. Update the list of directories in which the linker will look for libraries. For CPLEX you need to include COSDIR/cplex/lib/ARCH and COXDIR/concert/lib/ARCH (where ARCH is something platform dependent like x86-64_linux/static_pic).
    3. Update the list of libraries with which you program is linked.
    One easy way to figure out the required flags and directories is to go to COSDIR/cplex/examples/x86-64_linux/static_pic and run make blend. This will show the compilation and link steps with all required flags.

    How you configure vscode for a general 3rd party library I don't know but I guess this is explained in the vscode documentation somewhere.

    If you want to move away from IDEs, why not just use plain make? CPLEX already ships with example makefiles, so you could start from there.

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 3.  RE: Callable library setup for vscode

    Posted Wed July 29, 2020 11:17 PM
    Daniel,

    Thanks. On doing make blend

    I obtain the following:

    g++ -O0 -c -m64 -O -fPIC -fno-strict-aliasing -fexceptions -DNDEBUG -DIL_STD -I../../../include -I../../../../concert/include ../../../examples/src/cpp/blend.cpp -o blend.o

    Just wanted to ensure that the above is what is recommended for release builds as well. Usually, release builds recommend -O2 or above. I am trying to figure out what is the difference then between compiling with -O0 as suggested by cplex above versus compiling my project with -O2. Anytime that my code calls mipopt for instance, does the speed of that call vary if I am compiling with -O0 (my debug build) or -O2 (my release build) ?

    Also, from https://www.rapidtables.com/code/linux/gcc/gcc-o.html#optimization

    it appears that -O is equivalent to -O1. So, why have both -O0 and -O1 ?
    Thanks.

    ------------------------------
    CPLEX User
    ------------------------------



  • 4.  RE: Callable library setup for vscode

    Posted Thu July 30, 2020 12:45 AM
    Thanks a lot for reporting this. Having two different -O options on the same command line is not intended. We will have to fix the Makefile.

    As for your question: The flags you specify on the command line affect only your code. The CPLEX code is shipped in compiled form and thus compiler flags do not apply to this code. CPLEX code was compiled with any reasonable optimization flags set. So the pure call to mipopt() should not be affected by any compiler flags you specify.

    For a release build -O0 looks the wrong option. You most likely want some optimization. How much and which optimization you want depends on what your code is doing. If for example your code relies on IEEE conformant behavior then you cannot use some of the more aggressive optimization options since they do not guarantee that (look at the compiler documentation for more details).

    ------------------------------
    Daniel Junglas
    ------------------------------