XPRBprob
- java.lang.Object
-
- com.dashoptimization.XPRBprob
-
public class XPRBprob extends java.lang.Object
This class represents a problem definition in BCL.
-
-
Method Summary
Modifier and Type Method and Description void
addCuts(XPRBcut[] ca)
Add an array of cuts to the Optimizer problem.void
addMIPSol(XPRBsol sol)
void
addMIPSol(XPRBsol sol, java.lang.String name)
Add a MIP solution into the Optimizer.void
beginCB(com.dashoptimization.XPRSprob optprob)
Start working with BCL within an Optimizer callback.void
clearDir()
Delete all directives.void
delCtr(XPRBctr ctr)
Delete a constraint.void
delSol(XPRBsol sol)
Delete a solution.void
delSos(XPRBsos sos)
Delete a SOS.void
endCB()
Terminate working with BCL within an Optimizer callback.void
exportProb()
void
exportProb(int format)
void
exportProb(int format, java.lang.String fname)
Print problem matrix to a file.void
exportProb(java.lang.String fname)
void
finalize()
Finalize the problem.void
fixGlobals()
void
fixGlobals(boolean ifround)
Fix all the global entities Fixes all the global entities to the values of the last found MIP solution.XPRBctr
getCtrByName(java.lang.String name)
Retrieve a constraint by its name.java.lang.Iterable<XPRBctr>
getCtrs()
Returns an iterable (anonymous) object over the constraints in this problem.void
getIIS(java.util.ArrayList arrvar, java.util.ArrayList arrctr)
void
getIIS(java.util.ArrayList arrvar, java.util.ArrayList arrctr, java.util.ArrayList arrsos)
void
getIIS(java.util.ArrayList arrvar, java.util.ArrayList arrctr, java.util.ArrayList arrsos, int num)
Get IIS variables, constraints, and SOS.void
getIIS(java.util.ArrayList arrvar, java.util.ArrayList arrctr, int num)
XPRBindexSet
getIndexSetByName(java.lang.String name)
Retrieve an index set by its name.int
getLPStat()
Get the LP status.int
getMIPStat()
Get the MIP (global) status.java.lang.String
getName()
Get the name of a problem.int
getNumIIS()
Get the number of independent IIS.double
getObjVal()
Get the objective function value.int
getProbStat()
Get the problem status.int
getSense()
Get the sense of the objective function.XPRBsos
getSosByName(java.lang.String name)
Retrieve a SOS by its name.XPRBvar
getVarByName(java.lang.String name)
Retrieve a variable by its name.double
getXPRSdblAttrib(int c)
Deprecated.Use getXPRSprob in conjunction with getDblAttribdouble
getXPRSdblControl(int c)
Deprecated.Use getXPRSprob in conjunction with getDblControlint
getXPRSintAttrib(int c)
Deprecated.Use getXPRSprob in conjunction with getIntAttribint
getXPRSintControl(int c)
Deprecated.Use getXPRSprob in conjunction with getIntControlcom.dashoptimization.XPRSprob
getXPRSprob()
Retrieve the associated XPRSprob object.boolean
isValid()
Test whether a problem is correctly defined.void
loadBasis(XPRBbasis bs)
Load a previously saved basis.void
loadMat()
Load a problem into Xpress-Optimizer.int
loadMIPSol(double[] sol)
int
loadMIPSol(double[] sol, boolean ifopt)
Load an integer solution into BCL or the Optimizer.void
lpOptimise()
void
lpOptimise(java.lang.String alg)
void
lpOptimize()
void
lpOptimize(java.lang.String alg)
Solve as a continuous problem.void
maxim()
Deprecated.Use setSense(XPRB.MAXIM) and lpOptimize or mipOptimizevoid
maxim(java.lang.String alg)
Deprecated.Use setSense(XPRB.MAXIM) and lpOptimize or mipOptimizevoid
minim()
Deprecated.Use lpOptimize or mipOptimizevoid
minim(java.lang.String alg)
Deprecated.Use lpOptimize or mipOptimizevoid
mipOptimise()
void
mipOptimise(java.lang.String alg)
void
mipOptimize()
void
mipOptimize(java.lang.String alg)
Solve as a discrete problem.XPRBctr
newCtr()
XPRBctr
newCtr(java.lang.String name)
XPRBctr
newCtr(java.lang.String name, XPRBexpr l)
XPRBctr
newCtr(java.lang.String name, XPRBrelation lr)
Create a new constraint.XPRBctr
newCtr(XPRBexpr l)
XPRBctr
newCtr(XPRBrelation lr)
XPRBcut
newCut()
XPRBcut
newCut(int id)
XPRBcut
newCut(XPRBexpr l)
XPRBcut
newCut(XPRBexpr l, int id)
XPRBcut
newCut(XPRBrelation lr)
XPRBcut
newCut(XPRBrelation lr, int id)
Create a new cut.XPRBindexSet
newIndexSet()
XPRBindexSet
newIndexSet(int maxsize)
XPRBindexSet
newIndexSet(java.lang.String name)
XPRBindexSet
newIndexSet(java.lang.String name, int maxsize)
Create a new index set.XPRBsol
newSol()
Create a solution.XPRBsos
newSos(int type)
XPRBsos
newSos(int type, XPRBexpr le)
XPRBsos
newSos(java.lang.String name, int type)
XPRBsos
newSos(java.lang.String name, int type, XPRBexpr le)
Create a SOS.XPRBvar
newVar()
XPRBvar
newVar(double lob, double upb)
XPRBvar
newVar(int type)
XPRBvar
newVar(int type, double lob, double upb)
XPRBvar
newVar(java.lang.String name)
XPRBvar
newVar(java.lang.String name, double lob, double upb)
XPRBvar
newVar(java.lang.String name, int type)
XPRBvar
newVar(java.lang.String name, int type, double lob, double upb)
Create a variable.void
print()
Print out a problem.void
readBinSol()
void
readBinSol(java.lang.String fname)
void
readBinSol(java.lang.String fname, java.lang.String flags)
Read solution from a binary file.void
readSlxSol()
void
readSlxSol(java.lang.String fname)
void
readSlxSol(java.lang.String fname, java.lang.String flags)
Read solution from an ASCII file.void
reset()
Reset the problem.XPRBbasis
saveBasis()
Save the current basis.void
setColOrder(int num)
Set a column ordering criterion for matrix generation.void
setCutMode(int mode)
Parameter settings for cuts.void
setDictionarySize(int dico, int size)
Set the size of a dictionary.void
setMsgLevel(int level)
Set the message print level.void
setName(java.lang.String name)
Set the name of a problem.void
setObj(XPRBctr ctr)
Select the objective function.void
setObj(XPRBexpr q)
Set the objective function.void
setObj(XPRBvar v)
void
setOutputStream()
Set the output stream object.void
setOutputStream(java.lang.Object stream)
Set the output stream object.void
setRealFmt(java.lang.String fmt)
Set the format for printing real numbers.void
setSense(int dir)
Set the sense of the objective function.void
setXPRSdblControl(int c, double val)
Deprecated.Use getXPRSprob in conjunction with setDblControlvoid
setXPRSintControl(int c, int val)
Deprecated.Use getXPRSprob in conjunction with setIntControlvoid
solve()
Deprecated.Use lpOptimize or mipOptimizevoid
solve(java.lang.String alg)
Deprecated.Use lpOptimize or mipOptimizevoid
sync(int synctype)
Synchronize BCL with the Optimizer.java.lang.String
toString()
void
writeBinSol()
void
writeBinSol(java.lang.String fname)
void
writeBinSol(java.lang.String fname, java.lang.String flags)
Write solution to a binary file.void
writeDir()
void
writeDir(java.lang.String fname)
Write directives to a file.void
writePrtSol()
void
writePrtSol(java.lang.String fname)
void
writePrtSol(java.lang.String fname, java.lang.String flags)
Write solution to a fixed format ASCII file.void
writeSlxSol()
void
writeSlxSol(java.lang.String fname)
void
writeSlxSol(java.lang.String fname, java.lang.String flags)
Write solution to an ASCII file.void
writeSol()
void
writeSol(java.lang.String fname)
void
writeSol(java.lang.String fname, java.lang.String flags)
Write solution to a CSV file.
-
-
-
Method Detail
-
isValid
public boolean isValid()
Test whether a problem is correctly defined.XPRBprob expl2; if(expl2.isValid() == false) System.out.println("Error in problem definition.");
-
reset
public void reset()
Reset the problem. This method deletes any solution information stored in BCL; it also deletes the corresponding Optimizer problem and removes any auxiliary files that may have been created by optimization runs. The problem definition itself remains. This method may be used to free up memory if the solution information is not required any longer but the problem definition is to be kept for later (re)use.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.mipOptimize(); expl2.reset();
-
setMsgLevel
public void setMsgLevel(int level)
Set the message print level. BCL can produce different types of messages; status information, warnings and errors. This method controls which of these are output. In case of an error, an exception is raised before any message is output by BCL. The text and numbers of errors can be obtained with methodsXPRBerror.getMessage()
andXPRBerror.getErrorCode()
respectively.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.setMsgLevel(0);
- Parameters:
-
level
- message level (= types of messages printed by BCL). Possible values:0
disable all output from BCL and Xpress-Optimizer2
print warnings3
print warnings and Optimizer log (default)4
all messages printed
-
setOutputStream
public void setOutputStream(java.lang.Object stream)
Set the output stream object. BCL uses this object whenever it needs to display text (information, warning or error messages). The provided object must implement either a 'void write(String)' method (like in a Writer class) or a 'void print(String)' method (like in a printStream class).prob.setOutputStream(System.err);
- Parameters:
-
stream
- an object implementing either a 'write' or 'print' method
-
setOutputStream
public void setOutputStream()
Set the output stream object.- See Also:
-
setOutputStream(System.err)
-
setRealFmt
public void setRealFmt(java.lang.String fmt)
Set the format for printing real numbers. In problems with very large or very small numbers it may become necessary to change the printing format to obtain a more exact output. In particular, by changing the precision it is possible to reduce the difference between matrices loaded in memory into Xpress-Optimizer and the output produced by exporting them to a file.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.setRealFmt("%.10f");
- Parameters:
-
fmt
- format string (as used by the C function printf). Possible values include:"%g"
default printing format (precision: 6 digits; exponential notation if the exponent resulting from the conversion is less than -4 or greater than or equal to the precision)"%.
numf
print real numbers in the style[-]d.d
where the number of digits after the decimal point is equal to the given precision num
-
setColOrder
public void setColOrder(int num)
Set a column ordering criterion for matrix generation. BCL runs reproduce always the same matrix for a problem. This method allows the user to choose a different ordering criterion than the default one.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.setColOrder(1);
- Parameters:
-
num
- ordering criterion. Possible values:0
default order1
alphabetical order
-
newVar
public XPRBvar newVar(java.lang.String name, int type, double lob, double upb)
Create a variable. The creation of a variable in BCL involves not only its name but also its type and bounds (which may be infinite, defined by the corresponding Xpress constants). If the indicated name is already in use, BCL adds an index to it. If no variable name is given, BCL generates a default name starting withVAR
. (The generation of unique names will only take place if the names dictionary is enabled, seesetDictionarySize(int, int)
). If a partial integer, semi-continuous, or semi-continuous integer variable is being created, the integer or semi-continuous limit (= lower bound of the continuous part for partial integer and semi-continuous, and of the semi-continuous integer part for semi-continuous integer) is set to the maximum of 1 andbdl
. This value can be subsequently modified with the methodXPRBvar.setLim(double)
.XPRBprob expl2; XPRBvar x1,x2; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x2 = expl2.newVar("efg2", XPRB.SC, 0, 20); // x2=0 or 1<=x2<=20
- Parameters:
-
type
- variable type. Possible values:XPRB.PL
continuous (default)XPRB.BV
binaryXPRB.UI
general integerXPRB.PI
partial integerXPRB.SC
semi-continuousXPRB.SI
semi-continuous integer
-
name
- variable name (up to 64 characters), may benull
-
lob
- lower bound, may be-XPRB.INFINITY
for minus infinity (default0
) -
upb
- upper bound, may beXPRB.INFINITY
for plus infinity (defaultXPRB.INFINITY
) - Returns:
-
A new variable of type
XPRBvar
-
newVar
public XPRBvar newVar(java.lang.String name, int type)
- See Also:
-
newVar(name, type, 0, XPRB.INFINITY)
-
newVar
public XPRBvar newVar(java.lang.String name, double lob, double upb)
- See Also:
-
newVar(name, XPRB.PL, lob, upb)
-
newVar
public XPRBvar newVar(java.lang.String name)
- See Also:
-
newVar(name, XPRB.PL, 0, XPRB.INFINITY)
-
newVar
public XPRBvar newVar(int type)
- See Also:
-
newVar(null, type, 0, XPRB.INFINITY)
-
newVar
public XPRBvar newVar(int type, double lob, double upb)
- See Also:
-
newVar(null, type, lob, upb)
-
newVar
public XPRBvar newVar(double lob, double upb)
- See Also:
-
newVar(null, XPRB.PL, lob, upb)
-
newVar
public XPRBvar newVar()
- See Also:
-
newVar("", XPRB.PL, 0, XPRB.INFINITY)
-
newCtr
public XPRBctr newCtr(java.lang.String name, XPRBrelation lr)
Create a new constraint. This method has to be called beforeXPRBctr.addTerm(com.dashoptimization.XPRBvar, double)
orXPRBctr.setTerm(com.dashoptimization.XPRBvar, double)
are used to add terms to the constraint. Range constraints can first be created with any type and then converted using the functionXPRBctr.setRange(double, double)
. If the indicated name is already in use, BCL adds an index to it. If no constraint name is given, BCL generates a default name starting withCTR
. (The generation of unique names will only take place if the names dictionary is enabled, seesetDictionarySize(int, int)
).XPRBprob expl2; XPRBvar x2; XPRBctr ctr1; expl2 = new XPRBprob("example2"); x2 = expl2.newVar("x2"); ctr1 = expl2.newCtr("r1", x2.gEql(3));
- Parameters:
-
name
- constraint name (up to 64 characters), may benull
(default) -
lr
- linear relation (default 0-valued, non-binding relation) - Returns:
-
A new constraint of type
XPRBctr
-
newCtr
public XPRBctr newCtr(java.lang.String name)
- See Also:
-
newCtr(name, 0)
-
newCtr
public XPRBctr newCtr()
- See Also:
-
newCtr(null, 0)
-
newCtr
public XPRBctr newCtr(XPRBrelation lr)
- See Also:
-
newCtr(null, lr)
-
newCtr
public XPRBctr newCtr(XPRBexpr l)
- See Also:
-
newCtr(null, l)
-
newCtr
public XPRBctr newCtr(java.lang.String name, XPRBexpr l)
- See Also:
-
newCtr(name, l)
-
delCtr
public void delCtr(XPRBctr ctr)
Delete a constraint. If this constraint has previously been selected as the objective function (using methodsetObj(com.dashoptimization.XPRBctr)
), the objective will be set tonull
. If the constraint occurs in a previously saved basis that is to be (re)loaded later on you should change its type toXPRB.N
usingXPRBctr.setType(int)
instead of entirely deleting the constraint.XPRBprob expl2; XPRBvar x2; XPRBctr ctr1; expl2 = new XPRBprob("example2"); x2 = expl2.newVar("x2"); ctr1 = expl2.newCtr("r1", x2.gEql(3)); expl2.delCtr(ctr1);
- Parameters:
-
ctr
- constraint of typeXPRBctr
-
setObj
public void setObj(XPRBctr ctr)
Select the objective function. The variable terms of the indicated constraint become the objective function. The objective function must be set before any optimization task is carried out. Typically, the objective constraint will have the typeXPRB.N
, but any other type of constraint may be chosen too. In the latter case, the equation or inequality expressed by the constraint also remains part of the problem. Changes to the constraint after setting the objective function will also modify the latter.XPRBprob expl2; XPRBctr ctr3; XPRBvar[] x; int i; expl2 = new XPRBprob("example2"); for(i=0;i<5;i++) x[i] = expl2.newVar("x"); ctr3 = expl2.newCtr("r3", x[0].add(x[1]).lEql(10)); expl2.setObj(ctr3);
- Parameters:
-
ctr
- constraint of typeXPRBctr
-
setObj
public void setObj(XPRBexpr q)
Set the objective function. The indicated expression becomes the objective function. Changes to the expression after setting the objective function will have no effect on the latter. The objective function must be set before any optimization task is carried out.XPRBprob expl2; XPRBexpr qe; XPRBvar[] x; int i; expl2 = new XPRBprob("example2"); for(i=0;i<5;i++) x[i] = expl2.newVar("x"); qe = new XPRBexpr(); qe.add(x[2].mul(x[3])); expl2.setObj(qe);
- Parameters:
-
q
- expression of typeXPRBexpr
-
newSol
public XPRBsol newSol()
Create a solution. This method creates a new solution.XPRBprob expl2; XPRBvar x; XPRBsol sol1; expl2 = new XPRBprob("example2"); x = expl2.newVar("x"); sol1 = expl2.newSol(); sol1.addVar(x, 1.0);
- Returns:
- A new solution
-
newSos
public XPRBsos newSos(int type)
- See Also:
-
newSos(null, type, 0)
-
newSos
public XPRBsos newSos(java.lang.String name, int type)
- See Also:
-
newSos(name, type, 0)
-
newSos
public XPRBsos newSos(int type, XPRBexpr le)
- See Also:
-
newSos(null, type, le)
-
newSos
public XPRBsos newSos(java.lang.String name, int type, XPRBexpr le)
Create a SOS. This method creates a Special Ordered Set (SOS) of type 1 or 2 (abbreviated SOS1 and SOS2). If a linear expression is given as parameter, the variables in the expression are added to the SOS and the coefficient of each variable becomes its weight. Further set elements may be added (methodXPRBsos.addElement(com.dashoptimization.XPRBvar, double)
) or deleted (methodXPRBsos.delElement(com.dashoptimization.XPRBvar)
). If the indicated name is already in use, BCL adds an index to it. If no name is given for the set, BCL generates a default name starting withSOS
. (The generation of unique names will only take place if the names dictionary is enabled, seesetDictionarySize(int, int)
).XPRBprob expl2; XPRBvar[] x; int i; XPRBexpr l; XPRBsos set1; expl2 = new XPRBprob("example2"); for(i=0;i<5;i++) x[i] = expl2.newVar("x"); l = new XPRBexpr(); for(i=1;i<4;i++) l.add(x[i].mul(i)); set1 = expl2.newSos("sos1", XPRB.S1, l);
- Parameters:
-
name
- name of the set -
type
- set type. Possible values:XPRB.S1
Special Ordered Set of type 1XPRB.S2
Special Ordered Set of type 2
-
le
- linear expression - Returns:
- A new SOS
-
delSol
public void delSol(XPRBsol sol)
Delete a solution. This method deletes a solution.XPRBprob expl2; XPRBvar x; XPRBsol sol1; expl2 = new XPRBprob("example2"); x = expl2.newVar("x"); sol1 = expl2.newSol(); sol1.addVar(x, 1.0); expl2.delSol(sol1);
- Parameters:
-
sol
- previously created solution
-
delSos
public void delSos(XPRBsos sos)
Delete a SOS. This method deletes a SOS without deleting the variables it consists of.XPRBprob expl2; XPRBvar[] x; int i; XPRBexpr l; XPRBsos set1; expl2 = new XPRBprob("example2"); for(i=0;i<5;i++) x[i] = expl2.newVar("x"); l = new XPRBexpr(); for(i=1;i<4;i++) l.add(x[i].mul(i)); set1 = expl2.newSos("sos1", XPRB.S1, l); expl2.delSos(set1);
- Parameters:
-
sos
- previously created SOS of type 1 or 2
-
newIndexSet
public XPRBindexSet newIndexSet()
- See Also:
-
newIndexSet(null, 0)
-
newIndexSet
public XPRBindexSet newIndexSet(java.lang.String name)
- See Also:
-
newIndexSet(name, 0)
-
newIndexSet
public XPRBindexSet newIndexSet(int maxsize)
- See Also:
-
newIndexSet(null, maxsize)
-
newIndexSet
public XPRBindexSet newIndexSet(java.lang.String name, int maxsize)
Create a new index set. Note that the indicated sizemaxsize
corresponds to the space allocated initially to the set, but it is increased dynamically if need be. If the indicated set name is already in use, BCL adds an index to it. If no name is given, BCL generates a default name starting withIDX
. (The generation of unique names will only take place if the names dictionary is enabled, seesetDictionarySize(int, int)
).XPRBprob expl2; XPRBindexSet iset; expl2 = new XPRBprob("example2"); iset = expl2.newIndexSet("Set",100);
- Parameters:
-
name
- name of the index set to be created, may benull
-
maxsize
- maximum size of the index set (default 0) - Returns:
-
A new index set of type
XPRBindexSet
-
saveBasis
public XPRBbasis saveBasis()
Save the current basis. This method saves the basis for the current problem in the optimizer by creating a new object of typeXPRBbasis
. The basis may be re-input using methodloadBasis(com.dashoptimization.XPRBbasis)
.XPRBprob expl2; XPRBbasis bs1; expl2 = new XPRBprob("example2"); expl2.lpOptimize(""); bs1 = expl2.saveBasis();
- Returns:
-
A new basis of type
XPRBbasis
-
loadBasis
public void loadBasis(XPRBbasis bs)
Load a previously saved basis. This method loads a basis for the current problem in the optimizer. The basis must have been saved using methodsaveBasis()
. It is not possible to load a basis saved for any other problem, even if the problems are similar. This method takes into account that the problem may have been modified since the basis has been stored (addition of variables and constraints is handled - deletion of constraints is not handled: instead of entirely deleting a constraint, change its type toXPRB.N
usingXPRBctr.setType(int)
if you wish to load the basis later on). Note that the problem has to be loaded explicitly (methodloadMat()
) before the basis is re-input with this method.XPRBprob expl2; XPRBbasis bs1; XPRBvar x2; XPRBctr ctr1; expl2 = new XPRBprob("example2"); expl2.lpOptimize(); bs1 = expl2.saveBasis(); x2 = expl2.newVar("x2"); ctr1 = expl2.newCtr("r1", x2.gEql(3)); expl2.loadMat(); expl2.loadBasis(bs1);
- Parameters:
-
bs
- basis of typeXPRBbasis
-
clearDir
public void clearDir()
Delete all directives. Directives may be set on variables (methodXPRBvar.setDir(int, double)
) or on SOS (method XPRBsos#setPriority).XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.clearDir();
-
setSense
public void setSense(int dir)
Set the sense of the objective function. The objective sense is set to minimization by default.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.setSense(XPRB.MAXIM);
- Parameters:
-
dir
- sense of the objective function. Possible values:XPRB.MAXIM
maximize the objectiveXPRB.MINIM
minimize the objective (default)
-
getSense
public int getSense()
Get the sense of the objective function. The objective sense (maximization or minimization) is set to minimization by default and may be changed with methodssetSense(int)
,minim()
, andmaxim()
.XPRBprob expl2; int dir; expl2 = new XPRBprob("example2"); dir = expl2.getSense();
- Returns:
-
Sense of the objective function. Possible values:
XPRB.MAXIM
maximize the objectiveXPRB.MINIM
minimize the objective-1
in case of error
-
getName
public java.lang.String getName()
Get the name of a problem.XPRBprob expl2; String pbname; expl2 = new XPRBprob("example2"); pbname = expl2.getName(); System.out.println("Problem name: " + pbname);
- Returns:
-
Name of the given problem if method executed successfully,
null
otherwise
-
setName
public void setName(java.lang.String name)
Set the name of a problem.XPRBprob expl2; String pbname; expl2 = new XPRBprob("example2"); expl2.setName("example_two"); pbname = expl2.getName(); System.out.println("Problem name: " + pbname);
-
exportProb
public void exportProb(int format) throws java.io.IOException
- Throws:
-
java.io.IOException
- See Also:
-
exportProb(format, null)
-
exportProb
public void exportProb(java.lang.String fname) throws java.io.IOException
- Throws:
-
java.io.IOException
- See Also:
-
exportProb(XPRB.LP, fname)
-
exportProb
public void exportProb() throws java.io.IOException
- Throws:
-
java.io.IOException
- See Also:
-
exportProb(XPRB.LP, null)
-
exportProb
public void exportProb(int format, java.lang.String fname) throws java.io.IOException
Print problem matrix to a file. This method prints the matrix to a file with an extended LP or extended MPS format. Provided that no extension is given by the user LP files receive the extension.lp
. MPS files always receive the extension.mps
. This method is not available in the Student Edition. When exporting matrices semi-continuous and semi-continuous integer variables are preprocessed: if a lower bound value greater than 0 is given, then the variable is treated like a continuous (resp. integer) variable. The precision used by BCL for printing real numbers can be changed withsetRealFmt(java.lang.String)
to obtain more accurate output for very large or very small numbers. For full precision matrix output the user is advised to switch to the Optimizer function XPRSproblem.writeProb, preceded by a call toloadMat()
.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.exportProb(XPRB.MPS, "ex2");
- Parameters:
-
format
- matrix output file format. Possible values:XPRB.LP
LP file formatXPRB.MPS
MPS file format
-
fname
- name of the output file without extension - Throws:
-
java.io.IOException
-
fixGlobals
public void fixGlobals()
- See Also:
-
fixGlobals(true) fixGlobals(true)
-
fixGlobals
public void fixGlobals(boolean ifround)
Fix all the global entities Fixes all the global entities to the values of the last found MIP solution. This is useful for finding the reduced costs for the continuous variables after the global variables have been fixed to their optimal values.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.mipOptimize(); expl2.fixGlobals(); expl2.lpOptimize();
- Parameters:
-
ifround
- if all global entities should be rounded to the nearest discrete value in the solution before being fixed.
-
writeDir
public void writeDir() throws java.io.IOException
- Throws:
-
java.io.IOException
- See Also:
-
writeDir(null)
-
writeDir
public void writeDir(java.lang.String fname) throws java.io.IOException
Write directives to a file. This method writes out to a file the directives defined for a problem. The extension.dir
is appended to the given file name. When no file name is given, the name of the problem is used. If a file of the given name exists already it is replaced.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.writeDir();
- Parameters:
-
fname
- name of the output file without extension - Throws:
-
java.io.IOException
-
loadMat
public void loadMat()
Load a problem into Xpress-Optimizer. This method calls the Xpress-Optimizer methods XPRSloadlp, XPRSloadqprob, XPRSloadglobal, or XPRSloadqglobal (see Xpress-Optimizer manual for details) to transform the current BCL problem definition into a matrix in Xpress-Optimizer. Empty rows and columns are deleted before generating the matrix. Semi-continuous (integer) variables are preprocessed: if a lower bound value greater than 0 is given, then the variable is treated like a continuous (resp. integer) variable. Variables that belong to the problem but do not appear in the matrix receive negative column numbers. Usually, it is not necessary to call this method explicitly because BCL automatically does this conversion whenever it is required.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.loadMat();
-
lpOptimise
public void lpOptimise()
- See Also:
-
lpOptimize("")
-
lpOptimise
public void lpOptimise(java.lang.String alg)
- See Also:
-
lpOptimize(alg)
-
lpOptimize
public void lpOptimize()
- See Also:
-
lpOptimize("")
-
lpOptimize
public void lpOptimize(java.lang.String alg)
Solve as a continuous problem. This method selects and starts the Xpress-Optimizer LP/QP solution algorithm. The characters indicating the algorithm choice may be combined where it makes sense, e.g. "pn". If the matrix loaded in Xpress-Optimizer does not correspond to the current problem definition it is regenerated automatically prior to the start of the algorithm. The sense of the optimization (default: minimization) can be changed with methodsetSense(int)
. Before solving a problem, the objective function must be selected withsetObj(com.dashoptimization.XPRBctr)
.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.setSense(XPRB.MAXIM); expl2.lpOptimize("b");
- Parameters:
-
alg
- choice of the solution algorithm. Possible values:"p"
use primal simplex algorithm"d"
use dual simplex algorithm"b"
use Newton-Barrier algorithm"n"
use the network solver"c"
continue previously interrupted optimization run""
no parameter: use the default setting
-
mipOptimise
public void mipOptimise()
- See Also:
-
mipOptimize("")
-
mipOptimise
public void mipOptimise(java.lang.String alg)
- See Also:
-
mipOptimize(alg)
-
mipOptimize
public void mipOptimize()
- See Also:
-
mipOptimize("")
-
mipOptimize
public void mipOptimize(java.lang.String alg)
Solve as a discrete problem. This method selects and starts the Xpress-Optimizer MIP/MIQP solution algorithm. The characters indicating the algorithm choice may be combined where it makes sense, e.g. "pl". If the matrix loaded in Xpress-Optimizer does not correspond to the current problem definition it is regenerated automatically prior to the start of the algorithm. The sense of the optimization (default: minimization) can be changed with methodsetSense(int)
. Before solving a problem, the objective function must be selected withsetObj(com.dashoptimization.XPRBctr)
.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.setSense(XPRB.MINIM); expl2.mipOptimize("p");
- Parameters:
-
alg
- choice of the solution algorithm. Possible values:"p"
use primal simplex algorithm"d"
use dual simplex algorithm"b"
use Newton-Barrier algorithm"n"
use the network solver (for the initial LP)"l"
stop after solving the initial continuous relaxation"c"
continue previously interrupted optimization run""
no parameter: use the default setting
-
solve
public void solve()
Deprecated. Use lpOptimize or mipOptimize- See Also:
-
solve("")
-
solve
public void solve(java.lang.String alg)
Deprecated. Use lpOptimize or mipOptimizeCall Xpress-Optimizer solution algorithm. This method selects and starts the Xpress-Optimizer solution algorithm. The characters indicating the algorithm choice may be combined where it makes sense, e.g. "dg". If the matrix loaded in Xpress-Optimizer does not correspond to the current problem definition it is regenerated automatically prior to the start of the algorithm. The sense of the optimization (default: minimization) can be changed with methodsetSense(int)
. Before solving a problem, the objective function must be selected withsetObj(com.dashoptimization.XPRBctr)
. Note that if you use an incomplete global search you should finish your program with a call to the Xpress-Optimizer method XPRSinitglobal (see Xpress-Optimizer manual for details) in order to remove all search tree information that has been stored. Otherwise you may not be able to re-run your program.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.solve("pg");
- Parameters:
-
alg
- choice of the solution algorithm. Possible values:"p"
use primal simplex algorithm"d"
use dual simplex algorithm"b"
use Newton-Barrier algorithm"l"
only solve the (relaxed) linear problem"n"
use the network solver (LP only)"g"
solve the global (MIP) problem""
no parameter: use the default setting (LP only)
- See Also:
-
lpOptimize(String alg)
,mipOptimize(String alg)
,setSense(int dir)
-
minim
public void minim()
Deprecated. Use lpOptimize or mipOptimize- See Also:
-
minim("")
-
minim
public void minim(java.lang.String alg)
Deprecated. Use lpOptimize or mipOptimizeMinimize a problem. This method selects and starts the Xpress-Optimizer solution algorithm. The characters indicating the algorithm choice may be combined where it makes sense, e.g. "dg". If the matrix loaded in Xpress-Optimizer does not correspond to the current problem definition it is regenerated automatically prior to the start of the algorithm. Before solving a problem, the objective function must be selected withsetObj(com.dashoptimization.XPRBctr)
. Note that if you use an incomplete global search you should finish your program with a call to the Xpress-Optimizer method XPRSinitglobal (see Xpress-Optimizer manual for details) in order to remove all search tree information that has been stored. Otherwise you may not be able to re-run your program.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.minim("b");
- Parameters:
-
alg
- choice of the solution algorithm. Possible values:"p"
use primal simplex algorithm"d"
use dual simplex algorithm"b"
use Newton-Barrier algorithm"l"
only solve the (relaxed) linear problem"n"
use the network solver (LP only)"g"
solve the global (MIP) problem""
no parameter: use the default setting (LP only)
- See Also:
-
lpOptimize(String alg)
,mipOptimize(String alg)
,setSense(int dir)
-
maxim
public void maxim()
Deprecated. Use setSense(XPRB.MAXIM) and lpOptimize or mipOptimize- See Also:
-
maxim("")
-
maxim
public void maxim(java.lang.String alg)
Deprecated. Use setSense(XPRB.MAXIM) and lpOptimize or mipOptimizeMaximize a problem. This method selects and starts the Xpress-Optimizer solution algorithm. The characters indicating the algorithm choice may be combined where it makes sense, e.g. "dg". If the matrix loaded in Xpress-Optimizer does not correspond to the current problem definition it is regenerated automatically prior to the start of the algorithm. Before solving a problem, the objective function must be selected withsetObj(com.dashoptimization.XPRBctr)
. Note that if you use an incomplete global search you should finish your program with a call to the Xpress-Optimizer method XPRSinitglobal (see Xpress-Optimizer manual for details) in order to remove all search tree information that has been stored. Otherwise you may not be able to re-run your program.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.maxim("b");
- Parameters:
-
alg
- choice of the solution algorithm. Possible values:"p"
use primal simplex algorithm"d"
use dual simplex algorithm"b"
use Newton-Barrier algorithm"l"
only solve the (relaxed) linear problem"n"
use the network solver (LP only)"g"
solve the global (MIP) problem""
no parameter: use the default setting (LP only)
- See Also:
-
lpOptimize(String alg)
,mipOptimize(String alg)
,setSense(int dir)
-
getProbStat
public int getProbStat()
Get the problem status. Note that the BCL problem status uses a bit-encoding contrary to the LP and MIP status values, because several of the states may apply at the same time.XPRBprob expl2; int status; expl2 = new XPRBprob("example2"); status = expl2.getProbStat(); if((status&XPRB.MOD)==XPRB.MOD) expl2.lpOptimize();
- Returns:
-
Bit-encoded BCL status information. Possible values:
XPRB.GEN
matrix has been generatedXPRB.DIR
directives addedXPRB.MOD
problem has been modifiedXPRB.SOL
problem has been solved
-
getLPStat
public int getLPStat()
Get the LP status.XPRBprob expl2; int status; expl2 = new XPRBprob("example2"); expl2.lpOptimize(); status = expl2.getLPStat();
- Returns:
-
LP-status information. Possible values:
0
problem has not been loadedXPRB.LP_OPTIMAL
LP optimalXPRB.LP_INFEAS
LP infeasibleXPRB.LP_CUTOFF
objective value worse than cutoffXPRB.LP_UNFINISHED
LP unfinishedXPRB.LP_UNBOUNDED
LP unboundedXPRB.LP_CUTOFF_IN_DUAL
LP cutoff in dualXPRB.LP_UNSOLVED
LP problem not solvedXPRB.LP_NONCONVEX
QP problem is nonconvex
-
getMIPStat
public int getMIPStat()
Get the MIP (global) status.XPRBprob expl2; int status; expl2 = new XPRBprob("example2"); expl2.mipOptimize(); status = expl2.getMIPStat();
- Returns:
-
Global (MIP) status information. Possible values:
XPRB.MIP_NOT_LOADED
problem has not been loadedXPRB.MIP_LP_NOT_OPTIMAL
LP has not been optimizedXPRB.MIP_LP_OPTIMAL
LP has been optimizedXPRB.MIP_NO_SOL_FOUND
global search incomplete, no integer solution foundXPRB.MIP_SOLUTION
global search incomplete, an integer solution has been foundXPRB.MIP_INFEAS
global search complete, no integer solution foundXPRB.MIP_OPTIMAL
global search complete, an integer solution has been foundXPRB.MIP_UNBOUNDED
LP unbounded
-
sync
public void sync(int synctype)
Synchronize BCL with the Optimizer. This method resets the BCL problem status.XPRB.XPRS_SOL
: at the next solution access the solution information in BCL is updated with the solution held in the Optimizer (after MIP search: best integer solution, otherwise solution of the last LP solved).XPRB.XPRS_PROB
: at the next call to optimization orloadMat()
the problem is completely reloaded into the Optimizer; bound changes are not passed on to the problem loaded in the Optimizer any longer.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.sync(XPRB.XPRS_PROB);
- Parameters:
-
synctype
- type of synchronization. Possible values:XPRB.XPRS_SOL
update the BCL solution information with the LP solution currently held in the OptimizerXPRB.XPRS_SOLMIP
update the BCL solution information with the MIP solution currently held in the OptimizerXPRB.XPRS_PROB
force problem reloading
-
beginCB
public void beginCB(com.dashoptimization.XPRSprob optprob)
Start working with BCL within an Optimizer callback. This method precedes any call to BCL functionality within an Optimizer callback. It updates the BCL problem information for working with the local Optimizer subproblem and resets the BCL problem status. This method blocks access to the BCL problem until it is released by a matching call toendCB()
.XPRBprob expl2; expl2 = new XPRBprob("example2"); ... expl2.beginCB(mylocaloptprob); expl2.sync(XPRB.XPRS_PROB); expl2.endCB();
- Parameters:
-
optprob
- Xpress-Optimizer problem
-
endCB
public void endCB()
Terminate working with BCL within an Optimizer callback. This method sets the BCL problem information back to working with the main Optimizer problem, this includes resetting the BCL problem status. There must be a matching call tobeginCB(com.dashoptimization.XPRSprob)
.XPRBprob expl2; ... expl2.beginCB(mylocaloptprob); expl2.sync(XPRB.XPRS_PROB); expl2.endCB();
-
loadMIPSol
public int loadMIPSol(double[] sol, boolean ifopt)
Load an integer solution into BCL or the Optimizer. This method loads a MIP solution from an external source (e.g., the Xpress MIP Solution Pool) into BCL or the Optimizer. The solution is given in the form of an array, indexed by the column numbers of the decision variables. The size of the array must correspond to the number of columns in the matrix (generated by a call toloadMat()
or by starting an optimization run from BCL). If the solution is loaded into BCL the values are accepted as is, if the solution is loaded into the Optimizer (ifopt = true), the Optimizer will check whether the solution is acceptable and recalculates the values for the continuous variables in the solution. In the latter case the solution is loaded into BCL only once it has been successfully loaded and validated by the Optimizer.XPRBprob expl2; double[] vals = {1.5, 1, 0, 4, 2.2}; // Assuming we have 5 variables expl2 = new XPRBprob("example2"); if(expl2.loadMIPSol(vals)!=0) System.out.println("Loading MIP solution failed");
- Parameters:
-
sol
- Array holding the solution values. -
ifopt
- Whether to load the solution into the Optimizer:false
load into BCL onlytrue
load solution into the Optimizer.
- Returns:
-
Solution status. Possible values:
0
problem has not been loaded1
solution accepted,2
solution rejected because it is infeasible,3
solution rejected because the LP reoptimization was interrupted,-1
solution rejected because an error occurred,-2
the given solution array does not have the expected size,-3
error loading solution into BCL.
-
loadMIPSol
public int loadMIPSol(double[] sol)
- See Also:
-
loadMIPSol(sol, false)
-
addMIPSol
public void addMIPSol(XPRBsol sol, java.lang.String name)
Add a MIP solution into the Optimizer. This method adds a MIP solution from an external source into the Optimizer. The solution is given in the form of an XPRBsol object and can be feasible, infeasible or partial. The function returns immediately after passing the solution to the Optimizer. The solution is placed in a pool until the Optimizer is able to analyze the solution during a MIP solve. If the provided solution is found to be infeasible, a limited local search heuristic will be run in an attempt to find a close feasible integer solution. If a partial solution is provided, global columns will be fixed to any provided values and a limited local search will be run in an attempt to find integer feasible values for the remaining unspecified columns. Values provided for continuous column in partial solutions are currently ignored.XPRBprob expl2; x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); sol1 = expl2.newSol(); sol1.addVar(x1, 1.0); expl2.addMIPSol(sol1, "mysol");
- Parameters:
-
sol
- Solution object holding the solution values. -
name
- An optional name to associate with the solution (can be null).
-
addMIPSol
public void addMIPSol(XPRBsol sol)
- See Also:
-
addMIPSol(sol, null)
-
getObjVal
public double getObjVal()
Get the objective function value.XPRBprob expl2; double objval; expl2 = new XPRBprob("example2"); expl2.lpOptimize(); objval = expl2.getObjVal();
- Returns:
- Current objective function value (default 0)
-
getNumIIS
public int getNumIIS()
Get the number of independent IIS. The methods returns the number of independent irreducible infasible sets found by Xpress-Optimizer for an infeasible LP problem. The contents (variables and constraints) of each IIS can be retrieved with the methodgetIIS(java.util.ArrayList, java.util.ArrayList)
.XPRBprob expl2; int num; expl2 = new XPRBprob("example2"); expl2.lpOptimize(""); if(expl2.getLPStat()==XPRB.LP_INFEAS) num = expl2.getNumIIS();
- Returns:
- Number of independent IIS
-
getIIS
public void getIIS(java.util.ArrayList arrvar, java.util.ArrayList arrctr)
- See Also:
-
getIIS(arrvar, arrctr, null, 1)
-
getIIS
public void getIIS(java.util.ArrayList arrvar, java.util.ArrayList arrctr, java.util.ArrayList arrsos)
- See Also:
-
getIIS(arrvar, arrctr, arrsos, 1)
-
getIIS
public void getIIS(java.util.ArrayList arrvar, java.util.ArrayList arrctr, int num)
- See Also:
-
getIIS(arrvar, arrctr, null, num)
-
getIIS
public void getIIS(java.util.ArrayList arrvar, java.util.ArrayList arrctr, java.util.ArrayList arrsos, int num)
Get IIS variables, constraints, and SOS. This method returns the variables and/or constraints forming an IIS (irreducible infeasible set) in an infeasible LP or MIP problem. The number of independent IIS identified by Xpress-Optimizer can be obtained with methodgetNumIIS()
. The class ArrayList is defined in java.util.XPRBprob expl2; ArrayList iisvar; int i; expl2 = new XPRBprob("example2"); expl2.lpOptimize(); if(expl2.getLPStat()==XPRB.LP_INFEAS) { iisvar = new ArrayList(); expl2.getIIS(iisvar, null, null, 1); for(i=0;i<iisvar.size();i++) System.out.println(((XPRBvar)iisvar.get(i)).getName()); }
- Parameters:
-
arrvar
- list of variables (may be null) -
arrctr
- list of constraints (may be null) -
arrsos
- list of SOS (may be null) -
num
- sequence number of the IIS (default: 1)
-
getVarByName
public XPRBvar getVarByName(java.lang.String name)
Retrieve a variable by its name. This method cannot be used if the names dictionary has been disabled. Note that the same name may be used for objects of different types within one problem definition.XPRBprob expl2; XPRBvar x1; expl2 = new XPRBprob("example2"); expl2.newVar("abc3", XPRB.UI, 1, 100); x1 = expl2.getVarByName("abc3");
- Parameters:
-
name
- name of the variable - Returns:
-
A variable of type
XPRBvar
(check its validity withXPRBvar.isValid()
)
-
getCtrByName
public XPRBctr getCtrByName(java.lang.String name)
Retrieve a constraint by its name. This method cannot be used if the names dictionary has been disabled. Note that the same name may be used for objects of different types within one problem definition.XPRBprob expl2; XPRBctr ctr1; expl2 = new XPRBprob("example2"); expl2.newCtr("r1"); ctr1 = expl2.getCtrByName("r1");
- Parameters:
-
name
- name of the constraint - Returns:
-
A constraint of type
XPRBctr
(check its validity withXPRBctr.isValid()
)
-
getCtrs
public java.lang.Iterable<XPRBctr> getCtrs()
Returns an iterable (anonymous) object over the constraints in this problem.XPRBprob expl2; XPRBctr ctr1; expl2 = new XPRBprob("example2"); expl2.newCtr("r1"); for (XPRBctr c : expl2.getCtrs()) { c.print(); }
- Returns:
-
An iterable of type
Iterable<XPRBctr>
-
getSosByName
public XPRBsos getSosByName(java.lang.String name)
Retrieve a SOS by its name. This method cannot be used if the names dictionary has been disabled. Note that the same name may be used for objects of different types within one problem definition.XPRBprob expl2; XPRBsos set; expl2 = new XPRBprob("example2"); expl2.newSos("sos1", XPRB.S1); set = expl2.getSosByName("sos1");
- Parameters:
-
name
- name of the SOS - Returns:
-
A SOS of type
XPRBsos
(check its validity withXPRBsos.isValid()
)
-
getIndexSetByName
public XPRBindexSet getIndexSetByName(java.lang.String name)
Retrieve an index set by its name. This method cannot be used if the names dictionary has been disabled. Note that the same name may be used for objects of different types within one problem definition.XPRBprob expl2; XPRBindexSet iset; expl2 = new XPRBprob("example2"); expl2.newIndexSet("Set",100); iset = expl2.getIndexSetByName("Set");
- Parameters:
-
name
- name of the index set - Returns:
-
An index set of type
XPRBindexSet
(check its validity withXPRBindexSet.isValid()
)
-
setDictionarySize
public void setDictionarySize(int dico, int size)
Set the size of a dictionary. This method sets the size of the names or indices dictionaries. It can only be called immediately after the creation of a problem.
The names dictionary serves for storing and accessing the names of all modeling objects (variables, arrays of variables, constraints, SOS, index sets). Once the names dictionary has been disabled it cannot be enabled any more. All methods relative to the names cannot be used if this dictionary has been disabled and BCL will not generate any unique names at the creation of model objects. If this dictionary is enabled (default setting) BCL automatically resizes this dictionary to a suitable size for your problem. If nevertheless you wish to set the size by yourself we recommend to choose a size close to the number of variables+constraints in your problem.
The indices dictionary serves for storing all index set elements. The indices dictionary cannot be disabled, it is created automatically once an index set element is defined.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.setDictionarySize(XPRB.DICT_NAMES, 0); expl2.setDictionarySize(XPRB.DICT_IDX, 2999);
- Parameters:
-
dico
- name of the index set. Possible values:XPRB.DICT_NAMES
names dictionaryXPRB.DICT_IDX
index set dictionary
-
size
- size of the dictionary, 0 disables the dictionary (names only)
-
toString
public java.lang.String toString()
- Overrides:
-
toString
in classjava.lang.Object
- See Also:
-
getName()
-
print
public void print()
Print out a problem. This method prints out the complete problem definition currently held in BCL, that means, the list of constraints, any Special Ordered Sets that have been defined, and the objective function. This method is not available in the Student Edition.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.print();
-
getXPRSintAttrib
public int getXPRSintAttrib(int c)
Deprecated. Use getXPRSprob in conjunction with getIntAttribGet an integer problem attribute from the optimizer. This method returns the current value of an integer-valued problem attribute of Xpress-Optimizer. Refer to the Optimizer Reference Manual for a list of all problem attributes. It may be necessary to load the BCL problem explicitly (methodloadMat()
) into Xpress-Optimizer before this method is used.XPRBprob expl2; int val; expl2 = new XPRBprob("example2"); expl2.loadMat(); val = expl2.getXPRSintAttrib(XPRB.XPRS_MIPSOLS);
- Parameters:
-
c
- name of the control parameter - Returns:
- Current value of the problem attribute
- See Also:
-
getXPRSprob()
,XPRSprob.getIntAttrib(int)
-
getXPRSdblAttrib
public double getXPRSdblAttrib(int c)
Deprecated. Use getXPRSprob in conjunction with getDblAttribGet a double problem attribute from the optimizer. This method returns the current value of a double-valued problem attribute of Xpress-Optimizer. Refer to the Optimizer Reference Manual for a list of all problem attributes. It may be necessary to load the BCL problem explicitly (methodloadMat()
) into Xpress-Optimizer before this method is used.XPRBprob expl2; double val; expl2 = new XPRBprob("example2"); val = expl2.getXPRSdblAttrib(XPRB.XPRS_LPOBJVAL);
- Parameters:
-
c
- name of the control parameter - Returns:
- Current value of the problem attribute
- See Also:
-
getXPRSprob()
,XPRSprob.getDblAttrib(int)
-
getXPRSintControl
public int getXPRSintControl(int c)
Deprecated. Use getXPRSprob in conjunction with getIntControlGet an integer control parameter from the optimizer. This method returns the current value of an integer-valued control parameter of Xpress-Optimizer. Refer to the Optimizer Reference Manual for a list of all control parameters.XPRBprob expl2; int val; expl2 = new XPRBprob("example2"); val = expl2.getXPRSintControl(XPRB.XPRS_PRESOLVE);
- Parameters:
-
c
- name of the control parameter - Returns:
- Current value of the control parameter
- See Also:
-
getXPRSprob()
,XPRSprob.getIntControl(int)
-
getXPRSdblControl
public double getXPRSdblControl(int c)
Deprecated. Use getXPRSprob in conjunction with getDblControlGet a double control parameter from the optimizer. This method returns the current value of a double-valued control parameter of Xpress-Optimizer. Refer to the Optimizer Reference Manual for a list of all control parameters.XPRBprob expl2; double val; expl2 = new XPRBprob("example2"); val = expl2.getXPRSdblControl(XPRB.XPRS_MIPTOL);
- Parameters:
-
c
- name of the control parameter - Returns:
- Current value of the control parameter
- See Also:
-
getXPRSprob()
,XPRSprob.getDblControl(int)
-
setXPRSintControl
public void setXPRSintControl(int c, int val)
Deprecated. Use getXPRSprob in conjunction with setIntControlSet an integer control parameter for the optimizer. This method sets a new value for an integer-valued control parameter of Xpress-Optimizer. Refer to the Optimizer Reference Manual for a list of all control parameters.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.setXPRSintControl(XPRB.XPRS_MAXMIPSOL,1);
- Parameters:
-
c
- name of the control parameter -
val
- new value for the control parameter - See Also:
-
getXPRSprob()
,XPRSprob.setIntControl(int,int)
-
setXPRSdblControl
public void setXPRSdblControl(int c, double val)
Deprecated. Use getXPRSprob in conjunction with setDblControlSet a double control parameter for the optimizer. This method sets a new value for a double-valued control parameter of Xpress-Optimizer. Refer to the Optimizer Reference Manual for a list of all control parameters.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.setXPRSdblControl(XPRB.XPRS_MIPADDCUTOFF,0.99);
- Parameters:
-
c
- name of the control parameter -
val
- new value for the control parameter - See Also:
-
getXPRSprob()
,XPRSprob.setDblControl(int,double)
-
getXPRSprob
public com.dashoptimization.XPRSprob getXPRSprob()
Retrieve the associated XPRSprob object. This method returns anXPRSprob
object to be used with specific Xpress-Optimizer operations. The Xpress-Optimizer Java needs to be initialized withXPRS.init()
before the Optimizer problem is accessed.
-
setCutMode
public void setCutMode(int mode)
Parameter settings for cuts. This methods sets certain Xpress-Optimizer control parameters to enable the addition of cuts defined in BCL during the MIP search.XPRBprob expl2; expl2 = new XPRBprob("example2"); expl2.setCutMode(1);
- Parameters:
-
mode
- choice of parameter settings. Possible values:0
standard settings1
parameter settings required for cuts
-
newCut
public XPRBcut newCut(XPRBrelation lr, int id)
Create a new cut. This method has to be called beforeXPRBcut.addTerm(com.dashoptimization.XPRBvar, double)
orXPRBcut.setTerm(com.dashoptimization.XPRBvar, double)
are used to add terms to the cut. Cuts are linear inequalities or equations. If no type is specified the type XPRB.E is assumed, it can be changed with methodXPRBcut.setType(int)
.XPRBprob expl2; XPRBvar x2; XPRBcut cut; expl2 = new XPRBprob("example2"); x2 = expl2.newVar("x2"); cut = expl2.newCtr(x2.gEql(3), 1);
- Parameters:
-
lr
- linear relation (default 0-valued equality relation) -
id
- identification number for cut classification (default 0) - Returns:
-
A new cut of type
XPRBcut
-
newCut
public XPRBcut newCut()
- See Also:
-
newCut(0, 0)
-
newCut
public XPRBcut newCut(int id)
- See Also:
-
newCut(0, id)
-
newCut
public XPRBcut newCut(XPRBrelation lr)
- See Also:
-
newCut(lr, 0)
-
newCut
public XPRBcut newCut(XPRBexpr l)
- See Also:
-
newCut(l, 0)
-
newCut
public XPRBcut newCut(XPRBexpr l, int id)
- See Also:
-
newCut(l, id)
-
addCuts
public void addCuts(XPRBcut[] ca)
Add an array of cuts to the Optimizer problem. This method adds an array of previously defined cuts to the problem currently held in Xpress-Optimizer. Typically, this method will be called from the cut manager callback of the Optimizer (XPRScutMgrListener
). Cuts are not stored in the BCL problem.static class CutMgrCallback implements XPRScutMgrListener { public int XPRScutMgrEvent(XPRSprob oprob, Object data) { XPRBcur[] cut; XPRBprob pb; pb = (XPRBprob)data; ... // Definition of cuts in array "cut" pb.addCuts(cut); } } ... XPRBprob expl2; CutMgrCallback cb; expl2 = new XPRBprob("example2"); cb = new CutMgrCallback(); oprob.addCutMgrListener(cb, expl2);
- Parameters:
-
ca
- array of previously defined cuts (typeXPRBcut
)
-
writeSol
public void writeSol()
- See Also:
-
writeSol("", "")
-
writeSol
public void writeSol(java.lang.String fname)
- See Also:
-
writeSol(fname, "")
-
writeSol
public void writeSol(java.lang.String fname, java.lang.String flags) throws java.io.IOException
Write solution to a CSV file. This method writes the current Optimizer solution to a CSV format ASCII file (.asc and .hdr). Please refer to the documentation of XPRSwritesol in the Xpress Optimizer Reference Manual for a description of the various flags.XPRBprob expl2; expl2 = new XPRBprob("example2"); ... expl2.writeSol("myprob", "nar");
- Parameters:
-
fname
- name of the output file without extension - Throws:
-
java.io.IOException
-
writeBinSol
public void writeBinSol()
- See Also:
-
writeBinSol("", "")
-
writeBinSol
public void writeBinSol(java.lang.String fname)
- See Also:
-
writeBinSol(fname, "")
-
writeBinSol
public void writeBinSol(java.lang.String fname, java.lang.String flags) throws java.io.IOException
Write solution to a binary file. Writes the current MIP or LP Optimizer solution to a binary solution file (.sol) for later input into the Optimizer. Please refer to the documentation of XPRSwritebinsol in the Xpress Optimizer Reference Manual for a description of the various flags.XPRBprob expl2; expl2 = new XPRBprob("example2"); ... expl2.writeBinSol("myprob", "x");
- Parameters:
-
fname
- name of the output file without extension - Throws:
-
java.io.IOException
-
writePrtSol
public void writePrtSol()
- See Also:
-
writePrtSol("", "")
-
writePrtSol
public void writePrtSol(java.lang.String fname)
- See Also:
-
writePrtSol(fname, "")
-
writePrtSol
public void writePrtSol(java.lang.String fname, java.lang.String flags) throws java.io.IOException
Write solution to a fixed format ASCII file. Writes the current Optimizer solution to a fixed format ASCII file(.prt). Please refer to the documentation of XPRSwriteprtsol in the Xpress Optimizer Reference Manual for a description of the various flags.XPRBprob expl2; expl2 = new XPRBprob("example2"); ... expl2.writePrtSol("myprob", "x");
- Parameters:
-
fname
- name of the output file without extension - Throws:
-
java.io.IOException
-
writeSlxSol
public void writeSlxSol()
- See Also:
-
writeSlxSol("", "")
-
writeSlxSol
public void writeSlxSol(java.lang.String fname)
- See Also:
-
writeSlxSol(fname, "")
-
writeSlxSol
public void writeSlxSol(java.lang.String fname, java.lang.String flags) throws java.io.IOException
Write solution to an ASCII file. Writes the current Optimizer solution to an ASCII solution file (.slx) using a similar format to MPS files. Please refer to the documentation of XPRSwriteslxsol in the Xpress Optimizer Reference Manual for a description of the various flags.XPRBprob expl2; expl2 = new XPRBprob("example2"); ... expl2.writeSlxSol("myprob", "pm");
- Parameters:
-
fname
- name of the output file without extension - Throws:
-
java.io.IOException
-
readBinSol
public void readBinSol()
- See Also:
-
readBinSol("", "")
-
readBinSol
public void readBinSol(java.lang.String fname)
- See Also:
-
readBinSol(fname, "")
-
readBinSol
public void readBinSol(java.lang.String fname, java.lang.String flags) throws java.io.IOException
Read solution from a binary file. Reads a binary solution file (.bin) created by the writeBinSol method, loading it into the Optimizer. Please refer to the documentation of XPRSreadbinsol in the Xpress Optimizer Reference Manual for a description of the various flags.XPRBprob expl2; expl2 = new XPRBprob("example2"); ... expl2.readBinSol("myprob", "m");
- Parameters:
-
fname
- name of the output file without extension - Throws:
-
java.io.IOException
-
readSlxSol
public void readSlxSol()
- See Also:
-
readSlxSol("", "")
-
readSlxSol
public void readSlxSol(java.lang.String fname)
- See Also:
-
readSlxSol(fname, "")
-
readSlxSol
public void readSlxSol(java.lang.String fname, java.lang.String flags) throws java.io.IOException
Read solution from an ASCII file. Reads an ASCII solution file (.slx) created by the writeSlxSol method, loading it into the Optimizer. Please refer to the documentation of XPRSreadslxsol in the Xpress Optimizer Reference Manual for a description of the various flags.XPRBprob expl2; expl2 = new XPRBprob("example2"); ... expl2.readSlxSol("myprob", "m");
- Parameters:
-
fname
- name of the output file without extension - Throws:
-
java.io.IOException
-
finalize
public void finalize()
Finalize the problem. This method is called automatically by the system. If this method is called explicitly from the user's program to force the finalization of a BCL problem (as required byXPRB.finalize()
) the program must not access any objects of the problem after this call.XPRB bcl=new XPRB(); // Initialize BCL XPRBprob expl2; expl2 = new XPRBprob("example2"); // Create a problem ... prob.finalize(); // Finalize the problem prob=null; bcl.finalize(); // Finalize BCL (release license) bcl=null;
- Overrides:
-
finalize
in classjava.lang.Object
-
-
© 2001-2019 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.