[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] reading in GMPL file questions
From: |
Andrew Makhorin |
Subject: |
Re: [Help-glpk] reading in GMPL file questions |
Date: |
Sat, 1 Jul 2006 23:31:55 +0400 |
> I'm trying to learn the use of GLPK via the R-GLPK interface and as
> part of this, I am using the Dantzig cannery model from the
> documentation and using the API to examine it. Some questions:
>
> 1. Does the objective function always get read in as the first row?
> I noticed the GMPL file was read that way but I don't think it was
> required when I used the API to define the model.
In glpk api objective coefficients are specified separately and
not related to rows of the constraint matrix. The point is that gmpl
translator obtains objective coefficients from the first free row in
the model (specified in the objective statement) keeping that row as
well as other free rows in the constraint matrix. (Btw, the same
happens on reading mps files.)
>
> 2. Is the order of the rows always correspond to the order in the
> model file? I would like to be able to programmatically modify
> rows, but this requires I be able to predict where the row is based
> on the model file.
No, the order in which the translator produces rows and columns is
unpredictable. Once you have read the model via lpx_read_model, you
should call the api routine lpx_create_index to index rows and columns
by their symbolic names, and then use the routines lpx_find_row and
lpx_find_col to determine ordinal numbers of rows/columns.
Andrew Makhorin