Using JuMP.fix with a variable indexed by a string


#1

I am trying to fix a variable that I have previously defined as

factors = ["labor", "capital"]
@variable(mymodel, W[f in factors] => 0)

then using
JuMP.fix(W["labor"], 1)

I’m new to Julia/JuMP so this could be simple, but it seems like if I can define a variable over a set of strings I should also be able to fix it, right? What am I missing? Thanks for the help!!


#2

Write a loop:

for f in factors
    JuMP.fix(W[f], 1.0)
emd

#3

I actually found out that my error stems from the Complementarity.jl package rather than my own JuMP.fix implementation. :confused: oh well…