# Why getvalue(x) is not working in this optimization problem?

**URL:** <https://discourse.julialang.org/t/why-getvalue-x-is-not-working-in-this-optimization-problem/22895>\
**Category:** New to Julia\
**Tags:** package, jump\
**Created:** [April 7, 2019, 11:18pm UTC](https://discourse.julialang.org/t/why-getvalue-x-is-not-working-in-this-optimization-problem/22895 "2019-04-07T23:18:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdelfino](https://avatars.discourse-cdn.com/v4/letter/p/8c91f0/32.png) [@pdelfino](https://discourse.julialang.org/u/pdelfino)\
**Post date:** [April 7, 2019, 11:18pm UTC](https://discourse.julialang.org/t/why-getvalue-x-is-not-working-in-this-optimization-problem/22895/1 "2019-04-07T23:18:38Z")

</div>

Hi,

This is my second week using Julia. I am using Julia 1.1.0 and JuMP v0.19.0 for some optimization problems. I managed to solve a classic transport problem. I can see final optimal result. However, I would like to see the variable values that lead to the minimal value on the objective function.

This is my code:

```julia

using JuMP
using GLPK
using Cbc
using MathOptInterface

ORIG = ["Cleveland", "Boston", "Houston", "Los Angeles","Washinton D.C."]
DEST = ["Trumbull", "N.Y.", "Atlanta", "Chicago", "San Fran."]

supply = [45, 90, 95,75,105]
demand = [120, 80,50, 75, 85]

cost = [6 6 9 4 10 ;
	    3 2 7 5 12 ;
	    8 7 5 6 4 ;
        11 12 9 5 2 ;
         4 3 4 5 11]

model = Model(with_optimizer(Cbc.Optimizer))

@variable(model, x[1:length(ORIG), 1:length(DEST)] >= 0)

@objective(model, Min, sum(cost[i, j] * x[i, j] for i in 1:length(ORIG), j in 1:length(DEST)))

@constraint(model, [i in 1:length(ORIG)], sum(x[i, j] for j in 1:length(DEST)) == supply[i])

@constraint(model, [j in 1:length(DEST)],sum(x[i, j] for i in 1:length(ORIG)) == demand[j])

JuMP.optimize!(model)

println(termination_status(model))

println("Minimum total cost for the transport problem: ",objective_value(model) ," american dollars")

println(value(x))

```

Why `value(x)` is not working?

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [April 7, 2019, 11:23pm UTC](https://discourse.julialang.org/t/why-getvalue-x-is-not-working-in-this-optimization-problem/22895/2 "2019-04-07T23:23:08Z")

</div>

`value(x)` only works for a single variable. Use `value.(x)` instead.

Admittedly, this is a Julia feature (not specific to JuMP) that new users often aren’t aware of. We should have a better error message.

Edit: opened an issue: [Better docs/error message for broadcasting value et al · Issue #1925 · jump-dev/JuMP.jl · GitHub](https://github.com/JuliaOpt/JuMP.jl/issues/1925)
