4

My goal is to connect the open-source CBC solver with Pyomo in Spyder. I am working on a Windows 10 machine and it is not an option for me to use the NEOS server due to company policy.

I have downloaded the binaries from Bintray (https://bintray.com/coin-or/download/Cbc#files) that include a cbc.exe file. However when trying to run it, several errors come up stating that I am missing files (among other libbz2-1.dll and zlib1.dll). I do not know much about linux or software development but after a lot of time on google I understand that these are used for unpacking data among other things. I found all files except zlib1.dll in a developer chat on the same subject and zlib1.dll I found on another page. However when running I now get the error: “The application was unable to start correctly (0xc000007b).

I have also tried downloading MSYS2 MinGW and followed instructions from CBC. I don’t know if I require this or if it is only for developers.

Can anyone tell me what to do? I suspect other people than myself want to use CBC in Pyomo as an alternative to GLPK.

SimonLindahl
  • 41
  • 1
  • 2

3 Answers3

3

If you already have the .exe file, make sure it is in your current working folder (set as the working directory in Spyder, simply opening your file is not enough) and call it using the SolveFactory function:

opt = SolverFactory("cbc.exe")

results = opt.solve(model)

It works for me.

Miss Chanandler Bong
  • 4,081
  • 10
  • 26
  • 36
gvkcps
  • 51
  • 2
1

You will find some general information here where i outlined some approaches.

While this was targeted at Clp, it also applies to Cbc.

It's a bit strange as i observed too, that some libs are not statically linked (zlib) while it's certainly doable. But as mentioned in the thread, this should not be the case anymore (see the restriction about which files are fully statically linked) and therefore your observation is strange (and you did not say, which file you downloaded).

So i would trying one of the following (in this order):

  • Try again with your source, but stick to the master-versions (see first link) as the maintainer only guaranteed fully-static builds for those!
  • Use the builds from AMPL
    • (tested and works for me; generally recommended in terms of quality/stability of builds)
  • Use the builds from coin-or/pulp, another modelling-tool for python
    • (tested and works for me)
  • Compile from source using mingw64
  • (Use any build and provide some external dll of zlib and co -> hard to debug)

Of course i completely ignored other potential issues:

  • license-stuff (what's part of those builds)
    • not sure if a company can afford to use binaries not build themself in regards to legal stuff
  • version-compatibility with python
    • does every version of Cbc work
  • cbc version + configuration
    • modern version
    • compiled with multi-threading
    • ...
sascha
  • 32,238
  • 6
  • 68
  • 110
0

I also had trouble installing cbc for pyomo on windows 11. I kept getting errors like: Solver (cbc) did not exit normally, etc. Here's a step-by-step process worked for me in the end (for my and other people's future reference).

  1. Go to the AMPL website and download the coin binary for mswin64 (coin.mswin64.YYYYMMDD)

  2. Extract contents to any temporary folder

  3. Copy ALL the contents and paste them to your environment's bin folder. Typically located at:

    C:\Users\user\anaconda3\envs\my_env\Library\bin

  4. Open the anaconda cmd of my_env and get the list of available solvers (look for the '+' symbol before the solver name) by typing: pyomo help -s