I am trying to convert a set of GAMS models to a custom matrix style format. Is there a way to access each equation in a GAMS model and read the coefficients of each variable + type (=l=,=e= or =g=) & RHS for each equation? The closest I get is the Equations Listing, which gives me more or less what I need, as it is in a format that could be easily parsed, but as it says in the manual: "In nonlinear models, the GAMS equation listing shows firstorder Taylor approximations of the nonlinear equa tions." and not the equation itself. The other approach I investigated was using put statements, but I can't find a way to read the equations. What I had in mind was looping over all equations, and for each equation loop over all indices and put the coefficients for each row to an output file. Is something like this at all possible? Any ideas on how to proceed? asked 22 Nov '12, 07:04 hellemo 
what about letting GAMS write the model to a file which is then in a "standard" format (like LP format for linear and integer program) and parse that? answered 22 Nov '12, 10:53 Marco Luebbecke ♦ Yes, something like LP format would be great. Is that possible from GAMS?
(22 Nov '12, 15:16)
hellemo
Try using Convert as the selected solver. See GAMS solvers help for more information.
(22 Nov '12, 15:18)
Ehsan ♦
@hellemo: As I understand it, the LP format can only store linear coefficients. I'm not sure if there is a standard way of extracting coefficients from nonlinear equations. You might need a way of specifying how the coefficients appear in the terms, and which coefficients you want.
(22 Nov '12, 16:43)
Gilead ♦
Thanks @marcoluebbecke & @Ehsan. I forgot about convert, I thought it changed all variable names. On further investigation it turns out with the option dict, GAMS writes a dictionary to map variable names back to the original name. This gives me exactly what I need! In case it could be of use to someone else, see here.
(23 Nov '12, 04:31)
hellemo

Is your model linear? If not, are you trying to get the Jacobian of the constraints? (which corresponds to the A matrix of an LP if the system is linear)
No, it's nonlinear. I'm not trying to get the Jacobian, I want the coefficients from the original equations. I also need the name of the variables to be able to treat then differently (for decomposition).
I'm not sure GAMS is capable of doing what you need, but it seems that writing a specialized code in a programming language would do the trick as well.
@hellemo: Can you give us an example of what your equations look like? I suspect there isn't a prepackaged way of doing what you want, but if the form is regular enough, you can write a simple parser to do the job.