AMPL does not directly support writing .lp files. There are some possibilities, however.
To write a file containing an .lp-style list of all of the constraints generated by AMPL, use the AMPL command "expand >yourfile;" (replacing "yourfile" by whatever file name you want to use).
You can also tell the CPLEX, Gurobi, or Xpress solver to write a file in the .lp format that is readable by that solver. As an example, here are the AMPL statements you would use for Gurobi, which produces the attached file multmip.lp:
option solver gurobi;
option gurobi_options 'writeprob=..\multmip.lp timelim=0';
option gurobi_auxfiles rc;
option presolve 0;
solve;You can vary this in several ways:
- Leave timelim=0 out of the gurobi_options string to let Gurobi solve the problem after writing the .lp file.
- Leave out the option gurobi_auxfiles statement to get a more compact listing with constraint names R0, R1, R2, . . . , and similarly for the variable names.
- Leave out the option presolve to get a file based on the reduced version of the problem that is produced by AMPL's presolve phase.
It works similarly with CPLEX and with Xpress, but reply if you need help getting either of them to write the .lp file.