Package com.artelys.kalis
Class KXPRSLinearRelaxationSolver
- java.lang.Object
-
- com.artelys.kalis.KRelaxationSolver
-
- com.artelys.kalis.KLinearRelaxationSolver
-
- com.artelys.kalis.KXPRSLinearRelaxationSolver
-
public class KXPRSLinearRelaxationSolver extends KLinearRelaxationSolver
This linear relaxation solver relies on XPress Optimizer to solve the LP/MIP
problem.
Example:
// ... KProblem myProblem(mySession,""); // ... KLinearRelaxation * relax = myProblem.getLinearRelaxation(); KXPRSLinearRelaxationSolver mySolver(*relax, objectiveVar, KProblem::Minimize);
You must have XPress Optimizer installed to use this.
- Since:
- 2016.1
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.artelys.kalis.KLinearRelaxationSolver
KLinearRelaxationSolver.SolveAlgorithm
-
-
Field Summary
-
Fields inherited from class com.artelys.kalis.KRelaxationSolver
swigCMemOwn
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
KXPRSLinearRelaxationSolver(long cPtr, boolean cMemoryOwn)
KXPRSLinearRelaxationSolver(KLinearRelaxation relax, KNumVar obj, int sense)
Constructor (note: no default constructor).
KXPRSLinearRelaxationSolver(KLinearRelaxation relax, KNumVar obj, int sense, int storedBasisSize)
Constructor (note: no default constructor).
KXPRSLinearRelaxationSolver(KXPRSLinearRelaxationSolver arg0)
copy constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete()
protected void
finalize()
void
generateCuts(KLinearRelaxation relaxation)
Generate cuts.
If possible, cuts are added to the matrix of constraints to make
the relaxation tighter and improve the bound.double
getBestBound()
Get the best bound in a branch and bound tree.
Useful if search terminated before optimality.double
getBound()
Get the bound computed by the solver (see class KLinearRelaxationSolver).protected static long
getCPtr(KXPRSLinearRelaxationSolver obj)
double
getLPSolution(KAuxVar var)
Get the current LP solution for a KAuxVar variable.
double
getLPSolution(KNumVar var)
Get the current MIP solution for a KNumVar variable.
double
getMIPSolution(KAuxVar var)
Get the current MIP solution for a KAuxVar variable.
double
getMIPSolution(KNumVar var)
Get the current MIP solution for a KNumVar variable.
int
getNumberGlobals()
Get the number of global variables.
double
getReducedCost(KAuxVar var)
Get reduced costs.
Note that LP solve must be complete.
double
getReducedCost(KNumVar var)
Get reduced costs.
Note that LP solve is must be complete.
KHybridSolution
getSolutionPtr()
Get a pointer to the solution contained in the solver.
Method `updateSolution` must be used before the call.void
instantiateNumVarsToCurrentSol()
Instantiate variables to current solution obtained by linear relaxation solvervoid
instantiateNumVarToCurrentSol(KNumVar var)
Instantiate a variables to current solution obtained by linear relaxation solvervoid
print()
Print the internal state of the solver.
Use is discouraged, use method `writeLP` to output the content of the
solver.void
printSolution(boolean MIPflag)
Print the current solution.
void
printSolverOutput(boolean flag)
Activate or deactivate solver verbose output.void
printSolverOutput(boolean flag, com.artelys.kalis.SWIGTYPE_p_void callback, com.artelys.kalis.SWIGTYPE_p_void userPtr)
void
printVariables()
Print variables name and their rank.
This is useful to recover the meaning of the columns in the LP file produced by writeLP().void
setMipRelStop(double arg0)
Set MIPRELSTOP double control.void
setObjective(KNumVar var)
Set objective variable.
void
setPresolve(boolean arg0)
Activate or deactivate presolve.int
solve()
Call (XPress-Optimizer) and return an error code (see class
KLinearRelaxationSolver for its meaning).void
updateSolution(boolean MIPflag)
Update the KHybridSolution object with the current MIP (MIPflag=true) or
LP (MIPflag=false) solution.
int
writeLP(java.lang.String filename)
Write the current problem to a file in lp format.-
Methods inherited from class com.artelys.kalis.KLinearRelaxationSolver
getCPtr
-
Methods inherited from class com.artelys.kalis.KRelaxationSolver
getAlgorithm, getConfigurator, getCPtr, getInternalPtr, getTimeSpentInLastComputation, getTotalTimeSpentInComputation, isGlobal, isGlobal, setAlgorithm, setAllGlobal, setConfigurator, setGlobal, setGlobal, setIndicatorsGlobal, setMaxMIPSol, setSense, setSolveAsMIP, solveAsMIP
-
-
-
-
Constructor Detail
-
KXPRSLinearRelaxationSolver
protected KXPRSLinearRelaxationSolver(long cPtr, boolean cMemoryOwn)
-
KXPRSLinearRelaxationSolver
public KXPRSLinearRelaxationSolver(KLinearRelaxation relax, KNumVar obj, int sense, int storedBasisSize)
Constructor (note: no default constructor).
- Parameters:
relax
- domain (a linear relaxation)obj
- the objective variablesense
- the sense for optimizationstoredBasisSize
- maximum depth for basis reload
-
KXPRSLinearRelaxationSolver
public KXPRSLinearRelaxationSolver(KLinearRelaxation relax, KNumVar obj, int sense)
Constructor (note: no default constructor).
- Parameters:
relax
- domain (a linear relaxation)obj
- the objective variablesense
- the sense for optimization
-
KXPRSLinearRelaxationSolver
public KXPRSLinearRelaxationSolver(KXPRSLinearRelaxationSolver arg0)
copy constructor
-
-
Method Detail
-
getCPtr
protected static long getCPtr(KXPRSLinearRelaxationSolver obj)
-
finalize
protected void finalize()
- Overrides:
finalize
in classKLinearRelaxationSolver
-
delete
public void delete()
- Overrides:
delete
in classKLinearRelaxationSolver
-
setObjective
public void setObjective(KNumVar var)
Set objective variable.
- Overrides:
setObjective
in classKRelaxationSolver
- Parameters:
var
- the new objective variable
-
solve
public int solve()
Call (XPress-Optimizer) and return an error code (see class
KLinearRelaxationSolver for its meaning).- Overrides:
solve
in classKRelaxationSolver
-
getBound
public double getBound()
Get the bound computed by the solver (see class KLinearRelaxationSolver).- Overrides:
getBound
in classKRelaxationSolver
-
getBestBound
public double getBestBound()
Get the best bound in a branch and bound tree.
Useful if search terminated before optimality.- Overrides:
getBestBound
in classKRelaxationSolver
-
print
public void print()
Print the internal state of the solver.
Use is discouraged, use method `writeLP` to output the content of the
solver.- Overrides:
print
in classKRelaxationSolver
-
writeLP
public int writeLP(java.lang.String filename)
Write the current problem to a file in lp format.- Overrides:
writeLP
in classKLinearRelaxationSolver
- Parameters:
filename
- the path of the file to write (existing file is overwrited, if any)- Returns:
- return code is reserved for future use (for now, errors are trapped by an exception)
-
generateCuts
public void generateCuts(KLinearRelaxation relaxation)
Generate cuts.
If possible, cuts are added to the matrix of constraints to make
the relaxation tighter and improve the bound.- Overrides:
generateCuts
in classKLinearRelaxationSolver
-
printSolution
public void printSolution(boolean MIPflag)
Print the current solution.
- Parameters:
MIPflag
- to choose whether to print the current MIP solution or the current LP solution
-
printVariables
public void printVariables()
Print variables name and their rank.
This is useful to recover the meaning of the columns in the LP file produced by writeLP().
-
getMIPSolution
public double getMIPSolution(KNumVar var)
Get the current MIP solution for a KNumVar variable.
- Overrides:
getMIPSolution
in classKRelaxationSolver
- Parameters:
var
- variable whose value is checked- Returns:
- value of var in the current MIP solution
-
getMIPSolution
public double getMIPSolution(KAuxVar var)
Get the current MIP solution for a KAuxVar variable.
- Overrides:
getMIPSolution
in classKRelaxationSolver
- Parameters:
var
- variable whose value is checked- Returns:
- value of var in the current MIP solution
-
getLPSolution
public double getLPSolution(KNumVar var)
Get the current MIP solution for a KNumVar variable.
- Overrides:
getLPSolution
in classKRelaxationSolver
- Parameters:
var
- variable whose value is checked- Returns:
- value of var in the current MIP solution
-
getLPSolution
public double getLPSolution(KAuxVar var)
Get the current LP solution for a KAuxVar variable.
- Overrides:
getLPSolution
in classKRelaxationSolver
- Parameters:
var
- variable whose value is checked- Returns:
- value of var in the current solution
-
updateSolution
public void updateSolution(boolean MIPflag)
Update the KHybridSolution object with the current MIP (MIPflag=true) or
LP (MIPflag=false) solution.
- Parameters:
MIPflag
- true to get the current MIP solution, false for LP.
-
getSolutionPtr
public KHybridSolution getSolutionPtr()
Get a pointer to the solution contained in the solver.
Method `updateSolution` must be used before the call.
-
getNumberGlobals
public int getNumberGlobals()
Get the number of global variables.
- Overrides:
getNumberGlobals
in classKRelaxationSolver
- Returns:
- number of global variables
-
getReducedCost
public double getReducedCost(KNumVar var)
Get reduced costs.
Note that LP solve is must be complete.
- Overrides:
getReducedCost
in classKLinearRelaxationSolver
- Parameters:
var
- the variable whose reduced cost in the current LP solution is retrieved- Returns:
- reduced cost value
-
getReducedCost
public double getReducedCost(KAuxVar var)
Get reduced costs.
Note that LP solve must be complete.
- Overrides:
getReducedCost
in classKLinearRelaxationSolver
- Parameters:
var
- the variable whose reduced cost in the current LP solution is retrieved- Returns:
- reduced cost value
-
printSolverOutput
public void printSolverOutput(boolean flag)
Activate or deactivate solver verbose output.
-
printSolverOutput
public void printSolverOutput(boolean flag, com.artelys.kalis.SWIGTYPE_p_void callback, com.artelys.kalis.SWIGTYPE_p_void userPtr)
-
setPresolve
public void setPresolve(boolean arg0)
Activate or deactivate presolve.
-
setMipRelStop
public void setMipRelStop(double arg0)
Set MIPRELSTOP double control.
-
instantiateNumVarsToCurrentSol
public void instantiateNumVarsToCurrentSol()
Description copied from class:KRelaxationSolver
Instantiate variables to current solution obtained by linear relaxation solver- Overrides:
instantiateNumVarsToCurrentSol
in classKRelaxationSolver
-
instantiateNumVarToCurrentSol
public void instantiateNumVarToCurrentSol(KNumVar var)
Description copied from class:KRelaxationSolver
Instantiate a variables to current solution obtained by linear relaxation solver- Overrides:
instantiateNumVarToCurrentSol
in classKRelaxationSolver
-
-