Initializing help system before first use

XPRBvar

Description
Methods for modifying and accessing variables.
Constructors
Methods
Fix a variable.
Get the column number for a variable.
Get the C modeling object.
Get the lower bound on a variable.
Get the integer limit for a partial integer or the semi-continuous limit for a semi-continuous or semi-continuous integer variable.
Get the name of a variable.
Get the reduced cost value.
Get ranging information.
Get the solution value.
Get the type of a variable.
Get the upper bound on a variable.
Test the validity of the variable object.
Print out a variable.
Set a branching directive for a variable.
Set a lower bound.
Set the integer limit for a partial integer, or the lower semi-continuous limit for a semi-continuous or semi-continuous integer variable.
Set the variable type.
Set an upper bound.

Constructor detail

XPRBvar
Synopsis
XPRBvar();
XPRBvar(xbvar *v);
Argument
A variable in BCL C.
Description
Create a new variable object.

Method detail

fix
Synopsis
int fix(double val);
Argument
val 
The value to which the variable is to be fixed.
Return value
0 if method executed successfully, 1 otherwise.
Description
This method fixes a variable to the given value. It replaces calls to XPRBvar.setLB and XPRBvar.setUB. The value val may lie outside the original bounds of the variable. If the problem is loaded in the Optimizer, the bound change is passed on immediately without any need to reload the problem.
Related topics
Calls XPRBfixvar

getColNum
Synopsis
int getColNum();
Return value
Column number (non-negative value), or a negative value.
Description
This method returns the column number of a variable in the matrix currently loaded in the Xpress Optimizer. If the variable is not part of the matrix, or if the matrix has not yet been generated, the function returns a negative value. To check whether the matrix has been generated, use function XPRBprob.getProbStat. The counting of column numbers starts with 0.
Example
Related topics

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

getLB
Synopsis
double getLB();
Return value
Lower bound on the variable (default 0).
Description
This method returns the currently defined lower bound on a variable.
Example
Related topics

getLim
Synopsis
double getLim();
Return value
Limit value (default 1):
Description
This method returns the currently defined integer limit for a partial integer variable or the lower semi-continuous limit for a semi-continuous or semi-continuous integer variable.
Example
Related topics
Calls XPRBgetlim

getName
Synopsis
const char *getName();
Return value
Name of the variable if executed successfully, NULL otherwise.
Description
This method returns the name of a variable. If the user has not defined a name the default name generated by BCL is returned.
Example
The following example displays information about a semi-continuous variable. The output printed by this program extract is shown in the comment.
XPRBvar s;
XPRBprob prob("myprob");

s = prob.newVar("s", XPRB_SC, 0, 200);
s.setLim(10);
if (s.getType()==XPRB_SC || s.getType()==XPRB_SI)
{
 cout << s.getName() << " in {" << s.getLB() << "}+[";
 cout << s.getLim() << "," << s.getUB() << "]" << endl;
}                // s in {0}+[10,200]  
Related topics

getRCost
Synopsis
double getRCost();
Return value
Reduced cost value for the variable, 0 in case of an error.
Description
This method returns the reduced cost value for a variable. The user may wish to test first whether this variable is part of the problem, for instance by checking that the column number is non-negative.
Reduced cost information is available only after LP solving. To obtain reduced cost values for a MIP solution (that is, if function XPRBprob.getMIPStat returns values XPRB_MIP_SOLUTION or XPRB_MIP_OPTIMAL), you need to fix the discrete variables to their solution values with a call to XPRSfixmipentities, followed by a call to XPRBlpoptimize before calling XPRBgetrcost. Otherwise, if this function is called when a MIP solution is available it returns 0.
If no solution information is available this function outputs a warning and returns 0.
If this function is used during the execution of an optimization process (for instance in Optimizer library callback functions) it needs to be preceded by a call to XPRBprob.sync with the flag XPRB_XPRS_SOL. In this case it returns the reduced cost value in the last LP that has been solved.
Example
Related topics
Calls XPRBgetrcost

getRNG
Synopsis
double getRNG(int rngtype);
Argument
rngtype 
The type of ranging information sought. This is one of:
XPRB_UUP 
the change in objective value per unit increase in the variable activity, assuming the the current basis remains optimal;
XPRB_UDN 
the change in objective value per unit decrease in the variable activity, assuming the the current basis remains optimal;
XPRB_UCOST 
the largest value which this variable's objective coefficient can take while the current basis remains optimal;
XPRB_LCOST 
the smallest value which this variable's objective coefficient can take while the current basis remains optimal;
XPRB_UPACT 
for a variable which is at one of its bounds, the largest value which that bound can take while the current basis remains optimal;
XPRB_LOACT 
for a variable which is at one of its bounds, the smallest value which that bound can take while the current basis remains optimal.
Return value
Ranging information of the required type.
Description
1. This method can only be used after solving an LP problem. Ranging information for MIP problems can be obtained by fixing all discrete variables to their solution values and re-solving the resulting LP problem.
2. For non-basic variables, the unit costs are always the values of the reduced costs.
Example
This example retrieves ranging information (lower and upper activity) for a variable.
XPRBvar x;
XPRBprob prob("myprob");

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

...  // Define and solve an LP problem

cout << "x: " << x.getSol();
cout << " (act. range: " << x.getRNG(XPRB_LOACT) << ", " ;
cout << x.getRNG(XPRB_UPACT) << ")" << endl; 
Related topics

getSol
Synopsis
double getSol();
Return value
Primal solution value for the variable, 0 in case of an error.
Description
This function returns the current solution value for a variable. The user may wish to test first whether this variable is part of the problem, for instance by checking that the column number is non-negative.
If this function is called after completion of a branch and bound tree search and an integer solution has been found (that is, if function XPRBprob.getMIPStat returns values XPRB_MIP_SOLUTION or XPRB_MIP_OPTIMAL), it returns the value of the best integer solution. If no integer solution is available after a branch and bound tree search this function outputs a warning and returns 0. In all other cases it returns the solution value in the last LP that has been solved. If this function is used during the execution of an optimization process (for instance in Optimizer library callback functions) it needs to be preceded by a call to XPRBprob.sync with the flag XPRB_XPRS_SOL.
Example
This example retrieves the solution information for the variable x after solving an LP problem.
XPRBprob prob("myprob");
XPRBvar x;
   ...
x = prob.newVar("x", XPRB_PL, 0, 200);
prob.lpOptimize();
if (x.getColNum() >= 0 && prob.getLPStat()==XPRB_LP_OPTIMAL)
{
 cout << x.getName() << ": solution: " << x.getSol();
 cout << " reduced cost: " << x.getRCost() << endl;
}
else
 cout << "No solution information available." << endl; 
Related topics
Calls XPRBgetsol

getType
Synopsis
int getType();
Return value
XPRB_PL 
continuous;
XPRB_BV 
binary;
XPRB_UI 
general integer;
XPRB_PI 
partial integer;
XPRB_SC 
semi-continuous;
XPRB_SI 
semi-continuous integer;
-1 
an error has occurred.
Description
If the function exits successfully, the variable type is returned.
Example
Related topics

getUB
Synopsis
double getUB();
Return value
Upper bound on the variable (default XPRB_INFINITY).
Description
This method returns the currently defined upper bound on a variable.
Example
Related topics

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

print
Synopsis
int print();
Return value
The number of characters printed.
Description
This method prints out a variable.
Example
Related topics
Calls XPRBprintvar

setDir
Synopsis
int setDir(int type, double val);
int setDir(int type);
Arguments
type 
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 directive to be defined. Must be one of:
XPRB_PR 
priority value — an integer between 1 (highest) and 1000 (least priority), the default;
XPRB_UP 
no input required;
XPRB_DN 
no input required;
XPRB_PU 
value of the pseudo cost on branching upwards;
XPRB_PD 
value of the pseudo cost on branching downwards.
Return value
0 if method executed successfully, 1 otherwise.
Description
1. This method sets any type of branching directive available in Xpress. This may be a priority for branching on a variable (type XPRB_PR), the preferred branching direction (types XPRB_UP, XPRB_DN) or the estimated cost incurred when branching on a variable (types XPRB_PU, XPRB_PD). Several directives of different types may be set for a single variable.
2. Note that it is only possibly to set branching directives for discrete variables (including semi-continuous and partial integer variables). Method XPRBsos.setDir may be used to set a directive for a SOS.
Example
Related topics

setLB
Synopsis
int setLB(double val);
Argument
val 
The variable's new lower bound.
Return value
0 if method executed successfully, 1 otherwise.
Description
This method sets the lower bound on a variable. If the problem is loaded in the Optimizer, the bound change is passed on immediately without any need to reload the problem.
Related topics
Calls XPRBsetlb

setLim
Synopsis
int setLim(double val);
Argument
val 
Value of the integer limit.
Return value
0 if method executed successfully, 1 otherwise.
Description
This method sets the integer limit ( i.e. the lower bound of the continuous part) of a partial integer variable or the semi-continuous limit of a semi-continuous or semi-continuous integer variable to the given value.
Example
Related topics
Calls XPRBsetlim

setType
Synopsis
int setType(int type);
Argument
type 
The variable type, which is one of:
XPRB_PL 
continuous;
XPRB_BV 
binary;
XPRB_UI 
general integer;
XPRB_PI 
partial integer;
XPRB_SC 
semi-continuous;
XPRB_SI 
semi-continuous integer.
Return value
0 if method executed successfully, 1 otherwise.
Description
This method changes the type of a variable that has been created previously.
Related topics

setUB
Synopsis
int setUB(double val);
Argument
val 
The variable's new upper bound.
Return value
0 if method executed successfully, 1 otherwise.
Description
This method sets the upper bound on a variable. If the problem is loaded in the Optimizer, the bound change is passed on immediately without any need to reload the problem.
Related topics
Calls XPRBsetub


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