public class LPEngineLpSolveImpl extends java.lang.Object implements LPEngine
LPEngine.EngineType, LPEngine.ObjectiveTargetType, LPEngine.Operator, LPEngine.VariableType
Modifier and Type | Field and Description |
---|---|
protected lpsolve.LpSolve |
engine |
protected java.lang.Object |
lock |
Constructor and Description |
---|
LPEngineLpSolveImpl() |
LPEngineLpSolveImpl(int rows,
int columns) |
Modifier and Type | Method and Description |
---|---|
void |
accept(LPEngineVisitor visitor) |
int |
addConstraint(double[] constraint,
LPEngine.Operator operator,
double value)
Add a constraints to the LP Engine
|
int |
addConstraint(java.util.Map<java.lang.Integer,java.lang.Double> constraint,
LPEngine.Operator operator,
double value)
Add a constraints to the LP Engine
|
int |
addVariable(double[] column,
LPEngine.VariableType type)
Add a variable.
|
int |
addVariable(java.util.Map<java.lang.Integer,java.lang.Double> nonZeroValues,
LPEngine.VariableType type)
Add a variable.
|
protected boolean |
boolCheck(double value) |
LPEngine |
clone() |
void |
destroy()
destroy the ILP problem and (try to) free the memory;
|
double[] |
emptyConstraint()
Return an empty constraint ([0,0,...0]) with the appropriate length for
addition.
|
double[] |
emptyVariable()
Return an empty objective array ([0,0,...0]) with the appropriate length
for addition.
|
LPEngine.EngineType |
engineType()
Returns what engineType is actually used by the implementing class.
|
double |
getVariableLowerBound(int variableIndex) |
double |
getVariableUpperBound(int variableIndex) |
static void |
init() |
protected boolean |
intCheck(double value) |
boolean |
isFeasible()
Assess whether is at least one solution
|
protected org.processmining.framework.util.Pair<int[],double[]> |
mapToIndexValueArrayPair(java.util.Map<java.lang.Integer,java.lang.Double> map) |
int |
minimalConstraintIndex()
Given a specific engine type (e.g.
|
int |
minimalVariableIndex()
Given a specific engine type (e.g.
|
int |
numConstraints()
Query the total number of constraints (== rows in matrix)
|
int |
numVariables()
Query the total number of variables (== columns in matrix)
|
void |
pop()
pop a constraint out of the engine (that is the constraint with the max.
|
void |
print()
Print the current state of the LP.
|
boolean |
removeConstraint(int row)
Remove the given constraints.
|
boolean |
removeVariable(int column)
Remove a variable from the LP.
|
boolean |
setConstraint(int row,
double[] constraint)
Set the given row with the provided constraints Note: the size of the
array should equal the number of constraints.
|
boolean |
setConstraint(int row,
double[] constraint,
double rhs)
Set the given row with the provided constraint and rhs.
|
boolean |
setConstraint(int row,
double[] constraint,
LPEngine.Operator op,
double rhs)
Set the given row with the provided constraint, operator and rhs
|
boolean |
setConstraint(int row,
java.util.Map<java.lang.Integer,java.lang.Double> constraint)
Renew the given row with the provided constraints.
|
boolean |
setConstraintOperator(int row,
LPEngine.Operator op)
Set the given constraint's operator (e.g.
|
void |
setEngine(lpsolve.LpSolve engine) |
boolean |
setLowerBound(int column,
double lowerBound)
Set a variable's lower-bound.
|
void |
setMat(int rowIndex,
int columnIndex,
double value)
Set a cell within the engine.
|
boolean |
setObjective(double[] objective,
LPEngine.ObjectiveTargetType target)
Set the objectives value of the P
|
boolean |
setObjective(java.util.Map<java.lang.Integer,java.lang.Double> objective,
LPEngine.ObjectiveTargetType target)
Set the objectives value of the LP
|
boolean |
setObjectiveType(LPEngine.ObjectiveTargetType target)
Set the type of the objectives, either minimize or maximize.
|
boolean |
setRightHandSide(int row,
double rhs) |
void |
setTimeOut(long seconds) |
boolean |
setType(int column,
LPEngine.VariableType type)
Set a variable's type to be of type int.
|
void |
setup() |
boolean |
setUpperBound(int variable,
double upperBound)
Set a variable upperbound.
|
java.util.Map<java.lang.Integer,java.lang.Double> |
solve()
Solve the LP and return the best variable assignment
|
org.processmining.framework.util.Pair<double[],java.lang.Double> |
solveAndResetAndValueNative() |
org.processmining.framework.util.Pair<java.util.Map<java.lang.Integer,java.lang.Double>,java.lang.Double> |
solveAndValue()
Solve the LP and return the best variable assignment and the assignment
value.
|
org.processmining.framework.util.Pair<double[],java.lang.Double> |
solveAndValueNative()
Solve the LP and return the best variable assignment and the assignment
value.
|
double[] |
solveNative()
Solve the LP and return the best variable assignment
|
org.processmining.framework.util.Pair<org.processmining.framework.util.Pair<double[],java.lang.Double>,java.lang.Long> |
solveValueNativeSolveTimeNano() |
protected boolean |
valueMatchesType(double d,
LPEngine.VariableType type) |
protected double[] |
variableMapToArray(java.util.Map<java.lang.Integer,java.lang.Double> variableMap)
translates a variable map (i.e.
|
protected boolean |
variableMatchesType(double[] values,
LPEngine.VariableType type) |
protected boolean |
variableMatchesType(java.util.Map<java.lang.Integer,java.lang.Double> nonZeroValues,
LPEngine.VariableType type) |
void |
writeToFile(java.lang.String dest) |
public LPEngineLpSolveImpl()
public LPEngineLpSolveImpl(int rows, int columns)
public static void init()
public void accept(LPEngineVisitor visitor)
public int addConstraint(double[] constraint, LPEngine.Operator operator, double value)
LPEngine
addConstraint
in interface LPEngine
constraint
- to addoperator
- of constraintsvalue
- target value of constraintspublic int addConstraint(java.util.Map<java.lang.Integer,java.lang.Double> constraint, LPEngine.Operator operator, double value)
LPEngine
addConstraint
in interface LPEngine
constraint
- map of variable to double valueoperator
- of constraintsvalue
- target value of constraintspublic int addVariable(double[] column, LPEngine.VariableType type)
LPEngine
addVariable
in interface LPEngine
column
- an array of double's specifying the columntype
- type of the variablepublic int addVariable(java.util.Map<java.lang.Integer,java.lang.Double> nonZeroValues, LPEngine.VariableType type)
LPEngine
addVariable
in interface LPEngine
nonZeroValues
- mapping of row number to non-zero elementsprotected boolean boolCheck(double value)
public LPEngine clone() throws java.lang.CloneNotSupportedException
public void destroy()
LPEngine
public double[] emptyConstraint()
LPEngine
emptyConstraint
in interface LPEngine
public double[] emptyVariable()
LPEngine
emptyVariable
in interface LPEngine
public LPEngine.EngineType engineType()
LPEngine
engineType
in interface LPEngine
public double getVariableLowerBound(int variableIndex)
getVariableLowerBound
in interface LPEngine
public double getVariableUpperBound(int variableIndex)
getVariableUpperBound
in interface LPEngine
protected boolean intCheck(double value)
public boolean isFeasible()
LPEngine
isFeasible
in interface LPEngine
protected org.processmining.framework.util.Pair<int[],double[]> mapToIndexValueArrayPair(java.util.Map<java.lang.Integer,java.lang.Double> map)
public int minimalConstraintIndex()
LPEngine
minimalConstraintIndex
in interface LPEngine
public int minimalVariableIndex()
LPEngine
minimalVariableIndex
in interface LPEngine
public int numConstraints()
LPEngine
numConstraints
in interface LPEngine
public int numVariables()
LPEngine
numVariables
in interface LPEngine
public void pop()
LPEngine
public void print()
LPEngine
public boolean removeConstraint(int row)
LPEngine
removeConstraint
in interface LPEngine
row
- to be removedpublic boolean removeVariable(int column)
LPEngine
removeVariable
in interface LPEngine
column
- to removepublic boolean setConstraint(int row, double[] constraint)
LPEngine
setConstraint
in interface LPEngine
row
- to setconstraint
- new rowpublic boolean setConstraint(int row, double[] constraint, double rhs)
LPEngine
setConstraint
in interface LPEngine
row
- to setconstraint
- new constraintrhs
- right hand sidepublic boolean setConstraint(int row, double[] constraint, LPEngine.Operator op, double rhs)
LPEngine
setConstraint
in interface LPEngine
row
- to setconstraint
- new constraintop
- operatorrhs
- right hand sidepublic boolean setConstraint(int row, java.util.Map<java.lang.Integer,java.lang.Double> constraint)
LPEngine
setConstraint
in interface LPEngine
row
- number of constraints to renewconstraint
- to updatepublic boolean setConstraintOperator(int row, LPEngine.Operator op)
LPEngine
setConstraintOperator
in interface LPEngine
row
- to setop
- operatorpublic void setEngine(lpsolve.LpSolve engine)
public boolean setLowerBound(int column, double lowerBound)
LPEngine
setLowerBound
in interface LPEngine
column
- identifier of variablelowerBound
- to assing to variablepublic void setMat(int rowIndex, int columnIndex, double value)
LPEngine
public boolean setObjective(double[] objective, LPEngine.ObjectiveTargetType target)
LPEngine
setObjective
in interface LPEngine
objective
- of the LPtarget
- type of objectivespublic boolean setObjective(java.util.Map<java.lang.Integer,java.lang.Double> objective, LPEngine.ObjectiveTargetType target)
LPEngine
setObjective
in interface LPEngine
objective
- Objective of the ILP in terms of column id'starget
- type of objectivespublic boolean setObjectiveType(LPEngine.ObjectiveTargetType target)
LPEngine
setObjectiveType
in interface LPEngine
target
- of objectivespublic boolean setRightHandSide(int row, double rhs)
setRightHandSide
in interface LPEngine
public void setTimeOut(long seconds)
setTimeOut
in interface LPEngine
public boolean setType(int column, LPEngine.VariableType type)
LPEngine
public void setup()
public boolean setUpperBound(int variable, double upperBound)
LPEngine
setUpperBound
in interface LPEngine
variable
- identifier of variableupperBound
- to assing to variablepublic java.util.Map<java.lang.Integer,java.lang.Double> solve()
LPEngine
public org.processmining.framework.util.Pair<double[],java.lang.Double> solveAndResetAndValueNative()
solveAndResetAndValueNative
in interface LPEngine
public org.processmining.framework.util.Pair<java.util.Map<java.lang.Integer,java.lang.Double>,java.lang.Double> solveAndValue()
LPEngine
solveAndValue
in interface LPEngine
public org.processmining.framework.util.Pair<double[],java.lang.Double> solveAndValueNative()
LPEngine
solveAndValueNative
in interface LPEngine
public double[] solveNative()
LPEngine
solveNative
in interface LPEngine
public org.processmining.framework.util.Pair<org.processmining.framework.util.Pair<double[],java.lang.Double>,java.lang.Long> solveValueNativeSolveTimeNano()
solveValueNativeSolveTimeNano
in interface LPEngine
protected boolean valueMatchesType(double d, LPEngine.VariableType type)
protected double[] variableMapToArray(java.util.Map<java.lang.Integer,java.lang.Double> variableMap)
variableMap
- protected boolean variableMatchesType(double[] values, LPEngine.VariableType type)
protected boolean variableMatchesType(java.util.Map<java.lang.Integer,java.lang.Double> nonZeroValues, LPEngine.VariableType type)
public void writeToFile(java.lang.String dest)
writeToFile
in interface LPEngine