Error using getvalue

Your last loop is overwriting the variable r with the constraint r, the message is clear, the value inside r is a constraint not a variable. Also, getvalue is from old JuMP versions (0.18 and before). I recommend creating a new project/environment where you install JuMP first to get the latest version and use it. For example:

$ mkdir my_project
$ cd my_project
$ julia
julia> import Pkg
julia> Pkg.activate(".") # this will create Project.toml and Manifest.toml in the folder
julia> Pkg.add("JuMP")
julia> Pkg.add("GLPK") # do not add GLPKMathProgInterface this is obsolete
julia> include("your_code.jl") # to run your code

When you open the REPL again you need to repeat the two first steps to enter the right environment. Also, you should not have all these variables and for loops in global scope, put then inside a function and then you can redefine the function however you like inside the REPL itself.

2 Likes