Comments (4)
I don't know about this specific case. We'd have to intercept the method (::Colon)(::Int64, ::VariableRef)
. The issue is 1:a
, regardless of the fact it appears in an @variable
macro. But if we intercepted the method, we wouldn't be able give a good error message for the macro. We also can't tell, syntactically looking at @variable(model, b[1:a], Int)
that a
is a variable.
What we should do is improve the general case in which an error is thrown during parsing of the macro, because it is currently:
julia> @variable(model, b[1:a])
ERROR: MethodError: no method matching (::Colon)(::Int64, ::VariableRef)
Closest candidates are:
(::Colon)(::T, ::Any, ::T) where T<:Real
@ Base range.jl:50
(::Colon)(::A, ::Any, ::C) where {A<:Real, C<:Real}
@ Base range.jl:10
(::Colon)(::T, ::Any, ::T) where T
@ Base range.jl:49
...
Stacktrace:
[1] macro expansion
@ ~/.julia/dev/JuMP/src/macros.jl:375 [inlined]
[2] top-level scope
@ REPL[4]:1
from jump.jl.
Same with
using JuMP, SCIP
model = Model(SCIP.Optimizer)
max_a = 10
@variable(model, a, Int)
@variable(model, b[1:max_a], Int)
@constraint(model, [i=1:a], b[i] > 0)
# Should have been @constraint(model, [i=1:max_a], b[i] > 0)
from jump.jl.
What we should do is improve the general case in which an error is thrown during parsing of the macro, because it is currently:
Here's another example, not sure if should go into another issue:
using JuMP, SCIP
model = Model(SCIP.Optimizer)
max_a = 10
@variable(model, a, Int)
@variable(model, b[1:max_a,1:max_a,], Int)
@variable(model, c[1:max_a,1:max_a,], Bin)
@constraint(model, [i=1:max_a, k=1:max_a], b[i,k] == 0
@constraint(model, [i=1:max_a, j=1:max_a], b[i,j] == c[i,j] * b[i,k])
# Should be @constraint(model, [i=1:max_a, j=1:max_a], b[i,j] == c[i,j] * b[i,j])
ParseError:
# Error @ �]8;;file:///home/lebedevri/In[17]#14:1�\In[17]:14:1�]8;;�\
@constraint(model, [i=1:max_a, j=1:max_a], b[i,j] == c[i,j] * b[i,k])
└──────────────────────────────────────┘ ── Expected `)`
Stacktrace:
[1] top-level scope
@ In[17]:14
from jump.jl.
The parse error is because of @constraint(model, [i=1:max_a, k=1:max_a], b[i,k] == 0
. You're missing a )
.
As a comment, none of these are JuMP related. They're all just plain bugs in your code.
from jump.jl.
Related Issues (20)
- Documentation Request: List whether a solver supports Indicator Constraints HOT 4
- Bullet point alignment in bibliography HOT 9
- Multiplication of matrix expression and variables leads to stack overflow and matmul error HOT 4
- Multiple Ranges for variables HOT 3
- Y' when Y is of type ::Matrix{NonlinearExpr} HOT 1
- Poor performance in complementarity models HOT 23
- Add a method for Complex(a,b) HOT 8
- MethodError with empty summations HOT 1
- Nonlinear subexpressions HOT 4
- Should error when trying to mix `NonlinearExpression` and `GenericNonlinearExpr` HOT 1
- Support normalized_coefficient for vector-valued constraints
- Precompilation in CI fails on v1.22 HOT 7
- Fuzzy search on unrecognized keyword arguments to give suggestions HOT 2
- Track failures on nightly HOT 3
- Possibly missing diagnostics for vector of vector of variables HOT 3
- Printing of large vectorized constraints should probably cause output eliding? HOT 5
- Deleting part of containerized constraints makes whole constraint unprintable HOT 2
- function_string of Symmetric matrix includes the entire matrix HOT 7
- Inequality constraints over symmetric matrices are cumbersome HOT 9
- Set inequality syntax suggestion HOT 30
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jump.jl.