Getvalue() help


#1

I got a variable, x:

@variable(m, x_min <= x[i = 2:4] <= x_max, Int)

But after solving my optimization problem, i want to print 2*x+2. How can this be done?

I tried something like:

println("x = ", 2*getvalue(x)+2)

But it didn’t worked.


#2

Please remember to post a minimum working example that demonstrates what you tried, and what the error was:

In this case, x isn’t a single variable, so you probably want something like

for i in 2:4
    println("x[$(i)] = ", 2 * getvalue(x[i]) + 2)
end