|
Once an AMPL model is written, creating an nl file is easy.
At the AMPL prompt or in a text file, type the commands.
ampl: model xyz.mod;
ampl: data xyz.dat;
ampl: option nl_comments 1;
ampl: write gxyz;
Note: The g prefixing xyz in the last
command is important. If the above commands are stored in the
text file xyz.ampl, have AMPL execute it using
ampl xyz.ampl at the command line.
This creates a text file called xyz.nl with some
comments. The file is hardly human readable but is easily parsed
using the tools in the AMPL library. Its header will be similar
to
g3 0 1 0 # problem nltrans
21 10 1 0 10 # vars, constraints, objectives, ranges, eqns
0 1 # nonlinear constraints, objectives
0 0 # network constraints: nonlinear, linear
0 21 0 # nonlinear vars in constraints, objectives, both
0 0 0 1 # linear network variables; functions; arith, flags
0 0 0 0 0 # discrete variables: binary, integer, nonlinear (b,c,o)
42 21 # nonzeros in Jacobian, gradients
0 0 # max name lengths: constraints, variables
0 0 0 0 0 # common exprs: b,c,o,c1,o1
The rest of the file describes the DAG.
|