# help modeling a problem

**URL:** https://discourse.julialang.org/t/help-modeling-a-problem/22584
**Category:** General Usage
**Created:** [April 1, 2019, 2:35am UTC](https://discourse.julialang.org/t/help-modeling-a-problem/22584 "2019-04-01T02:35:38Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Matias\_Duran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matias_duran/32/7725_2.png) [@Matias\_Duran](https://discourse.julialang.org/u/Matias_Duran)
#### Post date: [April 1, 2019, 2:35am UTC](https://discourse.julialang.org/t/help-modeling-a-problem/22584/1 "2019-04-01T02:35:39Z")

</div>

Hello! im new using Julia and i was trying to modeling this:

```julia
Julia > import Pkg; Pkg.add(“JuMP”)
Julia > using JuMP
Julia > m = Model()
Julia > @variable(m, x1)
Julia > @variable(m, x2)
Julia > @variable(m, x3)
Julia > @variable(m, x4)
julia> @objective(m,Max,-x1 + 7x2 + 14x3 +2x4)
julia> @constraint(m, -x1+x2+x3+x4 >=7)
julia> @constraint(m, x1+27x2+30x3<=89)
julia> @constraint(m,x2-x4==1)
julia> @constraint(m, x3 <= 2)
julia> @constraint(m,x2>=0)
julia> @constraint(m,x3>=0)
julia> @constraint(m,x4>=0)
julia> optimize!(m)

```

when i use “optimize!(m)”, Julia send me this error "ERROR: NoOptimizer()  
"  
how can i fixed it?

another question: x1 is a free variable, how can i created a free variable?

sorry guys for my bad english, actually im taking english classes to improve it.

---

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [April 1, 2019, 2:51am UTC](https://discourse.julialang.org/t/help-modeling-a-problem/22584/2 "2019-04-01T02:51:04Z")

</div>

Welcome!

JuMP is just a tool for describing your optimization problem, so you also need an optimizer to solve the problem. It looks like [GitHub - jump-dev/GLPK.jl: GLPK wrapper module for Julia](https://github.com/JuliaOpt/GLPK.jl) would work for your case. You can install it with `Pkg.add("GLPK")` and then use it like this:

```julia
using JuMP
using GLPK
m = Model(with_optimizer(GLPK.Optimizer))
@variable(m, x1)
...

```

For more information, see: [Quick Start Guide · JuMP](http://www.juliaopt.org/JuMP.jl/v0.19.0/quickstart/#Quick-Start-Guide-1)

> [@Matias\_Duran](#):
>
> x1 is a free variable, how can i created a free variable?

Can you explain what you mean? `x1` is already a variable with no bounds in the optimization problem you’ve written. Do you need something other than that?

Also, by the way, rather than making variables with numbers in their names, like `x1`, `x2`, etc., I would suggest making a vector of variables:

```julia
julia> @variable(m, x[1:4])
4-element Array{VariableRef,1}:
 x[1]
 x[2]
 x[3]
 x[4]

```

Doing this can make it easier to add constraints to many variables at once:

```julia
julia> @constraint(m, x[2:4] .>= 0)
3-element Array{ConstraintRef{Model,MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.GreaterThan{Float64}},ScalarShape},1}:
 x[2] ≥ 0.0
 x[3] ≥ 0.0
 x[4] ≥ 0.0

```
