using JuMP,SCS
m=Model(with_optimizer(SCS.Optimizer))
branch=[1 2 0.1
3 4 0.1
4 5 0.2
4 6 0.3
5 6 0.1
]
If we want only the first column of the branch, what we have to do ?
I mean , if I write like this this
S=[(branch[r,1]) for r= 1:size(branch,1)]
@variable(m,v[S])
I’m getting the error.
Like this
ERROR: LoadError: Repeated index 4.0. Index sets must have unique elements.
Please help me
odow
2
You cannot create a JuMP variable with duplicate indices. See, e.g.,
model = Model()
@variable(model, x[[:a, :a, :b]])
x[:a] # Which `:a` is this referring to?
As I said in the other post, you probably intend
model = Model()
@variable(model, v[1:size(branch, 1)])
v[3] # Corresponds to (4, 5, 0.2)
p.s. Please don’t open multiple posts with the same question: Help me with indexing - #4 by varun_yaramasu. It can lead to the answers being split over multiple posts.