net.sf.javailp
Class Problem

java.lang.Object
  extended by net.sf.javailp.Problem

public class Problem
extends Object

The class Problem represents a linear problem consisting of multiple constraints and up to one objective function.


Constructor Summary
Problem()
          Constructs a Problem.
 
Method Summary
 void add(Constraint constraint)
          Adds a constraint.
 void add(Linear lhs, Operator operator, Number rhs)
          Adds a constraint.
 void add(Linear lhs, String operator, Number rhs)
          Adds a constraint.
 void add(String name, Linear lhs, Operator operator, Number rhs)
          Adds a constraint.
 void add(String name, Linear lhs, String operator, Number rhs)
          Adds a constraint.
 List<Constraint> getConstraints()
          Returns the constraints.
 int getConstraintsCount()
          Returns the number of objectives.
 Linear getObjective()
          Returns the objective function.
 OptType getOptType()
          Returns the optimization type.
 Collection<Object> getVariables()
          Returns the variables.
 int getVariablesCount()
          Returns the number of variables.
 Number getVarLowerBound(Object variable)
          Returns the lower bound of a variable.
 VarType getVarType(Object variable)
          Returns the variable type.
 Number getVarUpperBound(Object variable)
          Returns the upper bound of a variable.
 void setObjective(Linear objective)
          Sets the objective function.
 void setObjective(Linear objective, OptType optType)
          Sets the objective function.
 void setObjective(Linear objective, String optType)
          Sets the objective function.
 void setOptimizationType(OptType optType)
          Sets the optimization type.
 void setVarLowerBound(Object variable, Number value)
          Sets the lower bound of a variable.
 void setVarType(Object variable, Class<?> type)
          Sets the variable type of one variable.
 void setVarType(Object variable, VarType type)
          Sets the variable type of one variable.
 void setVarUpperBound(Object variable, Number value)
          Sets the upper bound of a variable.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Problem

public Problem()
Constructs a Problem.

Method Detail

getObjective

public Linear getObjective()
Returns the objective function.

Returns:
the objective function

setObjective

public void setObjective(Linear objective)
Sets the objective function.

Parameters:
objective - the objective function

setObjective

public void setObjective(Linear objective,
                         OptType optType)
Sets the objective function.

Parameters:
objective - the objective function
optType - the optimization type

setObjective

public void setObjective(Linear objective,
                         String optType)
Sets the objective function.

Parameters:
objective - the objective function
optType - the optimization type (min,max)

setOptimizationType

public void setOptimizationType(OptType optType)
Sets the optimization type.

Parameters:
optType - the optimization type to be set

getOptType

public OptType getOptType()
Returns the optimization type.

Returns:
the optimization type

getConstraints

public List<Constraint> getConstraints()
Returns the constraints.

Returns:
the constraints.

getConstraintsCount

public int getConstraintsCount()
Returns the number of objectives.

Returns:
the number of objectives

getVariables

public Collection<Object> getVariables()
Returns the variables.

Returns:
the variables

getVariablesCount

public int getVariablesCount()
Returns the number of variables.

Returns:
the number of variables

add

public void add(Constraint constraint)
Adds a constraint.

Parameters:
constraint - the constraint to be added

add

public void add(Linear lhs,
                Operator operator,
                Number rhs)
Adds a constraint.

Parameters:
lhs - the left-hand-side linear expression
operator - the operator
rhs - the right-hand-side number

add

public void add(Linear lhs,
                String operator,
                Number rhs)
Adds a constraint.

Parameters:
lhs - the left-hand-side linear expression
operator - the operator (<=,=,>=)
rhs - the right-hand-side number

add

public void add(String name,
                Linear lhs,
                Operator operator,
                Number rhs)
Adds a constraint.

Parameters:
name - the name of the constraint
lhs - the left-hand-side linear expression
operator - the operator
rhs - the right-hand-side number

add

public void add(String name,
                Linear lhs,
                String operator,
                Number rhs)
Adds a constraint.

Parameters:
name - the name of the constraint
lhs - the left-hand-side linear expression
operator - the operator (<=,=,>=)
rhs - the right-hand-side number

getVarType

public VarType getVarType(Object variable)
Returns the variable type.

Parameters:
variable - the variable
Returns:
the type

setVarType

public void setVarType(Object variable,
                       VarType type)
Sets the variable type of one variable.

Parameters:
variable - the variable
type - the type

setVarType

public void setVarType(Object variable,
                       Class<?> type)
Sets the variable type of one variable. The allowed types are Integer, Boolean, and Double.

Parameters:
variable - the variable
type - the type

getVarLowerBound

public Number getVarLowerBound(Object variable)
Returns the lower bound of a variable.

Parameters:
variable - the lower bound
Returns:
the variable or null if no lower bound exists

getVarUpperBound

public Number getVarUpperBound(Object variable)
Returns the upper bound of a variable.

Parameters:
variable - the upper bound
Returns:
the variable or null if no upper bound exists

setVarLowerBound

public void setVarLowerBound(Object variable,
                             Number value)
Sets the lower bound of a variable.

Parameters:
variable - the variable
value - the lower bound value

setVarUpperBound

public void setVarUpperBound(Object variable,
                             Number value)
Sets the upper bound of a variable.

Parameters:
variable - the variable
value - the upper bound value

toString

public String toString()
Overrides:
toString in class Object