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)
LPEngineaddConstraint in interface LPEngineconstraint - 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)
LPEngineaddConstraint in interface LPEngineconstraint - map of variable to double valueoperator - of constraintsvalue - target value of constraintspublic int addVariable(double[] column,
LPEngine.VariableType type)
LPEngineaddVariable in interface LPEnginecolumn - 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)
LPEngineaddVariable in interface LPEnginenonZeroValues - mapping of row number to non-zero elementsprotected boolean boolCheck(double value)
public LPEngine clone() throws java.lang.CloneNotSupportedException
public void destroy()
LPEnginepublic double[] emptyConstraint()
LPEngineemptyConstraint in interface LPEnginepublic double[] emptyVariable()
LPEngineemptyVariable in interface LPEnginepublic LPEngine.EngineType engineType()
LPEngineengineType in interface LPEnginepublic double getVariableLowerBound(int variableIndex)
getVariableLowerBound in interface LPEnginepublic double getVariableUpperBound(int variableIndex)
getVariableUpperBound in interface LPEngineprotected boolean intCheck(double value)
public boolean isFeasible()
LPEngineisFeasible in interface LPEngineprotected org.processmining.framework.util.Pair<int[],double[]> mapToIndexValueArrayPair(java.util.Map<java.lang.Integer,java.lang.Double> map)
public int minimalConstraintIndex()
LPEngineminimalConstraintIndex in interface LPEnginepublic int minimalVariableIndex()
LPEngineminimalVariableIndex in interface LPEnginepublic int numConstraints()
LPEnginenumConstraints in interface LPEnginepublic int numVariables()
LPEnginenumVariables in interface LPEnginepublic void pop()
LPEnginepublic void print()
LPEnginepublic boolean removeConstraint(int row)
LPEngineremoveConstraint in interface LPEnginerow - to be removedpublic boolean removeVariable(int column)
LPEngineremoveVariable in interface LPEnginecolumn - to removepublic boolean setConstraint(int row,
double[] constraint)
LPEnginesetConstraint in interface LPEnginerow - to setconstraint - new rowpublic boolean setConstraint(int row,
double[] constraint,
double rhs)
LPEnginesetConstraint in interface LPEnginerow - to setconstraint - new constraintrhs - right hand sidepublic boolean setConstraint(int row,
double[] constraint,
LPEngine.Operator op,
double rhs)
LPEnginesetConstraint in interface LPEnginerow - to setconstraint - new constraintop - operatorrhs - right hand sidepublic boolean setConstraint(int row,
java.util.Map<java.lang.Integer,java.lang.Double> constraint)
LPEnginesetConstraint in interface LPEnginerow - number of constraints to renewconstraint - to updatepublic boolean setConstraintOperator(int row,
LPEngine.Operator op)
LPEnginesetConstraintOperator in interface LPEnginerow - to setop - operatorpublic void setEngine(lpsolve.LpSolve engine)
public boolean setLowerBound(int column,
double lowerBound)
LPEnginesetLowerBound in interface LPEnginecolumn - identifier of variablelowerBound - to assing to variablepublic void setMat(int rowIndex,
int columnIndex,
double value)
LPEnginepublic boolean setObjective(double[] objective,
LPEngine.ObjectiveTargetType target)
LPEnginesetObjective in interface LPEngineobjective - of the LPtarget - type of objectivespublic boolean setObjective(java.util.Map<java.lang.Integer,java.lang.Double> objective,
LPEngine.ObjectiveTargetType target)
LPEnginesetObjective in interface LPEngineobjective - Objective of the ILP in terms of column id'starget - type of objectivespublic boolean setObjectiveType(LPEngine.ObjectiveTargetType target)
LPEnginesetObjectiveType in interface LPEnginetarget - of objectivespublic boolean setRightHandSide(int row,
double rhs)
setRightHandSide in interface LPEnginepublic void setTimeOut(long seconds)
setTimeOut in interface LPEnginepublic boolean setType(int column,
LPEngine.VariableType type)
LPEnginepublic void setup()
public boolean setUpperBound(int variable,
double upperBound)
LPEnginesetUpperBound in interface LPEnginevariable - identifier of variableupperBound - to assing to variablepublic java.util.Map<java.lang.Integer,java.lang.Double> solve()
LPEnginepublic org.processmining.framework.util.Pair<double[],java.lang.Double> solveAndResetAndValueNative()
solveAndResetAndValueNative in interface LPEnginepublic org.processmining.framework.util.Pair<java.util.Map<java.lang.Integer,java.lang.Double>,java.lang.Double> solveAndValue()
LPEnginesolveAndValue in interface LPEnginepublic org.processmining.framework.util.Pair<double[],java.lang.Double> solveAndValueNative()
LPEnginesolveAndValueNative in interface LPEnginepublic double[] solveNative()
LPEnginesolveNative in interface LPEnginepublic org.processmining.framework.util.Pair<org.processmining.framework.util.Pair<double[],java.lang.Double>,java.lang.Long> solveValueNativeSolveTimeNano()
solveValueNativeSolveTimeNano in interface LPEngineprotected 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