cplexoplcp-optimizer

How do we programmatically retrieve the software version number of CP Optimizer in OPL?


I'd like to include in my output the version of CP Optimizer (e.g. 12.9) used when solving. I'm working with problems solved under multiple versions of the software, so it'd be helpful to see which version was used while looking at the solution. I can't just check the about menu because I write the results to external files and review them a long time afterward.

Is there a way to programmatically retrieve the version number in OPL?

I'm using OPL inside the provided Oplide. I found the CP.Version property for the .NET interface (https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.9.0/ilog.odms.cpo.help/refdotnetcpoptimizer/html/P_ILOG_CP_CP_Version.htm), but I can't figure out an equivalent in OPL code.


Solution

  • It seems the IloCP scripting class does not export the version number. However, I can see two other ways to get the version:

    Option 1: From an execute or main block you can instantiate the IloCP Java class and use the getVersion() function of that class:

    execute {
       var cpo = IloOplCallJava("ilog.cp.IloCP", "<init>", "()Lilog/cp/IloCP");
       writeln(cpo.getVersion());
       cpo.end();
    }
    

    Option 2: The IloCplex scripting class does provide a getVersion() function. So in a main block you can do

    main {
       writeln(cplex.getVersion());
       // or
       var cpx = new IloCplex();
       writeln(cpx.getVersion());
       cpx.end();
    }
    

    The version number of CP Optimizer and CPLEX are the same.