problem.setcbcascadevar
problem.setcbcascadevar |
Purpose
Set a user callback to be called after each column has been cascaded
Synopsis
problem.setcbcascadevar (callback, data)
retval = callback (my_prob, my_object, colindex)
Arguments
callback
|
The function to be called after each column has been cascaded.
callback returns an integer value. If the return value is nonzero, the cascading process will be omitted for the remaining variables during the current SLP iteration, but the optimization will continue.
|
my_prob
|
The problem passed to the callback function.
|
my_object
|
The user-defined object passed as
data to
problem.setcbcascadevar.
|
colindex
|
The number of the column which has been cascaded.
|
data
|
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 after each variable has been cascaded:
obj = [] p.setcbcascadevar (CBCascVar, obj)
The following sample callback function resets the value of the variable if the cascaded value is of the opposite sign to the original value:
def CBCascVar (myprob, obj, iCol): (a,b,c,d,e,f,value,g,h,i,j,k,l,m,n) = myprob.getvar (iCol) if (value * obj[iCol] < 0): p.chgvar (myprob, ColNum, None, None, None, None, None, None, obj[iCol], None, None, None, None) return 0
The
data argument is used here to hold the address of the array
cSol which we assume has been populated with the original solution values.
Further information
This callback can be used after each variable has been cascaded and its new value has been calculated.
Related topics