Help in using the Cbc solver

Could someone help me in using Cbc. I don’t know what happens but every time I try to compile an error message appears.
I’m using JuMP v0.18.6 and Cbc v0.7.1, I tried to update these packages but I couldn’t.
Thank you!

using JuMP, Cbc, MathOptInterface
m = Model(Cbc.Optimizer)

Which is the error message?

Hi @Henrique_Becker
This is the error message that appears to me

MethodError: no method matching Model(::Type{Cbc.Optimizer})

In the topic of updating JuMP, I think it is useful to understand environments.

When you start the REPL and install a package, it goes in your default environment, the one used if you do not select any specific environment.

However, it is useful to have many separate environments for each project of yours, so when you want to run some project you can immediately restore the exact same versions of the same packages used last time and the packages and versions of other projects do not disturb your current project.

So, I would suggest you to do the following.

  1. If you do not have a folder for this project of yours create one, and put your code inside.
  2. With the terminal/console inside the folder call julia.
  3. import Pkg; Pkg.activate(".") will change your environment from the default to your folder.
  4. You can check if you are in a new environment by using Pkg.status() it will show no packages installed.
  5. Now you can install JuMP with Pkg.add("JuMP"). Now two files named Project.toml and Manifest.toml should have appeared in your folder, are they that save your environment, so do not mess with them unless you know what you are doing.
  6. Use Pkg.status() to see JuMP installed and check which version was installed, it will probably be the 0.21.5.
  7. Do Pkg.add("PackageName") for the next package you need and check Pkg.status() after, do it until you have all packages you want in the right version, or some package changes the version of JuMP to an older version. If this happens post the output of the Pkg.status() before and after the downgrade here, so we can discover why this package is holding JuMP back.

Also, if you close the REPL and open it again, to go back to the environment you were using you need to either do Pkg.activate(".") again. Or you can start Julia already in the right environment by using julia --project=@.. In both cases your console need to already be inside the folder with the toml files, or you need to replace the . (the dot) in these commands by the path to the folder with the toml files.

Hi @Henrique_Becker

When I try to add Julia, the following error message appears:
ERROR: KeyError: key "Artifacts" not found

And even following the step by step, when I managed to install JuMP the old version still appears

If you are using windows can you delete the file:

C:\Users\<your username>\.julia\registries

And try following the steps again? (i.e., create a new folder or remove the toml files to start from scratch)

The first Pkg.add will probably take a lot more time. Do not worry about this.

Also, what version of Julia are you using, you mentioned JuMP and Cbc versions but not Julia.

Ok, I’ll try again
I’m using JuliaPro v1.5.2-1

Ah, JuliaPro is often a source of problems in this forum. If doing what I suggested do not work then I suggest you avoid using JuliaPro and just use Julia instead (if possible). I heard using Chocolatey to install pure Julia on Windows is straightforward (see Chocolatey Software | Julia programming language 1.5.3).


Hi @Henrique_Becker
I followed your advice and downloaded Julia through Chocolatey, but I only managed to download PowerShell.
Is it possible to download a friendly IDE for Julia through chocolatey?

I have never used one, I edit my files with vim (on Linux) and run Julia through the command line.

I am not sure if there is an IDE already configured, but Chocolatey allows downloading Visual Studio Code and there are steps to configure Julia on it. Probably there are other options too, but I do not use windows, nor graphical IDEs, since long ago, so I am not the best person to ask about it.

Juno does not seem to be a good option as it comes with JuliaPRO.

1 Like

Juno can be used with any Julia version, not just JuliaPro (JuliaPro just bundles Atom/Juno with Julia).