AMPL to Julia

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

**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;

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:

1 Like

Hi @Julianewbie, welcome to the forum :smile:

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.

In case it helps, there’s also GitHub - JuliaSmoothOptimizers/AmplNLReader.jl: Julia AMPL Models Conforming to NLPModels.jl.