# [Coin-ipopt] Is there any free AMPL parser can work with IPOPT ?

Dominique Orban Dominique.Orban at polymtl.ca
Thu Aug 4 09:53:35 EDT 2005

```Hello,

Hoxide Ma wrote:
> I'm newbie to IPOPT. IPOPT is great. It can work with
> AMPL  as a solver. I had try it with AMPL Student
> Version , but,Is there any free AMPL parser?

No, there doesn't seem to be any. There is a full version of AMPL that
your problems via e-mail, http or tcp/ip, select an available solver and
the results of the solve will be returned to you.

> GNU MathProg Language maybe a "can work" Parser , but
> just for linear programming.

Indeed, it only understands linear programming.

> If there is no such parser, why not write a free one?

> Another question is , is there any document described
> the NL(nonlinear) format used in AMPL?

No that I know of. The nl files contains info on the problem, data for
the linear parts of all expressions and the expression tree of each
nonlinear expression appearing in the model. Using the very simple model

model;
var x {1..3};
minimize objective:
x[1]^2 + 2*x[2]^4 - sin( x[3] );

data;
let {i in 1..3} x[i] := 1;

and the ampl commands

model simplemod.mod;
data simplemod.dat;
write gsimplemod;

you will see the following in the nl file:

O0 0    #objective

(this defines the first objective: it has number 0)

o54     #sumlist
3

(operator #54 is a sum and this one has 3 terms)

o5      #^      (power operator)
v0      #x[1]   (variable number 0 is our x[1])
n2              (raised to the power 2)
o2      #*      (second term of the sum is 2*x[2]^2
n2
o5      #^
v1      #x[2]
n4
o16     #-      (third term is -sin(x[3])
o41     #sin
v2      #x[3]

You basically write those trees in so-called reverse Polish notation. A
series of tools is available to read nl files. Check the AMPL Library at