When compiling @variabel
on my model, julia displays the following message
Expected ModeloDeterministico to be a JuMP model, but it has type DataType
error(::String, ::Type{T} where T) at error.jl:42
validmodel(::Type{T} where T, ::Symbol) at macros.jl:279
top-level scope at macros.jl:284
Is there another way to declare variables?
I tried to follow a macro but the message kept showing
rdeits
October 5, 2020, 5:38pm
2
The error message is telling you that ModeloDeterministico
should be an instance of type JuMP.Model
, but you actually have a type . If you can create a reproducible example of the problem, it will be easier for us to figure out what went wrong.
Most likely, you have something like:
# This makes `ModeloDeterministico` just another name for the *type* Model
ModeloDerministico = Model
instead of:
# This actually creates a new *instance* of a `Model`
ModeloDerministico = Model()
3 Likes
using JuMP,Cbc
ModelD = Model()
ModelD = Cbc.Optimizer
a = 1:4
A = a
@variable(ModelD,b[A], lower_bound=0, Bin)
In the first compilation this error appeared: In @variable(ModelD,b[A],lower_bound = 0,Bin): Unrecognized keyword argument lower_bound
And in the second compilation this error appeared again: Expected ModeloD to be a JuMP model, but it has type DataType
blegat
October 5, 2020, 8:17pm
5
Which version of JuMP are you using? The syntax you are using is for JuMP v0.19 and higher
rdeits
October 5, 2020, 8:19pm
6
RaquelSantos:
ModelD = Cbc.Optimizer
This line is the problem. You are making ModelD
just an alias for the type Cbc.Optimizer
.
Understand. I put Cbc.Optimizer
because it was a suggestion that appeared in Julia for the compilation
@rdeits Was this the correct way?
ModelD = Model(with_optimizer(Cbc.Optimizer))
@blegat I’m using JuliaPro 1.5.2-1
odow
October 5, 2020, 8:39pm
10
Please read the documentation: https://jump.dev/JuMP.jl/stable/quickstart/
You want ModelD = Model(Cbc.Optimizer)
.
1 Like
Even though I used ModelD = Model (Cbc.Optimizer)
the error message continues: MethodError: no method matches Model (:: Type {Cbc.Optimizer})
I did until the update and the package rm and add again but the error continues.
using JuMP,Cbc
ModeloD = Model()
ModeloD = Model(Cbc.Optimizer)
a = 1:4
A = a
@variable(ModeloD,b[A],lower_bound=0,Bin)
odow
October 6, 2020, 7:58pm
13
After updating packages, you need to close Julia and re-open for the changes to take effect. You need JuMP 0.21 for Model(Cbc.Optimizer)
to work.
Note that discourse has a search function. This question has been asked multiple times recently:
Hello, I’m new in Julia and JuMP and I just tried to install and test JuMP but I got this error (with all solvers that I tested):
julia> Model(Gurobi.Optimizer)
ERROR: MethodError: no method matching Model(::Type{Gurobi.Optimizer})
Closest candidates are:
Model(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at …
Hello,
I am a novice to Julia programming. Going though a tutorial I see myself running into this error and I am not quite sure what it means. Can someone who is an expert in JuMP and GLPK advise?
Error:
MethodError: no method matching Model(::Type{GLPK.Optimizer})
Code:
using Interact
using Plots
using JuMP, GLPK
# Define some input data about the test system
# Maximum power output of generators
const GENERATION_MAX = [1000, 1000]
# Minimum power output of generators
const GENERATION_MIN =…
Hi, I’ve been using JuMP for a project and it stopped working today after I installed Gurobi. I get ERROR: LoadError: MethodError: no method matching Model(::Type{Gurobi.Optimizer}) when I set the solver to Gurobi, but it is also doing this for Ipopt. I have tried downgrading/upgrading the package versions but the same error keeps occurring. What could be causing this?
Thanks.
2 Likes