Decision Optimization

Expand all | Collapse all

CpoException: Executable file should be given in 'execfile' context attribute.

  • 1.  CpoException: Executable file should be given in 'execfile' context attribute.

    Posted Tue March 30, 2021 01:19 AM
    Hello All,

    When trying to solve this example on a MacOS Big Sur, I get the following error: CpoException: Executable file should be given in 'execfile' context attribute. More specifically, the error is pointed out to msol = mdl.solve(). When I run the same problem on Windows, everything works just fine. Does anyone have any suggestion to fix this problem? Any help is appreciated. Thank you!

    ------------------------------
    Fabio Vitor
    ------------------------------


  • 2.  RE: CpoException: Executable file should be given in 'execfile' context attribute.

    Posted Tue March 30, 2021 04:15 AM
    Hello Fabio,

    The solve of your model is delegated to a subprocess "cpoptimizer(.exe)" that is created when solve() is called. The name of this process is stored in the configuration attribute 'context.solver.local.execfile' and is searched by default in the system path.

    I recommend that you:

    • Check that a cpoptimizer executable is actually present on your disk inside the COS installation directory
    • Ensure this file is actually visible in your system path
    If this does not work, you can try to specify the full path of the executable dynamically inside the solve request, like:
    msol = mdl.solve(execfile='<full path of the cpoptimizer executable>')


    ------------------------------
    Olivier Oudot
    ------------------------------



  • 3.  RE: CpoException: Executable file should be given in 'execfile' context attribute.

    Posted Thu April 01, 2021 04:38 AM
    Thank you Olivier. This worked.

    Best regards.

    ------------------------------
    Fabio Vitor
    ------------------------------



  • 4.  RE: CpoException: Executable file should be given in 'execfile' context attribute.

    Posted 28 days ago
    Hi, Could you please provide more detailed steps for solving this problem? I met the same question, but I'm not sure how to implement the suggestions given above.

    ------------------------------
    Linli Jia
    ------------------------------



  • 5.  RE: CpoException: Executable file should be given in 'execfile' context attribute.

    Posted 28 days ago
    Edited by ALEX FLEISCHER 28 days ago
    Hi,

    let me share the bus example with this :

    from docplex.cp.model import CpoModel
    
    mdl = CpoModel(name='buses')
    nbbus40 = mdl.integer_var(0,1000,name='nbBus40')
    nbbus30 = mdl.integer_var(0,1000,name='nbBus30')
    mdl.add(nbbus40*40 + nbbus30*30 >= 300)
    mdl.minimize(nbbus40*500 + nbbus30*400)
    
    #call CPLEX 20.1
    msol=mdl.solve(execfile='C:\\ILOG\\CPLEX_Studio201\\cpoptimizer\\bin\\x64_win64\\cpoptimizer.exe')
    #call CPLEX 12.10
    msol=mdl.solve(execfile='C:\\ILOG\\CPLEX_Studio1210\\cpoptimizer\\bin\\x64_win64\\cpoptimizer.exe')
    
    print(msol[nbbus40]," buses 40 seats")
    print(msol[nbbus30]," buses 30 seats") ​



    ------------------------------
    [Alex] [Fleischer]
    [EMEA CPLEX Optimization Technical Sales]
    [IBM]
    ------------------------------



  • 6.  RE: CpoException: Executable file should be given in 'execfile' context attribute.

    Posted 28 days ago
    Thank you so much for the example. I guess I understand the path of "execfile" should be defined. But I don't know how and where should I define it... sorry for this stupid question. My system is MacOS Big Sur, CPLEX 20 installed successfully, the command for API with Python also works well in Terminal,...docplex is installed. When runing an example in Python, such a mistake happens:
    Should I make some changes in "solver_local.py"? 

    Thank you so much.

    ------------------------------
    Linli Jia
    ------------------------------



  • 7.  RE: CpoException: Executable file should be given in 'execfile' context attribute.

    Posted 28 days ago
    Hello Linli,

    Please read carefully the topic 2 in this discussion, it answers your question.

    ------------------------------
    Olivier Oudot
    ------------------------------