# AMPL to Julia

**URL:** https://discourse.julialang.org/t/ampl-to-julia/102800
**Category:** Optimization (Mathematical)
**Tags:** question
**Created:** [August 14, 2023, 6:37pm UTC](https://discourse.julialang.org/t/ampl-to-julia/102800 "2023-08-14T18:37:09Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Julianewbie](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@Julianewbie](https://discourse.julialang.org/u/Julianewbie)
#### Post date: [August 14, 2023, 6:37pm UTC](https://discourse.julialang.org/t/ampl-to-julia/102800/1 "2023-08-14T18:37:09Z")

</div>

Hello,

I am trying to convert an AMPL file to Julia and I dont know how to get started I have the following expressions that I need help with so I can use them as a reference to get started, the second one should be a for loop from my understanding, also what are some useful resources

Expression 1  
` **param** BRMPPSC {t **in** initial..T} **default** 0`

expression 2

```julia
**param** BRLOADINGMG {t **in** initial..T} := **if** BRCOM[t] = 15 **then** (<<665,667,669,671,673,675,677,679,681,683,685,687,689,691,693,695;2.19912781954887,2.19912781954887,4.13499999999999,4.13999999999999,4.13499999999999,4.13999999999999,4.13499999999999,4.13499999999999,4.13499999999999,3.34000000000003,2.70500000000004,2.70499999999993,2.71000000000004,2.70500000000004,2.70499999999993,2.71000000000004,2.70500000000004>> FB['BR',t])

**else**  **if** BRCOM[t] = 7 **then** (<<665,667,669,671,673,675,677,679,681,683,685,687,689,691,693,695;1.6689022556391,1.6689022556391,3.13499999999999,3.13499999999999,3.1400000000001,3.13499999999999,3.13499999999999,2.35000000000002,2.02499999999998,2.02999999999997,2.02999999999997,2.02999999999997,2.03000000000009,2.02499999999998,2.02999999999997,2.02999999999997,2.03000000000009>>FB['BR',t])

**else** 0;

```

---

<div class="post-metadata">

### Author: ![robsmith11](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robsmith11/32/29641_2.png) [@robsmith11](https://discourse.julialang.org/u/robsmith11)
#### Post date: [August 14, 2023, 6:56pm UTC](https://discourse.julialang.org/t/ampl-to-julia/102800/2 "2023-08-14T18:56:40Z")

</div>

I’ve never used AMPL, so can’t be of much help there, but I imagine the JuMP docs would be a good place start:

> **[Getting started with JuMP · JuMP](https://jump.dev/JuMP.jl/stable/tutorials/getting_started/getting_started_with_JuMP/)**
>
> Documentation for JuMP.

---

<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: [August 14, 2023, 7:25pm UTC](https://discourse.julialang.org/t/ampl-to-julia/102800/3 "2023-08-14T19:25:20Z")

</div>

Hi @Julianewbie, welcome to the forum 😄

JuMP is a little different to AMPL. We don’t separate the data and the model, so for parameters, you can use regular data structures like arrays. For example, `BRMPPSC = [0, 0, 0, 1, 2, 3, 0, 4]`.

I’m a little unsure what the second one means. You might need to provide more context from the model, like what `BRCOM` is, and what `FB` are, etc.

---

<div class="post-metadata">

### Author: ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)
#### Post date: [August 15, 2023, 10:30am UTC](https://discourse.julialang.org/t/ampl-to-julia/102800/4 "2023-08-15T10:30:30Z")

</div>

In case it helps, there’s also [GitHub - JuliaSmoothOptimizers/AmplNLReader.jl: Julia AMPL Models Conforming to NLPModels.jl](https://github.com/JuliaSmoothOptimizers/AmplNLReader.jl).
