Closed willu47 closed 1 year ago
In the model file, the names of the problem, objective function, variables and constraints are listed in the lines beginning with n
where:
n p NAME # p = problem instance
n z NAME # z = objective function
n i ROW NAME # i = constraint name, ROW is the row ordinal number
n j COL NAME # j = variable name, COL is the column ordinal number
In the solution file, the rows take on the following format:
i ROW ST PRIM DUAL
where:
ROW
is the ordinal number of the rowST
is one of:
b
= inactive constraint;l
= inequality constraint active on its lower bound;u
= inequality constraint active on its upper bound;f
= active free (unounded) row;s
= active equality constraint.PRIM
specifies the row primal value (float)DUAL
specifies the row dual value (float)Columns take on the following format:
j COL ST PRIM DUAL
where:
COL
specifies the column ordinal numberST
contains one of the following lower-case letters that specifies the column status in the basic solution:
b
= basic variablel
= non-basic variable having its lower bound activeu
= non-basic variable having its upper bound activef
= non-basic free (unbounded) variables
= non-basic fixed variable.PRIM
field contains column primal value (float)DUAL
field contains the column dual value (float)
To programmatically process the results from OSeMOSYS using GLPK (as an alternative to manually writing out tabular files my modifying the model files), I would prefer to use the solution file generated by GLPK as we are doing with the CBC and CPLEX solvers. Apparently, using the
--wglp
option to write a model file in GLPK format and the solution with the--write
(instead of--output
) generates a machine readable text file which can be more easily processed, and the variable names can be extracted from the glpk model file as the identifiers match.From https://en.wikibooks.org/wiki/GLPK/Interoperability :
The following command can be used to generate the solution and model file which can be parsed programmatically: