public class XPRBsos
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
void |
add(XPRBexpr l)
Add a linear expression to a SOS.
|
void |
addElement(double val,
XPRBvar var) |
void |
addElement(XPRBvar var,
double val)
Add an element to a SOS.
|
void |
assign(XPRBexpr l)
Assign a linear expression to a SOS.
|
void |
delElement(XPRBvar var)
Delete an element from a SOS.
|
java.lang.String |
getName()
Get the name of a SOS.
|
int |
getType()
Get the type of a SOS.
|
boolean |
isValid()
Test whether a SOS is correctly defined.
|
void |
print()
Print out a Special Ordered Set.
|
void |
setDir(int type) |
void |
setDir(int type,
double val)
Set a branching directive for a SOS.
|
java.lang.String |
toString() |
public boolean isValid()
XPRBsos set1;
if(set1.isValid() == false)
System.out.println("Error in SOS definition.");
public void assign(XPRBexpr l) throws java.lang.ArithmeticException
XPRBprob expl2;
XPRBvar[] x;
int i;
XPRBexpr l;
XPRBsos set3;
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));
set3.assign(l);
l - linear expressionjava.lang.ArithmeticExceptionpublic java.lang.String getName()
XPRBprob expl2;
XPRBsos set1;
expl2 = new XPRBprob("example2");
set1 = expl2.newSos("sos1", XPRB.S1);
System.out.println("SOS name:" + set1.getName());
null otherwisepublic int getType()
XPRBprob expl2;
XPRBsos set1;
int stype;
expl2 = new XPRBprob("example2");
set1 = expl2.newSos("sos1", XPRB.S1);
stype = set1.getType();
XPRB.S1 Special Ordered Set of
type 1XPRB.S2 Special Ordered Set of type 2-1 an error has occurredpublic void setDir(int type,
double val)
XPRB.PR), the preferred branching direction
(types XPRB.UP, XPRB.DN) or the estimated cost
incurred when branching on a SOS (types XPRB.PU,
XPRB.PU). Several directives of different types may be set for
a single set. Method XPRBvar.setDir(int, double) may be used to set
a branching directive for a variable.
XPRBprob expl2;
XPRBsos set1;
expl2 = new XPRBprob("example2");
set1 = expl2.newSos("sos1", XPRB.S1);
set1.setDir(XPRB.PR, 5);
set1.setDir(XPRB.DN);
type - directive type. Possible values:
XPRB.PR priorityXPRB.UP first branch upwardsXPRB.DN first branch downwardsXPRB.PU pseudocost on branching upwards XPRB.PD pseudocost on branching downwardsval - the value of this argument depends on the type of
directive to be defined. Possible values:
XPRB.PR: priority value, integer
between 1 (highest) and 1000 (least priority, default
value)XPRB.UP,XPRB.DN: no input required, choose any
dummy value (e.g. 0) XPRB.PU,XPRB.PD: value of pseudocost for the
corresponding branchpublic void setDir(int type)
setDir(type, 0)public void addElement(XPRBvar var, double val)
XPRBprob expl2;
XPRBsos set1;
XPRBvar x2;
expl2 = new XPRBprob("example2");
x2 = expl2.newvar("abc1", XPRB.PL, 0, INFINITY);
set1 = expl2.newSos("sos1", XPRB.S1);
set1.addElement(x2, 9);
var - a variable of type XPRBvarval - the corresponding weight or reference valuepublic void addElement(double val,
XPRBvar var)
addElement(type, 0)public void delElement(XPRBvar var)
XPRBprob expl2;
XPRBsos set1;
XPRBvar x2;
expl2 = new XPRBprob("example2");
x2 = expl2.newvar("abc1", XPRB.PL, 0, INFINITY);
set1 = expl2.newSos("sos1", XPRB.S1);
set1.addElement(x2, 9);
set1.delElement(x2);
var - a variable of type XPRBvarpublic void add(XPRBexpr l) throws java.lang.ArithmeticException
XPRBprob expl2;
XPRBvar[] x;
int i;
XPRBexpr l;
XPRBsos set3;
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));
set3 = expl2.newSos("sos2", XPRB.S2);
set3.add(l);
l - linear expressionjava.lang.ArithmeticExceptionpublic void print()
XPRBprob expl2;
XPRBsos set1;
expl2 = new XPRBprob("example2");
set1 = expl2.newSos("sos1", XPRB.S1);
set1.print();
public java.lang.String toString()
toString in class java.lang.ObjectgetName()