I’m trying to be able to use values put in a Dictionary to weight the variables that are going to be minimized in a JuMP objective function.
The dictionnary is implemented as follow :
Dicopond = Dict(0=> 1, 1 => 2, 2 => 4, 3 => 8,
4 => 16, 5 => 32, 6 => 64, 7 => 128)
The variable :
And the objective function :
@objective(model, Min, sum((absolute[y])*Dicopond[(absolute[y])] for y=1:endclassNb))
Absolute[y] will only take the values between 0 and 7.
However, I get the Error “LoadError: KeyError: key absolute not found
in expression starting at…”
Is there a way to make him get the actual value corresponding to the value that will be assigned to absolute[y] ?
I’ve tried different ways to be able to put a weight to the decision variable and this was the one that seemed to be the most likely to work.
Thank you for your help!
EDIT : cross-posted on variables - Julia : use dictionary value in objective function? - Stack Overflow