sbrt.ext.glpk
Class GlpkSolver<R,C>

java.lang.Object
  extended by sbrt.ext.glpk.GlpkSolver<R,C>
Type Parameters:
R - the row variable type.
C - the column variable type.
All Implemented Interfaces:
LinearProgramSolver<R,C>, ProgramSolver<R,C>

public class GlpkSolver<R,C>
extends java.lang.Object
implements LinearProgramSolver<R,C>

This class is a wrapper for the GLPK package from GNU.

Author:
This class was written and documented by Jeremiah Wright while in the Wagner lab.

Constructor Summary
GlpkSolver()
          Constructs a new GLPK program solver.
 
Method Summary
 void clear()
          Clears all information contained in this program solver.
 double getObjectiveValue()
          Returns the most recently computed objective value.
 java.util.Map<C,java.lang.Double> getSolutionVector()
          Returns the most recently computed solution vector.
 ProgramSolverStatus getStatus()
          Returns the status of the most recently attempted optimization.
 boolean isColumnVar(java.lang.Object obj)
          Indicates if the provided object is a column variable in the matrix of this program solver.
 boolean isRowVar(java.lang.Object obj)
          Indicates if the provided object is a row variable in the matrix of this program solver.
 boolean optimize()
          Computes the optimal value of the current objective function in the current optimization sense.
<Y extends C>
void
setColumnConstraint(Y column, Interval c)
          Sets the constraint on the provided column variable.
 void setColumnConstraints(java.util.Map<? extends C,Interval> columnConstraints)
          Sets the constraints for the provided column variables.
 void setConstraint(LinearComb<? extends C> expression, Interval c)
          Sets a constraint on the provided mathematical expression of column variables.
 void setConstraint(MathExpr<? extends C> expression, Interval c)
          Sets a constraint on the provided mathematical expression of column variables.
 void setConstraints(java.util.Map<? extends MathExpr<? extends C>,Interval> expressionConstraints)
          Sets constraints on the provided mathematical expressions of column variables.
<X extends R,Y extends C>
void
setMatrixElement(X row, Y column, double value)
          Sets the element of the program matrix at the provided row and column variables to the one provided.
 void setObjectiveFunction(LinearComb<? extends C> expression)
          Sets the objective function to the provided mathematical expression of column variables.
 void setObjectiveFunction(LinearComb<? extends C> expression, OptSense sense)
          Sets the objective function and optimization sense to the provided values.
 void setObjectiveFunction(MathExpr<? extends C> expression)
          Sets the objective function to the provided mathematical expression of column variables.
 void setObjectiveFunction(MathExpr<? extends C> expression, OptSense sense)
          Sets the objective function and optimization sense to the provided values.
 void setOptimizationSense(OptSense sense)
          Sets the optimization sense.
 void setParamFile(java.lang.String fileName)
          Throws UnsupportedOperationException.
<X extends R>
void
setRowConstraint(X row, Interval c)
          Sets the constraint for the provided row variable.
 void setRowConstraints(java.util.Map<? extends R,Interval> rowConstraints)
          Sets the constraints for the provided row variables.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GlpkSolver

public GlpkSolver()
Constructs a new GLPK program solver.

Method Detail

clear

public void clear()
Clears all information contained in this program solver. Calling this method restores this program solver to its original, pristine state.

Specified by:
clear in interface ProgramSolver<R,C>

isRowVar

public boolean isRowVar(java.lang.Object obj)
Indicates if the provided object is a row variable in the matrix of this program solver.

Specified by:
isRowVar in interface ProgramSolver<R,C>
Parameters:
obj - the potential row variable.
Returns:
true if the provided object is a row variable in the matrix of this program solver; false otherwise.

isColumnVar

public boolean isColumnVar(java.lang.Object obj)
Indicates if the provided object is a column variable in the matrix of this program solver.

Specified by:
isColumnVar in interface ProgramSolver<R,C>
Parameters:
obj - the potential column variable.
Returns:
true if the provided object is a column variable in the matrix of this program solver; false otherwise.

setMatrixElement

public <X extends R,Y extends C> void setMatrixElement(X row,
                                                       Y column,
                                                       double value)
Sets the element of the program matrix at the provided row and column variables to the one provided.

Specified by:
setMatrixElement in interface ProgramSolver<R,C>
Type Parameters:
X - a type extending the primary row variable type.
Y - a type extending the primary column variable type.
Parameters:
row - the row variable.
column - the column variable.
value - the double precision element value.

setColumnConstraint

public <Y extends C> void setColumnConstraint(Y column,
                                              Interval c)
Sets the constraint on the provided column variable.

Specified by:
setColumnConstraint in interface ProgramSolver<R,C>
Type Parameters:
Y - a type extending the primary column variable type.
Parameters:
column - the column variable for which the constraint is set.
c - the constraint.

setColumnConstraints

public void setColumnConstraints(java.util.Map<? extends C,Interval> columnConstraints)
Sets the constraints for the provided column variables.

Specified by:
setColumnConstraints in interface ProgramSolver<R,C>
Parameters:
columnConstraints - column variables mapped to their corresponding constraint.

setRowConstraint

public <X extends R> void setRowConstraint(X row,
                                           Interval c)
Sets the constraint for the provided row variable.

Specified by:
setRowConstraint in interface ProgramSolver<R,C>
Type Parameters:
X - a type extending the primary row variable type.
Parameters:
row - the row variable for which the constraint is set.
c - the constraint.

setRowConstraints

public void setRowConstraints(java.util.Map<? extends R,Interval> rowConstraints)
Sets the constraints for the provided row variables.

Specified by:
setRowConstraints in interface ProgramSolver<R,C>
Parameters:
rowConstraints - row variables mapped to their corresponding constraint.

setConstraint

public void setConstraint(MathExpr<? extends C> expression,
                          Interval c)
Sets a constraint on the provided mathematical expression of column variables.

Specified by:
setConstraint in interface ProgramSolver<R,C>
Parameters:
expression - a mathematical expression of column variables for which the constraint is set.
c - the constraint.

setConstraint

public void setConstraint(LinearComb<? extends C> expression,
                          Interval c)
Sets a constraint on the provided mathematical expression of column variables.

Specified by:
setConstraint in interface LinearProgramSolver<R,C>
Parameters:
expression - a mathematical expression of column variables for which the constraint is set.
c - the constraint.

setConstraints

public void setConstraints(java.util.Map<? extends MathExpr<? extends C>,Interval> expressionConstraints)
Sets constraints on the provided mathematical expressions of column variables.

Specified by:
setConstraints in interface ProgramSolver<R,C>
Parameters:
expressionConstraints - mathematical expressions of column variables mapped to their corresponding constraint.

setObjectiveFunction

public void setObjectiveFunction(MathExpr<? extends C> expression,
                                 OptSense sense)
Sets the objective function and optimization sense to the provided values.

Specified by:
setObjectiveFunction in interface ProgramSolver<R,C>
Parameters:
expression - a mathematical expression of column variables from this program solver.
sense - the optimization sense.
See Also:
setObjectiveFunction(MathExpr), setOptimizationSense(OptSense)

setObjectiveFunction

public void setObjectiveFunction(MathExpr<? extends C> expression)
Sets the objective function to the provided mathematical expression of column variables.

Specified by:
setObjectiveFunction in interface ProgramSolver<R,C>
Parameters:
expression - a mathematical expression of column variables from this program solver.

setObjectiveFunction

public void setObjectiveFunction(LinearComb<? extends C> expression,
                                 OptSense sense)
Sets the objective function and optimization sense to the provided values.

Specified by:
setObjectiveFunction in interface LinearProgramSolver<R,C>
Parameters:
expression - a mathematical expression of column variables from this program solver.
sense - the optimization sense.
See Also:
setObjectiveFunction(MathExpr), setOptimizationSense(OptSense)

setObjectiveFunction

public void setObjectiveFunction(LinearComb<? extends C> expression)
Sets the objective function to the provided mathematical expression of column variables.

Specified by:
setObjectiveFunction in interface LinearProgramSolver<R,C>
Parameters:
expression - a mathematical expression of column variables from this program solver.

setOptimizationSense

public void setOptimizationSense(OptSense sense)
Sets the optimization sense.

Specified by:
setOptimizationSense in interface ProgramSolver<R,C>
Parameters:
sense - the optimization sense.

optimize

public boolean optimize()
Computes the optimal value of the current objective function in the current optimization sense.

Specified by:
optimize in interface ProgramSolver<R,C>
Returns:
true if an optimal solution was found; false otherwise.
See Also:
getObjectiveValue(), getSolutionVector()

getObjectiveValue

public double getObjectiveValue()
Returns the most recently computed objective value.

Specified by:
getObjectiveValue in interface ProgramSolver<R,C>
Returns:
the most recently computed objective value.
See Also:
optimize()

getSolutionVector

public java.util.Map<C,java.lang.Double> getSolutionVector()
Returns the most recently computed solution vector.

Specified by:
getSolutionVector in interface ProgramSolver<R,C>
Returns:
column variables mapped to their corresponding numerical values.
See Also:
optimize()

getStatus

public ProgramSolverStatus getStatus()
Returns the status of the most recently attempted optimization.

Specified by:
getStatus in interface ProgramSolver<R,C>
Returns:
the status of the most recently attempted optimization.
See Also:
optimize()

setParamFile

public void setParamFile(java.lang.String fileName)
Throws UnsupportedOperationException.

Specified by:
setParamFile in interface ProgramSolver<R,C>
Parameters:
fileName - the name of the file containing parameter values.
Throws:
java.lang.UnsupportedOperationException