Commit 6df796bf authored by Jukka Pekka's avatar Jukka Pekka Committed by jpekka
Browse files

Wrote. Currently gives only a valid error msg. (mps_parse_bounds): Added

2002-07-03  Jukka Pekka  <jiivonen@hutcs.cs.hut.fi>

	* parser.c (mps_parse_ranges): Wrote. Currently gives only a valid
	error msg.
	(mps_parse_bounds): Added support for lower bounds.
	(mps_parse_file): Added ranges section parsing.
parent 84e60e80
2002-07-03 Jukka Pekka <jiivonen@hutcs.cs.hut.fi>
* parser.c (mps_parse_ranges): Wrote. Currently gives only a valid
error msg.
(mps_parse_bounds): Added support for lower bounds.
(mps_parse_file): Added ranges section parsing.
2002-07-03 Jukka Pekka <jiivonen@hutcs.cs.hut.fi>
* parser.c (mps_add_bound): Bug fix: Add type field setting.
......
......@@ -8,10 +8,12 @@
* MPS importer module. MPS format is a de facto standard ASCII format
* among most of the commercial LP solvers.
*
* This implementation does not yet support ranges and bounds but is
* already quite suitable for testing the solving algorithms.
* See, for example, the Netlib collection of LP problems in MPS format
* (ftp://netlib2.cs.utk.edu/lp/data).
* This implementation does not yet support ranges and all types
* of bounds but is already quite suitable for testing the
* solving algorithms. See, for example, the Netlib collection
* of LP problems in MPS format (ftp://netlib2.cs.utk.edu/lp/data).
*
* Supported bound types are: UP and LO.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
......@@ -475,6 +475,23 @@ mps_add_bound (MpsInputContext *ctxt, MpsBoundType type, gchar *bound_name,
return TRUE;
}
/*
* RANGES section parsing. Ranges are currently not supported.
*
* Returns FALSE on error.
*/
static gboolean
mps_parse_ranges (MpsInputContext *ctxt)
{
gchar type[3], n1[10], n2[10], v1[20], n3[10], v2[20];
if (strncmp (ctxt->line, "ENDATA", 6) == 0)
return TRUE;
if (strncmp (ctxt->line, "RANGES", 6) != 0 || ctxt->line[6] != '\0')
return TRUE;
}
/*
* BOUNDS section parsing. Saves the bounds into `ctxt->bounds' GSList.
* Each list element is MpsBound, and their `name', `col_index', and `value'
......@@ -485,7 +502,8 @@ mps_add_bound (MpsInputContext *ctxt, MpsBoundType type, gchar *bound_name,
static gboolean
mps_parse_bounds (MpsInputContext *ctxt)
{
gchar type[3], n1[10], n2[10], v1[20], n3[10], v2[20];
gchar type[3], n1[10], n2[10], v1[20], n3[10], v2[20];
MpsBoundType t;
if (strncmp (ctxt->line, "ENDATA", 6) == 0)
return TRUE;
......@@ -504,11 +522,15 @@ mps_parse_bounds (MpsInputContext *ctxt)
return FALSE;
}
if (strncmp (type, "UP", 2) == 0) {
if (!mps_add_bound (ctxt, UpperBound, n1, n2, v1))
return FALSE;
} else
return FALSE; /* Only upper bounds are implemented */
if (strncmp (type, "UP", 2) == 0)
t = UpperBound;
else if (strncmp (type, "LO", 2) == 0)
t = LowerBound;
else
return FALSE; /* Not all bound types are implemented */
if (!mps_add_bound (ctxt, t, n1, n2, v1))
return FALSE;
}
}
......@@ -538,6 +560,11 @@ mps_parse_file (MpsInputContext *ctxt)
(ctxt->io_context,
error_info_new_printf (_("Invalid RHS section in the "
"file.")));
} else if (!mps_parse_ranges (ctxt)) {
gnumeric_io_error_info_set
(ctxt->io_context,
error_info_new_printf (_("Invalid RANGES section in "
"the file.")));
} else if (!mps_parse_bounds (ctxt)) {
gnumeric_io_error_info_set
(ctxt->io_context,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment