# How to graphically solve a problem?

**URL:** <https://discourse.julialang.org/t/how-to-graphically-solve-a-problem/30231>\
**Category:** Optimization (Mathematical)\
**Tags:** question, plotting\
**Created:** [October 23, 2019, 3:56pm UTC](https://discourse.julialang.org/t/how-to-graphically-solve-a-problem/30231 "2019-10-23T15:56:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![RaquelSantos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raquelsantos/32/3668_2.png) [@RaquelSantos](https://discourse.julialang.org/u/RaquelSantos)\
**Post date:** [October 23, 2019, 3:56pm UTC](https://discourse.julialang.org/t/how-to-graphically-solve-a-problem/30231/1 "2019-10-23T15:56:16Z")

</div>

Is it possible to get the graphical solution of the x1 and x2 result of this problem using the Pyplot package?

```julia
using JuMP, Cbc
using PyPlot

Test1 = Model(solver = CbcSolver())

@variable(Test1, x1 >= 0)
@variable(Test1, x2 >= 0)

@objective(Test1, Max, 4x1 + 3x2)

@constraint(Test1, 5x1 + 3x2 <= 22)
@constraint(Test1, 2x1 + 2x2 <= 11)

println("The optimization problem to be solved is:")
print(Test1)

status = solve(Test1)
println("Objective value: ", getObjectiveValue(Test1))
println("x1 = ", getValue(x1))
println("x2 = ", getValue(x2))

```

---

<div class="post-metadata">

**Author:** ![blegat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blegat/32/217090_2.png) [@blegat](https://discourse.julialang.org/u/blegat)\
**Post date:** [October 25, 2019, 9:53am UTC](https://discourse.julialang.org/t/how-to-graphically-solve-a-problem/30231/2 "2019-10-25T09:53:59Z")

</div>

You do it using [Polyhedra](https://github.com/JuliaPolyhedra/Polyhedra.jl). First [create a polyhedron from the feasible set](https://juliapolyhedra.github.io/Polyhedra.jl/stable/optimization/#Creating-a-polyhedron-from-the-feasible-set-of-a-JuMP-model-1) and then plot it using [Plots](http://docs.juliaplots.org/latest/).
