problem.setcbconstruct
problem.setcbconstruct |
Purpose
Set a user callback to be called during the Xpress SLP augmentation process
Synopsis
problem.setcbconstruct (callback, data)
retval = callback (my_prob, my_object)
Arguments
callback
|
The function to be called during problem augmentation.
callback returns an integer value. See below for an explanation of the values.
|
my_prob
|
The problem passed to the callback function.
|
my_object
|
The user-defined object passed as
data to
setcbconstruct.
|
data
|
Address of a user-defined object, which can be used for any purpose by the function.
data is passed to
callback as
my_object.
|
Example
The following example sets up a callback to be executed during the Xpress SLP problem augmentation:
value = [] p.setcbconstruct (CBConstruct, value)
The following sample callback function sets values for the variables the first time the function is called and returns to
problem.construct to recalculate the initial matrix. The second time it is called it frees the allocated memory and returns to
problem.construct to proceed with the rest of the augmentation.
def CBConstruct (myprob, obj) { if (obj == None): n = myprob.attributes.cols cValue = n * [0] # initialize with values (not shown here) for i in range (n): # store into SLP structures myprob.chgvar (i, None, None, None, None, None, None, cValue[i], None, None, None, None) # set Object non-null to indicate we have processed data obj = cValue return -1 else: obj = None return 0
Further information
This callback can be used during the problem augmentation, generally (although not exclusively) to change the initial values for the variables.
The following return codes are accepted:
- 0
- Normal return: augmentation continues
- -1
- Return to recalculate matrix values
- -2
- Return to recalculate row weights and matrix entries
- other
- Error return: augmentation terminates, problem.construct terminates with a nonzero error code.
The return values -1 and -2 will cause the callback to be called a second time after the matrix has been recalculated. It is the responsibility of the callback to ensure that it does ultimately exit with a return value of zero.
Related topics