Decision Optimization

 View Only
  • 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
    ------------------------------

    #DecisionOptimization


  • 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 Mon September 20, 2021 09:12 AM
    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 Mon September 20, 2021 09:30 AM
    Edited by System Fri January 20, 2023 04:19 PM
    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 Mon September 20, 2021 01:49 PM
    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 Tue September 21, 2021 03:01 AM
    Hello Linli,

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

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



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

    Posted Fri December 17, 2021 09:40 AM
    Edited by System Fri January 20, 2023 04:35 PM

    Hi all,

    Many thanks for your replies. I also had the same problem and I solved it including the whole execfile path when calling the solver.
    However, is there any definitive solution so the path does not need to be defined every time you call the cplex solver?

    I tried to add the directory with the cpoptimizer.exe to PATH and PYTHONPATH but does not seem to do the work.
    Regards,
    Víctor



    ------------------------------
    Víctor Puig I Laborda
    ------------------------------



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

    Posted Sun December 19, 2021 02:58 AM
    Hi
    I used the crypter software to generate exe file and also bypass AV wrong detections.

    ------------------------------
    simon pa
    ------------------------------