drasys.or.mp
Class Problem

java.lang.Object
  |
  +--drasys.or.matrix.RealContainer
        |
        +--drasys.or.mp.Problem

public class Problem
extends RealContainer
implements SizableProblemI, java.io.Serializable

Container that holds a mathematical programming problem and metadata. The this container can efficiently store both sparse and dense problems because it can use any matrix type to hold the constraint coefficients. The default matrix type is a CompressedColumnMatrix, which is efficient for storing sparse problems and compatible with most sparse algorithms. A coefficient can be accessed by its row/column name and by its row/column index. All indices in the problem are zero based.

See Also:
MPSReader,

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
, Serialized Form


Fields inherited from class drasys.or.matrix.RealContainer
_epsilon, _globalEpsilon
 
Constructor Summary
Problem(int capacityOfConstraints, int capacityOfVariables)
          Construct an empty sparse problem with initial capacities.
Problem(int capacityOfConstraints, int capacityOfVariables, SizableMatrixI matrix)
          Construct an empty problem with initial capacities using the supplied matrix for the coefficients.
 
Method Summary
 java.util.Enumeration coefficients()
          Returns a mutable 'Enumeration' of the sparse in the problem.
 java.util.Enumeration constraints()
          Returns an 'Enumeration' of the constraints.
 boolean equals(java.lang.Object o)
           
 double getCoefficientAt(int constraintIndex, int variableIndex)
          Gets a matrix coefficient by index.
 double getCoefficientAt(java.lang.String constraintName, java.lang.String variableName)
          Gets a matrix coefficient by name.
 MatrixI getCoefficientMatrix()
          Returns the matrx holding the coefficients.
 ConstraintI getConstraint(int rowIndex)
          Returns a constraint by row index.
 ConstraintI getConstraint(java.lang.String name)
          Returns a constraint by name.
 Metadata getMetadata()
          Returns the metadata container for the problem.
 VariableI getVariable(int columnIndex)
          Returns a variable by column index.
 VariableI getVariable(java.lang.String name)
          Returns a variable by name.
 void maskNames(java.util.Enumeration names)
          Renames all the variables and constraints to strings taken from 'names'.
 ConstraintI newConstraint(java.lang.String name)
          Creates a new constraint with default values.
 VariableI newVariable(java.lang.String name)
          Creates a new variable with default values.
 int relaxInteger()
          Changes all INTEGER or BOOLEAN variables to REAL variables.
 void setCapacity(int capacityOfConstraints, int capacityOfVariables)
          Increases the constraint capacity.
 void setCoefficientAt(int constraintIndex, int variableIndex, double value)
          Sets a matrix coefficient by index.
 void setCoefficientAt(java.lang.String constraintName, java.lang.String variableName, double value)
          Sets a matrix coefficient by name.
 int sizeOfCoefficients()
          Returns the number of non-null coefficients in the problem.
 int sizeOfConstraints()
          Returns the number of constraints in the problem.
 int sizeOfVariables()
          Returns the number of variable in the problem.
 java.lang.String toString()
          Returns a String representation of this Problem.
 java.lang.String toString(int beginConstraint, int endConstraint, int beginVariable, int endVariable)
          Returns a String representation of this Problem.
 java.util.Enumeration variables()
          Returns an 'Enumeration' of the variables.
 
Methods inherited from class drasys.or.matrix.RealContainer
equals, getEpsilon, getGlobalEpsilon, setEpsilon, setGlobalEpsilon
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Problem

public Problem(int capacityOfConstraints,
               int capacityOfVariables)
Construct an empty sparse problem with initial capacities. The internal coefficient matrix is a SparseMatrix. The Problem will dynamically increase its capacity as required when coefficients are added. However; the initial capacities should be set as close as possible to the actual size of the problem to minimize memory reallocation and fragmentation.
Parameters:
capacityOfRows - The initial row capacity.
capacityOfColumns - The initial row capacity.

Problem

public Problem(int capacityOfConstraints,
               int capacityOfVariables,
               SizableMatrixI matrix)
Construct an empty problem with initial capacities using the supplied matrix for the coefficients. The supplied matrix should have the capacity set to the expected size of the problem and the size set to 0x0; The Problem will dynamically increase its capacity as required when coefficients are added. However; the initial capacities should be set as close as possible to the actual size of the problem to minimize memory reallocation and fragmentation.
Parameters:
capacityOfRows - The initial row capacity.
capacityOfColumns - The initial row capacity.
Method Detail

getMetadata

public Metadata getMetadata()
Returns the metadata container for the problem.

sizeOfConstraints

public int sizeOfConstraints()
Returns the number of constraints in the problem.

sizeOfVariables

public int sizeOfVariables()
Returns the number of variable in the problem.

sizeOfCoefficients

public int sizeOfCoefficients()
Returns the number of non-null coefficients in the problem.

setCapacity

public void setCapacity(int capacityOfConstraints,
                        int capacityOfVariables)
Increases the constraint capacity.
Specified by:
setCapacity in interface SizableProblemI

newVariable

public VariableI newVariable(java.lang.String name)
                      throws DuplicateException
Creates a new variable with default values.
Default values:

type - REAL
lowerBound - 0.0
upperBound - POSITIVE_INFINITY
ObjectiveCoefficient - 0.0

Specified by:
newVariable in interface SizableProblemI
Returns:
the new variable.

newConstraint

public ConstraintI newConstraint(java.lang.String name)
                          throws DuplicateException
Creates a new constraint with default values.
Default values:

type - LESS
lowerRange - NEGATIVE_INFINITY
upperRange - POSITIVE_INFINITY
rightHandSide - 0.0

Specified by:
newConstraint in interface SizableProblemI
Returns:
the new constraint.

getVariable

public VariableI getVariable(java.lang.String name)
Returns a variable by name.

getVariable

public VariableI getVariable(int columnIndex)
Returns a variable by column index.

getConstraint

public ConstraintI getConstraint(java.lang.String name)
Returns a constraint by name.

getConstraint

public ConstraintI getConstraint(int rowIndex)
Returns a constraint by row index.

setCoefficientAt

public void setCoefficientAt(int constraintIndex,
                             int variableIndex,
                             double value)
Sets a matrix coefficient by index.

setCoefficientAt

public void setCoefficientAt(java.lang.String constraintName,
                             java.lang.String variableName,
                             double value)
                      throws NotFoundException
Sets a matrix coefficient by name.

getCoefficientAt

public double getCoefficientAt(int constraintIndex,
                               int variableIndex)
Gets a matrix coefficient by index.

getCoefficientAt

public double getCoefficientAt(java.lang.String constraintName,
                               java.lang.String variableName)
                        throws NotFoundException
Gets a matrix coefficient by name.

toString

public java.lang.String toString()
Returns a String representation of this Problem.
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(int beginConstraint,
                                 int endConstraint,
                                 int beginVariable,
                                 int endVariable)
Returns a String representation of this Problem.

maskNames

public void maskNames(java.util.Enumeration names)
Renames all the variables and constraints to strings taken from 'names'. All variables and constraints will be renamed even if the original name was null. The names enumeration argument must return 'String' objects. If 'names' is null then a 'KeyGenerator' will be used that assigns names with eight upper case alphabetic characters.

relaxInteger

public int relaxInteger()
Changes all INTEGER or BOOLEAN variables to REAL variables. When a BOOLEAN variable is changed, the lower bound is set to 0.0 and the upper bound is set to 1.0.

getCoefficientMatrix

public MatrixI getCoefficientMatrix()
Returns the matrx holding the coefficients.

coefficients

public java.util.Enumeration coefficients()
Returns a mutable 'Enumeration' of the sparse in the problem. The 'Enumeration' returns elements which implement MatrixElementI. The contents of a returned element must be used before getting the next element because the same object is modified and reused for each 'nextElement' call.

variables

public java.util.Enumeration variables()
Returns an 'Enumeration' of the variables. The 'Enumeration' returns elements which implement VariableI.

constraints

public java.util.Enumeration constraints()
Returns an 'Enumeration' of the constraints. The 'Enumeration' returns elements which implement ConstraintI.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object


Copyright(C)1997-2000 by DRA Systems all rights reserved. OpsResearch.com