public class XPRBprob
extends java.lang.Object
implements java.lang.AutoCloseable
| Constructor and Description |
|---|
XPRBprob(java.lang.String name)
Deprecated.
Since version 46.00, use the optimizer's Java API instead.
|
| 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 |
close()
Finalize the problem.
|
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()
Deprecated.
As of version 8.14, use
close(), or, even better,
use try-with-resources. |
void |
fixMIPEntities() |
void |
fixMIPEntities(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 getDblAttrib
|
double |
getXPRSdblControl(int c)
Deprecated.
Use getXPRSprob in conjunction with getDblControl
|
int |
getXPRSintAttrib(int c)
Deprecated.
Use getXPRSprob in conjunction with getIntAttrib
|
int |
getXPRSintControl(int c)
Deprecated.
Use getXPRSprob in conjunction with getIntControl
|
com.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()
Deprecated.
Since version 46.00, use the optimizer's Java API instead.
|
void |
lpOptimise(java.lang.String alg)
Deprecated.
Since version 46.00, use the optimizer's Java API instead.
|
void |
lpOptimize()
Deprecated.
Since version 46.00, use the optimizer's Java API instead.
|
void |
lpOptimize(java.lang.String alg)
Deprecated.
Since version 46.00, use the optimizer's Java API instead.
|
void |
maxim()
Deprecated.
Use setSense(XPRB.MAXIM) and lpOptimize or mipOptimize
|
void |
maxim(java.lang.String alg)
Deprecated.
Use setSense(XPRB.MAXIM) and lpOptimize or mipOptimize
|
void |
minim()
Deprecated.
Use lpOptimize or mipOptimize
|
void |
minim(java.lang.String alg)
Deprecated.
Use lpOptimize or mipOptimize
|
void |
mipOptimise()
Deprecated.
Since version 46.00, use the optimizer's Java API instead.
|
void |
mipOptimise(java.lang.String alg)
Deprecated.
Since version 46.00, use the optimizer's Java API instead.
|
void |
mipOptimize()
Deprecated.
Since version 46.00, use the optimizer's Java API instead.
|
void |
mipOptimize(java.lang.String alg)
Deprecated.
Since version 46.00, use the optimizer's Java API instead.
|
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.
|
boolean |
setExplicitGarbageCollect(boolean value) |
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 setDblControl
|
void |
setXPRSintControl(int c,
int val)
Deprecated.
Use getXPRSprob in conjunction with setIntControl
|
void |
solve()
Deprecated.
Use lpOptimize or mipOptimize
|
void |
solve(java.lang.String alg)
Deprecated.
Use lpOptimize or mipOptimize
|
void |
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.
|
@Deprecated public XPRBprob(java.lang.String name)
XPRB.newProb(String) but does not
need an XPRB instance. It will implicitly create the required
XPRB instance and release that instance when the
close() function is called.
With this function you can easily create new problems and manage the
related native resources like so:
try (XPRBprob prob = new XPRBprob("problem")) {
... // Use the problem here
} // Resources will be automatically cleaned up here.
public boolean isValid()
XPRBprob expl2;
if(expl2.isValid() == false)
System.out.println("Error in problem definition.");
public void reset()
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.mipOptimize();
expl2.reset();
}
public void setMsgLevel(int level)
XPRBerror.getMessage() and
XPRBerror.getErrorCode() respectively.
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.setMsgLevel(0);
}
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 public void setOutputStream(java.lang.Object stream)
prob.setOutputStream(System.err);
stream - an object implementing either a 'write' or 'print' methodpublic void setOutputStream()
setOutputStream(System.err)public void setRealFmt(java.lang.String fmt)
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.setRealFmt("%.10f");
}
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 numpublic void setColOrder(int num)
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.setColOrder(1);
}
num - ordering criterion. Possible values:
0 default order1 alphabetical order public XPRBvar newVar(java.lang.String name, int type, double lob, double upb)
VAR.
(The generation of unique names will only take place if the names
dictionary is enabled, see setDictionarySize(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 and bdl. This value can be
subsequently modified with the method XPRBvar.setLim(double).
try (XPRBprob expl2 = new XPRBprob("example2")) {
XPRBvar x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
XPRBvar x2 = expl2.newVar("efg2", XPRB.SC, 0, 20); // x2=0 or 1<=x2<=20
}
type - variable type. Possible values:
XPRB.PL continuous (default)XPRB.BV binary XPRB.UI general integerXPRB.PI partial integer XPRB.SC semi-continuousXPRB.SI semi-continuous integername - variable name, may be
nulllob - lower bound, may be -XPRB.INFINITY for minus infinity
(default 0)upb - upper bound, may be XPRB.INFINITY for plus infinity
(default XPRB.INFINITY)XPRBvarpublic XPRBvar newVar(java.lang.String name, int type)
newVar(name, type, 0, XPRB.INFINITY)public XPRBvar newVar(java.lang.String name, double lob, double upb)
newVar(name, XPRB.PL, lob, upb)public XPRBvar newVar(java.lang.String name)
newVar(name, XPRB.PL, 0, XPRB.INFINITY)public XPRBvar newVar(int type)
newVar(null, type, 0, XPRB.INFINITY)public XPRBvar newVar(int type, double lob, double upb)
newVar(null, type, lob, upb)public XPRBvar newVar(double lob, double upb)
newVar(null, XPRB.PL, lob, upb)public XPRBvar newVar()
newVar("", XPRB.PL, 0, XPRB.INFINITY)public XPRBctr newCtr(java.lang.String name, XPRBrelation lr)
XPRBctr.addTerm(com.dashoptimization.XPRBvar, double) or
XPRBctr.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 function XPRBctr.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 with CTR .
(The generation of unique names will only take place if the names
dictionary is enabled, see setDictionarySize(int, int)).
try (XPRBprob expl2 = new XPRBprob("example2")) {
XPRBvar x2 = expl2.newVar("x2");
XPRBctr ctr1 = expl2.newCtr("r1", x2.gEql(3));
}
name - constraint name, may be
null (default)lr - linear relation (default 0-valued, non-binding relation)XPRBctrpublic XPRBctr newCtr(java.lang.String name)
newCtr(name, 0)public XPRBctr newCtr()
newCtr(null, 0)public XPRBctr newCtr(XPRBrelation lr)
newCtr(null, lr)public XPRBctr newCtr(XPRBexpr l)
newCtr(null, l)public XPRBctr newCtr(java.lang.String name, XPRBexpr l)
newCtr(name, l)public void delCtr(XPRBctr ctr)
setObj(com.dashoptimization.XPRBctr)), the objective will
be set to null.
If the constraint occurs in a previously saved basis that is to be
(re)loaded later on you should change its type to XPRB.N
using XPRBctr.setType(int) instead of entirely deleting the
constraint.
try (XPRBprob expl2 = new XPRBprob("example2")) {
XPRBvar x2 = expl2.newVar("x2");
XPRBctr ctr1 = expl2.newCtr("r1", x2.gEql(3));
expl2.delCtr(ctr1);
}
ctr - constraint of type XPRBctrpublic void setObj(XPRBctr ctr)
XPRB.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.
try (XPRBprob expl2 = new XPRBprob("example2")) {
XPRBvar[] x = new XPRBvar[5];
for (int i=0;i<5;i++) x[i] = expl2.newVar("x");
XPRBctr ctr3 = expl2.newCtr("r3", x[0].add(x[1]).lEql(10));
expl2.setObj(ctr3);
}
ctr - constraint of type XPRBctrpublic void setObj(XPRBexpr q)
try (XPRBprob expl2 = new XPRBprob("example2")) {
XPRBvar[] x = new XPRBvar[5];
for(int i=0;i<5;i++) x[i] = expl2.newVar("x");
XPRBexpr qe = new XPRBexpr();
qe.add(x[2].mul(x[3]));
expl2.setObj(qe);
}
q - expression of type XPRBexprpublic XPRBsol newSol()
try (XPRBprob expl2 = new XPRBprob("example2")) {
XPRBvar x = expl2.newVar("x");
XPRBsol sol1 = expl2.newSol();
sol1.addVar(x, 1.0);
}
public XPRBsos newSos(int type)
newSos(null, type, 0)public XPRBsos newSos(java.lang.String name, int type)
newSos(name, type, 0)public XPRBsos newSos(int type, XPRBexpr le)
newSos(null, type, le)public XPRBsos newSos(java.lang.String name, int type, XPRBexpr le)
XPRBsos.addElement(com.dashoptimization.XPRBvar, double))
or deleted (method XPRBsos.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 with SOS.
(The generation of unique names will only take place if the names
dictionary is enabled, see setDictionarySize(int, int)).
try (XPRBprob expl2 = new XPRBprob("example2")) {
XPRBvar[] x = new XPRBvar[5];
for (int i=0;i<5;i++) x[i] = expl2.newVar("x");
XPRBexpr l = new XPRBexpr();
for (int i=1;i<4;i++) l.add(x[i].mul(i));
XPRBsos set1 = expl2.newSos("sos1", XPRB.S1, l);
}
name - name of the settype - set type. Possible values:
XPRB.S1 Special Ordered Set of
type 1XPRB.S2 Special Ordered Set of type 2le - linear expressionpublic void delSol(XPRBsol sol)
try (XPRBprob expl2 = new XPRBprob("example2")) {
XPRBvar x = expl2.newVar("x");
XPRBsol sol1 = expl2.newSol();
sol1.addVar(x, 1.0);
expl2.delSol(sol1);
}
sol - previously created solutionpublic void delSos(XPRBsos sos)
try (XPRBprob expl2 = new XPRBprob("example2")) {
XPRBvar[] x = new XPRBvar[5];
for (int i=0;i<5;i++) x[i] = expl2.newVar("x");
XPRBexpr l = new XPRBexpr();
for(int i=1;i<4;i++) l.add(x[i].mul(i));
XPRBsos set1 = expl2.newSos("sos1", XPRB.S1, l);
expl2.delSos(set1);
}
sos - previously created SOS of type 1 or 2public XPRBindexSet newIndexSet()
newIndexSet(null, 0)public XPRBindexSet newIndexSet(java.lang.String name)
newIndexSet(name, 0)public XPRBindexSet newIndexSet(int maxsize)
newIndexSet(null, maxsize)public XPRBindexSet newIndexSet(java.lang.String name, int maxsize)
maxsize 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 with IDX.
(The generation of unique names will only take place if the names
dictionary is enabled, see setDictionarySize(int, int)).
try (XPRBprob expl2 = new XPRBprob("example2")) {
XPRBindexSet iset = expl2.newIndexSet("Set",100);
}
name - name of the index set to be created, may be nullmaxsize - maximum size of the index set (default 0)XPRBindexSetpublic XPRBbasis saveBasis()
XPRBbasis.
The basis may be re-input using method loadBasis(com.dashoptimization.XPRBbasis).
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.lpOptimize("");
XPRBbasis bs1 = expl2.saveBasis();
}
XPRBbasispublic void loadBasis(XPRBbasis bs)
saveBasis().
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 to XPRB.N using
XPRBctr.setType(int) if you wish to load the basis later on).
Note that the problem has to be loaded explicitly (method
loadMat()) before the basis is re-input with this method.
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.lpOptimize();
XPRBbasis bs1 = expl2.saveBasis();
XPRBvar x2 = expl2.newVar("x2");
XPRBctr ctr1 = expl2.newCtr("r1", x2.gEql(3));
expl2.loadMat();
expl2.loadBasis(bs1);
}
bs - basis of type XPRBbasispublic void clearDir()
XPRBvar.setDir(int, double)) or
on SOS (method XPRBsos#setPriority).
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.clearDir();
}
public void setSense(int dir)
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.setSense(XPRB.MAXIM);
}
dir - sense of the objective function. Possible values:
XPRB.MAXIM maximize the objectiveXPRB.MINIM minimize the objective (default)public int getSense()
setSense(int), minim(), and maxim().
try (XPRBprob expl2 = new XPRBprob("example2")) {
int dir = expl2.getSense();
}
XPRB.MAXIM maximize the objectiveXPRB.MINIM minimize the objective -1 in case of errorpublic java.lang.String getName()
try (XPRBprob expl2 = new XPRBprob("example2")) {
String pbname = expl2.getName();
System.out.println("Problem name: " + pbname);
}
null otherwisepublic void setName(java.lang.String name)
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.setName("example_two");
String pbname = expl2.getName();
System.out.println("Problem name: " + pbname);
}
public void exportProb(int format)
throws java.io.IOException
java.io.IOExceptionexportProb(format, null)public void exportProb(java.lang.String fname)
throws java.io.IOException
java.io.IOExceptionexportProb(XPRB.LP, fname)public void exportProb()
throws java.io.IOException
java.io.IOExceptionexportProb(XPRB.LP, null)public void exportProb(int format,
java.lang.String fname)
throws java.io.IOException
.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
with setRealFmt(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
to loadMat().
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.exportProb(XPRB.MPS, "ex2");
}
format - matrix output file format. Possible values:
XPRB.LP LP file formatXPRB.MPS MPS file formatfname - name of the output file without extensionjava.io.IOExceptionpublic void fixMIPEntities()
public void fixMIPEntities(boolean ifround)
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.mipOptimize();
expl2.fixMIPEntities();
expl2.lpOptimize();
}
ifround - if all global entities should be rounded to the nearest
discrete value in the solution before being fixed.public void writeDir()
throws java.io.IOException
java.io.IOExceptionwriteDir(null)public void writeDir(java.lang.String fname)
throws java.io.IOException
.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.
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.writeDir();
}
fname - name of the output file without extensionjava.io.IOExceptionpublic void loadMat()
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.loadMat();
}
@Deprecated public void lpOptimise()
lpOptimize("")@Deprecated public void lpOptimise(java.lang.String alg)
lpOptimize(alg)@Deprecated public void lpOptimize()
lpOptimize("")@Deprecated public void lpOptimize(java.lang.String alg)
setSense(int). Before solving a problem, the
objective function must be selected with setObj(com.dashoptimization.XPRBctr).
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.setSense(XPRB.MAXIM);
expl2.lpOptimize("b");
}
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 @Deprecated public void mipOptimise()
mipOptimize("")@Deprecated public void mipOptimise(java.lang.String alg)
mipOptimize(alg)@Deprecated public void mipOptimize()
mipOptimize("")@Deprecated public void mipOptimize(java.lang.String alg)
setSense(int). Before solving a problem, the
objective function must be selected with setObj(com.dashoptimization.XPRBctr).
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.setSense(XPRB.MINIM);
expl2.mipOptimize("p");
}
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@Deprecated public void solve()
solve("")@Deprecated public void solve(java.lang.String alg)
setSense(int). Before solving a problem, the
objective function must be selected with setObj(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.
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.solve("pg");
}
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)lpOptimize(String alg),
mipOptimize(String alg),
setSense(int dir)@Deprecated public void minim()
minim("")@Deprecated public void minim(java.lang.String alg)
setObj(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.
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.minim("b");
}
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)lpOptimize(String alg),
mipOptimize(String alg),
setSense(int dir)@Deprecated public void maxim()
maxim("")@Deprecated public void maxim(java.lang.String alg)
setObj(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.
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.maxim("b");
}
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)lpOptimize(String alg),
mipOptimize(String alg),
setSense(int dir)public int getProbStat()
try (XPRBprob expl2 = new XPRBprob("example2")) {
...
int status = expl2.getProbStat();
if((status&XPRB.MOD)==XPRB.MOD) expl2.lpOptimize();
}
XPRB.GEN matrix has been generatedXPRB.DIR directives addedXPRB.MOD problem has been modified XPRB.SOL problem has been solvedpublic int getLPStat()
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.lpOptimize();
int status = expl2.getLPStat();
}
0 problem has not been loadedXPRB.LP_OPTIMAL LP optimalXPRB.LP_INFEAS LP infeasible XPRB.LP_CUTOFF objective value worse than cutoff XPRB.LP_UNFINISHED LP unfinished XPRB.LP_UNBOUNDED LP unbounded XPRB.LP_CUTOFF_IN_DUAL LP cutoff in dualXPRB.LP_UNSOLVED LP problem not solvedXPRB.LP_NONCONVEX QP problem is nonconvexpublic int getMIPStat()
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.mipOptimize();
int status = expl2.getMIPStat();
}
XPRB.MIP_NOT_LOADED problem has not been loaded XPRB.MIP_LP_NOT_OPTIMAL LP has not been optimized XPRB.MIP_LP_OPTIMAL LP has been optimized XPRB.MIP_NO_SOL_FOUND global search incomplete, no integer
solution foundXPRB.MIP_SOLUTION global search incomplete, an integer solution
has been found XPRB.MIP_INFEAS global search complete, no integer solution
foundXPRB.MIP_OPTIMAL global search complete, an integer solution
has been foundXPRB.MIP_UNBOUNDED LP unbounded public void sync(int synctype)
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 or loadMat() the problem is completely
reloaded into the Optimizer; bound changes are not passed on to the
problem loaded in the Optimizer any longer.
try (XPRBprob expl2 = new XPRBprob("example2")) {
...
expl2.sync(XPRB.XPRS_PROB);
}
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 reloadingpublic void beginCB(com.dashoptimization.XPRSprob optprob)
endCB().
try (XPRBprob expl2 = new XPRBprob("example2")) {
...
expl2.beginCB(mylocaloptprob);
expl2.sync(XPRB.XPRS_PROB);
expl2.endCB();
}
optprob - Xpress-Optimizer problempublic void endCB()
beginCB(com.dashoptimization.XPRSprob).
try (XPRBprob expl2 = new XPRBprob("example2")) {
...
expl2.beginCB(mylocaloptprob);
expl2.sync(XPRB.XPRS_PROB);
expl2.endCB();
}
public int loadMIPSol(double[] sol,
boolean ifopt)
loadMat() 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.
try (XPRBprob expl2 = new XPRBprob("example2")) {
double[] vals = {1.5, 1, 0, 4, 2.2}; // Assuming we have 5 variables
if(expl2.loadMIPSol(vals)!=0)
System.out.println("Loading MIP solution failed");
}
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.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.public int loadMIPSol(double[] sol)
loadMIPSol(sol, false)public void addMIPSol(XPRBsol sol, java.lang.String name)
try (XPRBprob expl2 = new XPRBprob("example2")) {
XPRBvar x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
XPRBsol sol1 = expl2.newSol();
sol1.addVar(x1, 1.0);
expl2.addMIPSol(sol1, "mysol");
}
sol - Solution object holding the solution values.name - An optional name to associate with the solution (can be null).public void addMIPSol(XPRBsol sol)
addMIPSol(sol, null)public double getObjVal()
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.lpOptimize();
double objval = expl2.getObjVal();
}
public int getNumIIS()
getIIS(java.util.ArrayList, java.util.ArrayList).
try (XPRBprob expl2 = new XPRBprob("example2")) {
int num = 0;
expl2.lpOptimize("");
if(expl2.getLPStat()==XPRB.LP_INFEAS) num = expl2.getNumIIS();
}
public void getIIS(java.util.ArrayList arrvar,
java.util.ArrayList arrctr)
getIIS(arrvar, arrctr, null, 1)public void getIIS(java.util.ArrayList arrvar,
java.util.ArrayList arrctr,
java.util.ArrayList arrsos)
getIIS(arrvar, arrctr, arrsos, 1)public void getIIS(java.util.ArrayList arrvar,
java.util.ArrayList arrctr,
int num)
getIIS(arrvar, arrctr, null, num)public void getIIS(java.util.ArrayList arrvar,
java.util.ArrayList arrctr,
java.util.ArrayList arrsos,
int num)
getNumIIS().
The class ArrayList is defined in java.util.
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.lpOptimize();
if (expl2.getLPStat()==XPRB.LP_INFEAS) {
ArrayList iisvar = new ArrayList();
expl2.getIIS(iisvar, null, null, 1);
for (int i=0;i<iisvar.size();i++)
System.out.println(((XPRBvar)iisvar.get(i)).getName());
}
}
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)public XPRBvar getVarByName(java.lang.String name)
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.newVar("abc3", XPRB.UI, 1, 100);
XPRBvar x1 = expl2.getVarByName("abc3");
}
name - name of the variableXPRBvar
(check its validity with XPRBvar.isValid())public XPRBctr getCtrByName(java.lang.String name)
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.newCtr("r1");
XPRBctr ctr1 = expl2.getCtrByName("r1");
}
name - name of the constraintXPRBctr
(check its validity with XPRBctr.isValid())public java.lang.Iterable<XPRBctr> getCtrs()
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.newCtr("r1");
for (XPRBctr c : expl2.getCtrs()) {
c.print();
}
}
Iterable<XPRBctr>public XPRBsos getSosByName(java.lang.String name)
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.newSos("sos1", XPRB.S1);
XPRBsos set = expl2.getSosByName("sos1");
}
name - name of the SOSXPRBsos
(check its validity with XPRBsos.isValid())public XPRBindexSet getIndexSetByName(java.lang.String name)
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.newIndexSet("Set",100);
XPRBindexSet iset = expl2.getIndexSetByName("Set");
}
name - name of the index setXPRBindexSet
(check its validity with XPRBindexSet.isValid())public void setDictionarySize(int dico,
int size)
try (XPRBprob expl2 new XPRBprob("example2")) {
expl2.setDictionarySize(XPRB.DICT_NAMES, 0);
expl2.setDictionarySize(XPRB.DICT_IDX, 2999);
}
dico - name of the index set. Possible values:
XPRB.DICT_NAMES names dictionaryXPRB.DICT_IDX index set dictionarysize - size of the dictionary, 0 disables the dictionary (names only)public java.lang.String toString()
toString in class java.lang.ObjectgetName()public void print()
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.print();
}
@Deprecated public int getXPRSintAttrib(int c)
loadMat()) into Xpress-Optimizer before this method is used.
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.loadMat();
int val = expl2.getXPRSintAttrib(XPRB.XPRS_MIPSOLS);
}
c - name of the control parametergetXPRSprob(),
XPRSprob.getIntAttrib(int)@Deprecated public double getXPRSdblAttrib(int c)
loadMat()) into Xpress-Optimizer before this method is used.
try (XPRBprob expl2 = new XPRBprob("example2")) {
double val = expl2.getXPRSdblAttrib(XPRB.XPRS_LPOBJVAL);
}
c - name of the control parametergetXPRSprob(),
XPRSprob.getDblAttrib(int)@Deprecated public int getXPRSintControl(int c)
try (XPRBprob expl2 = new XPRBprob("example2")) {
int val = expl2.getXPRSintControl(XPRB.XPRS_PRESOLVE);
}
c - name of the control parametergetXPRSprob(),
XPRSprob.getIntControl(int)@Deprecated public double getXPRSdblControl(int c)
try (XPRBprob expl2 = new XPRBprob("example2")) {
double val = expl2.getXPRSdblControl(XPRB.XPRS_MIPTOL);
}
c - name of the control parametergetXPRSprob(),
XPRSprob.getDblControl(int)@Deprecated
public void setXPRSintControl(int c,
int val)
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.setXPRSintControl(XPRB.XPRS_MAXMIPSOL,1);
}
c - name of the control parameterval - new value for the control parametergetXPRSprob(),
XPRSprob.setIntControl(int,int)@Deprecated
public void setXPRSdblControl(int c,
double val)
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.setXPRSdblControl(XPRB.XPRS_MIPADDCUTOFF,0.99);
}
c - name of the control parameterval - new value for the control parametergetXPRSprob(),
XPRSprob.setDblControl(int,double)public com.dashoptimization.XPRSprob getXPRSprob()
XPRSprob object to be used with
specific Xpress-Optimizer operations. The Xpress-Optimizer Java
needs to be initialized with XPRS.init() before the
Optimizer problem is accessed.public void setCutMode(int mode)
try (XPRBprob expl2 = new XPRBprob("example2")) {
expl2.setCutMode(1);
}
mode - choice of parameter settings. Possible values:
0 standard settings 1 parameter settings required for cuts public XPRBcut newCut(XPRBrelation lr, int id)
XPRBcut.addTerm(com.dashoptimization.XPRBvar, double) or
XPRBcut.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
method XPRBcut.setType(int).
try (XPRBprob expl2 = new XPRBprob("example2")) {
XPRBvar x2 = expl2.newVar("x2");
XPRBcut cut = expl2.newCtr(x2.gEql(3), 1);
}
lr - linear relation (default 0-valued equality relation)id - identification number for cut classification (default 0)XPRBcutpublic XPRBcut newCut()
newCut(0, 0)public XPRBcut newCut(int id)
newCut(0, id)public XPRBcut newCut(XPRBrelation lr)
newCut(lr, 0)public XPRBcut newCut(XPRBexpr l)
newCut(l, 0)public XPRBcut newCut(XPRBexpr l, int id)
newCut(l, id)public void addCuts(XPRBcut[] ca)
XPRScutRoundListener).
Cuts are not stored in the BCL problem.
static class CutMgrCallback implements XPRScutRoundListener {
public int XPRScutRoundEvent(XPRSprob oprob, Object data, int ifxpresscuts, IntHolder p_action) {
XPRBcur[] cut;
XPRBprob pb;
pb = (XPRBprob)data;
... // Definition of cuts in array "cut"
pb.addCuts(cut);
}
}
...
try (XPRBprob expl2 = new XPRBprob("example2")) {
CutRoundCallback cb = new CutRoundCallback();
expl2.addRoundMgrListener(cb, expl2);
}
ca - array of previously defined cuts (type XPRBcut)public void writeSol()
writeSol("", "")public void writeSol(java.lang.String fname)
writeSol(fname, "")public void writeSol(java.lang.String fname,
java.lang.String flags)
throws java.io.IOException
try (XPRBprob expl2 = new XPRBprob("example2")) {
...
expl2.writeSol("myprob", "nar");
}
fname - name of the output file without extensionjava.io.IOExceptionpublic void writeBinSol()
writeBinSol("", "")public void writeBinSol(java.lang.String fname)
writeBinSol(fname, "")public void writeBinSol(java.lang.String fname,
java.lang.String flags)
throws java.io.IOException
try (XPRBprob expl2 = new XPRBprob("example2")) {
...
expl2.writeBinSol("myprob", "x");
}
fname - name of the output file without extensionjava.io.IOExceptionpublic void writePrtSol()
writePrtSol("", "")public void writePrtSol(java.lang.String fname)
writePrtSol(fname, "")public void writePrtSol(java.lang.String fname,
java.lang.String flags)
throws java.io.IOException
try (XPRBprob expl2 = new XPRBprob("example2")) {
...
expl2.writePrtSol("myprob", "x");
}
fname - name of the output file without extensionjava.io.IOExceptionpublic void writeSlxSol()
writeSlxSol("", "")public void writeSlxSol(java.lang.String fname)
writeSlxSol(fname, "")public void writeSlxSol(java.lang.String fname,
java.lang.String flags)
throws java.io.IOException
try (XPRBprob expl2 = new XPRBprob("example2")) {
...
expl2.writeSlxSol("myprob", "pm");
}
fname - name of the output file without extensionjava.io.IOExceptionpublic void readBinSol()
readBinSol("", "")public void readBinSol(java.lang.String fname)
readBinSol(fname, "")public void readBinSol(java.lang.String fname,
java.lang.String flags)
throws java.io.IOException
try (XPRBprob expl2 = new XPRBprob("example2")) {
...
expl2.readBinSol("myprob", "m");
}
fname - name of the output file without extensionjava.io.IOExceptionpublic void readSlxSol()
readSlxSol("", "")public void readSlxSol(java.lang.String fname)
readSlxSol(fname, "")public void readSlxSol(java.lang.String fname,
java.lang.String flags)
throws java.io.IOException
try (XPRBprob expl2 = new XPRBprob("example2")) {
...
expl2.readSlxSol("myprob", "m");
}
fname - name of the output file without extensionjava.io.IOExceptionpublic void close()
XPRB.close()) the program must not access any objects
of the problem after this call.
It is recommended to call this function only implicitly through
try-with-resources.
try (XPRB bcl=new XPRBprob("example2")) { // Create a problem
...
} // Finalize the problem
close in interface java.lang.AutoCloseablepublic boolean setExplicitGarbageCollect(boolean value)
@Deprecated public void finalize()
close(), or, even better,
use try-with-resources.finalize in class java.lang.Object