Initializing help system before first use

XPRBsos

Description
Methods for modifying and accessing Special Ordered Sets and operators for constructing them. Note that all members in a SOS must belong to the same problem as the SOS itself.
Constructors
Methods
Add a linear expression to a SOS.
Add an element to a SOS.
Delete an element from a SOS.
Get the C modeling object.
Get the name of a SOS.
Get the type of a SOS.
Test the validity of the SOS object.
Print out a SOS
Set a branching directive for a SOS.
Operators
Assigning and adding linear expressions to Special Ordered Sets:
set = linexp
set += linexp

Constructor detail

XPRBsos
Synopsis
XPRBsos();
XPRBsos(xbsos *s);
XPRBsos(xbsos *s, XPRBexpr& l);
Arguments
A SOS in BCL C.
Linear expression defining the SOS.
Description
Create a new SOS object.

Method detail

add
Synopsis
int add(const XPRBexpr& le);
Argument
le 
A linear expression.
Return value
0 if method executed successfully, 1 otherwise.
Description
This method adds the variables of a linear expression to a SOS, using their coefficients in the linear expression as weights.
Example
This example shows different ways of defining SOS and modifying their contents. The resulting SOS definitions (as obtained with XPRBsos.print) and the output printed by the program are displayed as comments.
XPRBvar x,y,z;
XPRBsos SO1, SO2;
XPRBprob prob("myprob");

x = prob.newVar("x", XPRB_PL, 0, 200);
y = prob.newVar("y", XPRB_PL, 0, 200);
z = prob.newVar("z", XPRB_PL, 0, 200);

SO1 = prob.newSos("SO1", XPRB_S1);
SO1.add(x+2*y+3*z);       // SO1(1): x(+1) y(+2) z(+3)
SO1 += 2*z-x;             // SO1(1): y(+2) z(+5)
cout << SO1.getName() << " type: ";
cout << (SO1.getType()==XPRB_S1?1:2) << endl;
                          // SO1 type: 1
SO2 = prob.newSos("SO2", XPRB_S2, 10*x+20*y);
SO2.addElement(z, 5);     // SO2(2): x(+10) y(+20) z(+5)
SO2.delElement(x);        // SO2(2): y(+20) z(+5) 

addElement
Synopsis
int addElement(XPRBvar& var, double val);
int addElement(double val, XPRBvar& var);
Arguments
var 
Reference to a variable.
val 
The corresponding weight or reference value.
Return value
0 if function executed successfully, 1 otherwise
Description
This method adds a single 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.
Example
Related topics
Calls XPRBaddsosel

delElement
Synopsis
int delElement(XPRBvar& var);
Argument
var 
A BCL variable.
Return value
0 if method executed successfully, 1 otherwise.
Description
This function removes a variable from a Special Ordered Set.
Example
Related topics
Calls XPRBdelsosel

getCRef
Synopsis
xbsos *getCRef();
Return value
The underlying modeling object in BCL C.
Description
This method returns the SOS object in BCL C that belongs to the C++ SOS object.

getName
Synopsis
const char *getName();
Return value
Name of the SOS if executed successfully, NULL otherwise.
Description
This method returns the name of a SOS. If the user has not defined a name the default name generated by BCL is returned.
Example
Related topics

getType
Synopsis
int getType();
Return value
XPRB_S1 
a Special Ordered Set of type 1;
XPRB_S2 
a Special Ordered Set of type 2;
-1 
an error has occurred.
Description
This method returns the type of a SOS.
Example
Related topics

isValid
Synopsis
bool isValid();
Return value
true if object is valid, false otherwise.
Description
This method checks whether the SOS object is correctly defined. It should always be used to test the result returned by XPRBprob.getSosByName.
Example

print
Synopsis
int print();
Return value
0 if function executed successfully, 1 otherwise.
Description
This method prints out a SOS.
Example
Related topics
Calls XPRBprintsos

setDir
Synopsis
int setDir(int type, double val);
int setDir(int type);
Arguments
type 
The directive type, which must be one of:
XPRB_PR 
priority;
XPRB_UP 
first branch upwards;
XPRB_DN 
first branch downwards;
XPRB_PU 
pseudo cost on branching upwards;
XPRB_PD 
pseudo cost on branching downwards.
val 
An argument dependent on the type of the directive being defined. If type is:
XPRB_PR 
val will be the priority value, an integer between 1 (highest) and 1000 (lowest), the default;
XPRB_UP 
no input is required;
XPRB_DN 
no input is required;
XPRB_PU 
val will be the value of the pseudo cost for the upward branch;
XPRB_PD 
val will be the value of the pseudo cost for the downward branch.
Return value
0 if method executed successfully, 1 otherwise.
Description
This method sets any type of branching directive available in Xpress. This may be a priority for branching on a SOS (type 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_PD). Several directives of different types may be set for a single set. Method XPRBvar.setDir may be used to set a directive for a variable.
Example
Related topics


© 2001-2024 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.