drasys.or.mp.util
Class MPSWriter
java.lang.Object
|
+--java.io.Writer
|
+--java.io.PrintWriter
|
+--drasys.or.mp.util.MPSWriter
- public class MPSWriter
- extends java.io.PrintWriter
- implements ProblemWriterI
Outputs a mathematical programming problem to an
MPS
stream.
There are two predominate versions of the MPS format.
An older format that uses fixed field records and a newer
format that uses white-space delimited records.
The fixed record format limits row/column names to eight characters
and the delimited format allows names of arbitrary length.
An MPS reader that reads delimited records can read fixed records
with no changes if the row/column names don't contain embedded spaces.
This class writes records using the fixed format if the names contain
eight or fewer characters and uses the delimited format if they are longer.
Any value that is equal to zero to within the 'epsilon' parameter for
the problem will not be written to the stream.
Variables of type INTEGER and BOOLEAN will be grouped inside integer marker records in the columns section.
Variables of type BOOLEAN will have either a 'BV' or a 'UP' record in the bounds section dependent on the
value of 'useBooleanBound'.
A RANGE constraint will be output as an EQUAL constraint in the rows section
with the lower range in the right-hand-side section and upper-lower in the ranges section.
If the problem has a non-null value for the 'lp.name' metadatum, a NAME record will be written with the value.
References:
Linear Programming
Vasek Chvatal / Paperback / Published 1983
Integer and Combinatorial Optimization
George L. Nemhauser, Laurence A. Wolsey / Paperback / Published 1988
Integer Programming
Laurence A. Wolsey / Hardcover / Published 1998
Fields inherited from class java.io.PrintWriter |
out |
Fields inherited from class java.io.Writer |
lock |
Constructor Summary |
MPSWriter(java.io.OutputStream out)
|
MPSWriter(java.io.OutputStream out,
boolean autoFlush)
|
MPSWriter(java.io.Writer out)
|
MPSWriter(java.io.Writer out,
boolean autoFlush)
|
Method Summary |
void |
setBoundName(java.lang.String name)
Sets the name to use for the bound row. |
void |
setObjectiveName(java.lang.String name)
Sets the name to use for the objective row. |
void |
setRangeName(java.lang.String name)
Sets the name to use for the range column. |
void |
setRightHandSideName(java.lang.String name)
Sets the name to use for the right-hand-side column. |
void |
setUseBooleanBound(boolean useBooleanBound)
If 'useBooleanBound' is 'true' then a variable of type BOOLEAN will be designated with a bound data record of type 'BV'. |
void |
setWriteMetadata(boolean writeMetadata)
If 'writeMetadata' is 'true' then the metadata will be written as comments. |
void |
writeProblem(ProblemI problem)
Writes 'problem' to an
MPS
formatted stream. |
Methods inherited from class java.io.PrintWriter |
checkError,
close,
flush,
print,
print,
print,
print,
print,
print,
print,
print,
print,
println,
println,
println,
println,
println,
println,
println,
println,
println,
println,
setError,
write,
write,
write,
write,
write |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
MPSWriter
public MPSWriter(java.io.OutputStream out)
MPSWriter
public MPSWriter(java.io.OutputStream out,
boolean autoFlush)
MPSWriter
public MPSWriter(java.io.Writer out)
MPSWriter
public MPSWriter(java.io.Writer out,
boolean autoFlush)
setUseBooleanBound
public void setUseBooleanBound(boolean useBooleanBound)
- If 'useBooleanBound' is 'true' then a variable of type BOOLEAN will be designated with a bound data record of type 'BV'.
If it is 'false' then a variable of type BOOLEAN will be designated with a bound data record of type 'UP' and a value of '1.0'.
The default is to use a 'BV' record.
setWriteMetadata
public void setWriteMetadata(boolean writeMetadata)
- If 'writeMetadata' is 'true' then the metadata will be written as comments.
If it is 'false' then the metadata will not be written.
The default is to write the metadata.
setRightHandSideName
public void setRightHandSideName(java.lang.String name)
- Sets the name to use for the right-hand-side column.
The default is 'RHS';
setObjectiveName
public void setObjectiveName(java.lang.String name)
- Sets the name to use for the objective row.
The default is 'OBJ';
setRangeName
public void setRangeName(java.lang.String name)
- Sets the name to use for the range column.
The default is 'RNG';
setBoundName
public void setBoundName(java.lang.String name)
- Sets the name to use for the bound row.
The default is 'BND';
writeProblem
public void writeProblem(ProblemI problem)
throws java.io.IOException
- Writes 'problem' to an
MPS
formatted stream.
If a variable or constraint has no name then an arbitrary name will generated.
- Specified by:
- writeProblem in interface ProblemWriterI
Copyright(C)1997-2000 by DRA Systems all rights reserved. OpsResearch.com