XPRBsos
- java.lang.Object
-
- com.dashoptimization.XPRBsos
-
public class XPRBsos extends java.lang.ObjectThis class represents a Special Ordered Set (SOS) definition in BCL. All members in SOS must belong to the same problem as the SOS itself.
-
-
Method Summary
Modifier and Type Method and Description voidadd(XPRBexpr l)Add a linear expression to a SOS.voidaddElement(double val, XPRBvar var)voidaddElement(XPRBvar var, double val)Add an element to a SOS.voidassign(XPRBexpr l)Assign a linear expression to a SOS.voiddelElement(XPRBvar var)Delete an element from a SOS.java.lang.StringgetName()Get the name of a SOS.intgetType()Get the type of a SOS.booleanisValid()Test whether a SOS is correctly defined.voidprint()Print out a Special Ordered Set.voidsetDir(int type)voidsetDir(int type, double val)Set a branching directive for a SOS.java.lang.StringtoString()
-
-
-
Method Detail
-
isValid
public boolean isValid()
Test whether a SOS is correctly defined.XPRBsos set1; if(set1.isValid() == false) System.out.println("Error in SOS definition.");
-
assign
public void assign(XPRBexpr l) throws java.lang.ArithmeticException
Assign a linear expression to a SOS.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);- Parameters:
-
l- linear expression - Throws:
-
java.lang.ArithmeticException
-
getName
public java.lang.String getName()
Get the name of a SOS. If the user has not defined a name the default name generated by BCL is returned.XPRBprob expl2; XPRBsos set1; expl2 = new XPRBprob("example2"); set1 = expl2.newSos("sos1", XPRB.S1); System.out.println("SOS name:" + set1.getName());- Returns:
-
Name of the SOS if method executed successfully,
nullotherwise
-
getType
public int getType()
Get the type of a SOS.XPRBprob expl2; XPRBsos set1; int stype; expl2 = new XPRBprob("example2"); set1 = expl2.newSos("sos1", XPRB.S1); stype = set1.getType();- Returns:
-
Type of the SOS. Possible values:
XPRB.S1Special Ordered Set of type 1XPRB.S2Special Ordered Set of type 2-1an error has occurred
-
setDir
public void setDir(int type, double val)Set a branching directive for a SOS. This method sets any type of branching directive available in Xpress. This may be a priority for branching on a SOS (typeXPRB.PR), the preferred branching direction (typesXPRB.UP, XPRB.DN) or the estimated cost incurred when branching on a SOS (typesXPRB.PU, XPRB.PU). Several directives of different types may be set for a single set. MethodXPRBvar.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);- Parameters:
-
type- directive type. Possible values:XPRB.PRpriorityXPRB.UPfirst branch upwardsXPRB.DNfirst branch downwardsXPRB.PUpseudocost on branching upwardsXPRB.PDpseudocost on branching downwards
-
val- 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 branch
-
setDir
public void setDir(int type)
- See Also:
-
setDir(type, 0)
-
addElement
public void addElement(XPRBvar var, double val)
Add an element to a SOS. This method adds a variable and its weight coefficient to a Special Ordered Set. If the variable is already contained in the set, the indicated value is added to its weight. Note that weight coefficients must be different from 0.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);- Parameters:
-
var- a variable of typeXPRBvar -
val- the corresponding weight or reference value
-
addElement
public void addElement(double val, XPRBvar var)- See Also:
-
addElement(type, 0)
-
delElement
public void delElement(XPRBvar var)
Delete an element from a SOS.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);- Parameters:
-
var- a variable of typeXPRBvar
-
add
public void add(XPRBexpr l) throws java.lang.ArithmeticException
Add a linear expression to a SOS. If a variable in the linear expression is already contained in the set, the indicated value is added to its weight. Constant terms in the linear expression are ignored.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);- Parameters:
-
l- linear expression - Throws:
-
java.lang.ArithmeticException
-
print
public void print()
Print out a Special Ordered Set. This method is not available in the Student Edition.XPRBprob expl2; XPRBsos set1; expl2 = new XPRBprob("example2"); set1 = expl2.newSos("sos1", XPRB.S1); set1.print();
-
toString
public java.lang.String toString()
- Overrides:
-
toStringin classjava.lang.Object - See Also:
-
getName()
-
-
© 2001-2020 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.
